C_T has asked for the wisdom of the Perl Monks concerning the following question:
my(@input_array) =(); chomp(@input_array = <STDIN>); #===== Search for a e i o and u (case insensitive) foreach $_ (@input_array) { if ($_ =~ /a/i && /e/i && /i/i && /o/i && /u/i) { print $_, "\n"; } }
This code fails with "Use of uninitialized value in pattern match (m//) at ./match4 line 19, <STDIN> line 3.":
What gives? Isn't it just about the same exact code?my(@input_array) =(); my($one_line) = ''; chomp(@input_array = <STDIN>); #===== Search for a e i o and u (case insensitive) foreach $one_line(@input_array) { if ($one_line =~ /a/i && /e/i && /i/i && /o/i && /u/i) { print $one_line, "\n"; } }
For some reason, I keep getting these "uninitialized value" warnings on my OSX machine when running examples that gave me no errors on the Unix machine we used for my class. Something is different between the two Unix implementations, but I'm not sure what I'm doing wrong.
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: $_ works, $my_variable doesn't?
by merlyn (Sage) on Mar 29, 2004 at 22:15 UTC | |
by C_T (Scribe) on Mar 29, 2004 at 22:29 UTC | |
|
Re: $_ works, $my_variable doesn't?
by eric256 (Parson) on Mar 29, 2004 at 22:19 UTC | |
|
Re: $_ works, $my_variable doesn't?
by revdiablo (Prior) on Mar 29, 2004 at 22:20 UTC | |
by dragonchild (Archbishop) on Mar 30, 2004 at 02:09 UTC | |
by bageler (Hermit) on Mar 30, 2004 at 03:54 UTC | |
by dragonchild (Archbishop) on Mar 30, 2004 at 13:53 UTC | |
by duff (Parson) on Mar 30, 2004 at 14:28 UTC | |
| |
|
Re: $_ works, $my_variable doesn't?
by fglock (Vicar) on Mar 31, 2004 at 17:44 UTC |