Perl regexp use of uninitialized pattern patch?

First of all, it's always a good idea to use strict pragma -- unless you have a valid reason to avoid it.

First of all, it's always a good idea to use strict pragma -- unless you have a valid reason to avoid it --. Second, I don't see $plm3 initialized anywhere in your code. You have probably forgot to initialize it.

Yes, frist I wrote it with strict but when I changed it to take file and array names dynamically I had to abandon it, things like @{$1} didn't work with strict – Benca Lucian Jun 29 '11 at 7:59 right I initialized $plm3 and got rid of "Use of uninitialized value in pattern match (m//) at emo_full_dynamic. Pl line 120, chunk 2. " now i'm left only with "Modification of a read-only value attempted at emo_full_dynamic.

Pl line 121, chunk 2. " line 120 = $plm3 =~ /arr_(\w+. Txt)/; – Benca Lucian Jun 29 '11 at 8:00 @Benca Lucian: strict prevents you from doing things like @{$1} for a reason; it's generally very poor planning that brings you to using symbolic refs.

Just use a hash: my %arrays; push @{$arrays{$1}}, .... ;, for example is a preferable way. See perlref and perlreftut from Perl's documentation. – DavidO Jun 29 '11 at 8:19 ok, will give hashes a go, thanks!

– Benca Lucian Jun 29 '11 at 8:26.

I think you are assigning something to variable $1 on line 121.

Apparently there are some copy/paste issues which negates my initial answer. Other mistakes, great and small: You don't use strict. (fatal flaw) Your opendir is used once, then never closed.

You use global filehandles, instead of lexical (e.g. Open my $fh, ...) Using a complext loop + splice instead of grep (@files=grep /^arr/i, @files) Using chomp($_) when chomp per default chomps the $_ variable I don't even know what this line means: if(grep $stare =~ m/$_/i, @{$1}) { You seem to be using a pattern match, where $_ is the pattern (which in this case is.. what? Nothing? Anything?

), whose return value is used as a grep pattern for an array reference, that may or may not be initialized. A very horrible statement. If it indeed works as intended, the readability is very low.

Redeclaring $/ seems like a frivolous thing to do in this context, but I can't really tell, as the script ends there.

That part opens files that have a speciffic name format and then generates arrays with similar name and loads data from files to those arrays. Strangely that first "{" isn't in my code, it's probably from the copy/paste and reindenting from editor to post, that part works fine, I fact all of it works fine except those last lines – Benca Lucian Jun 29 '11 at 9:04 @Benca Fix the other things I mention in my updated answer. Then please edit your question to include your new code, using a complete copy/paste.

– TLP Jun 29 '11 at 9:19 @Benca And most importantly, add use strict; use warnings; It may seem like a lot of work to fix the errors, but in reality, you save a lot more time in the end, because the hidden bugs become visible. – TLP Jun 29 '11 at 9:22 @Benca Oh, sorry, I see you are using warnings. Well, then add strict.

– TLP Jun 29 '11 at 9:24 I can't use strict for reasons stated above, I do use warnings it's right there in the code:), closing DIR handle is not part of the problem, "if(grep $stare =~ m/$_/i, @{$1})" this lets me get a match when the input has more or less chars than the actual string i'm looking for, there are a lot of other validations that are not part of the problem so I didn't post them, soory for the low readability but it's perl after all:P, I need to redeclare $/ so that I can read elements from some files that are have a different separators, thanks for the other tips though, appreciated very much – Benca Lucian Jun 29 '11 at 9:29.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions