> Why are $1, $2, $3, and $4 in quotes? What's > wrong with this: > > my @array = ( $1, $2, $3, $4 ); > > Or this: > > my @array = //;
Sorry, when I use the second way u mentioned,it can't work. the code: while(<>) { next unless /$host/; $_=~/\((\w+)\,\s*(\d+)\)\s+\((\w+)\,\s*(\d+)\)/; # my @array=("$1","$2","$3","$4"); my @array=qw/$1 $2 $3 $4/; print join (":",@array),"\n"; } executing the script: $ perl t10.pl tt2.txt $1:$2:$3:$4 why this happen? On Mon, 12 Sep 2005 02:38:25 -0500, "Charles K. Clarkson" <[EMAIL PROTECTED]> said: > Jeff Pan <mailto:[EMAIL PROTECTED]> wrote: > > : Is this feasible? > > Yes, but ... > > > : while(<>) > : { > : next unless /$host/; > : $_=~/\((\w+)\,(\d+)\)\s+\((\w+)\,(\d+)\)/; > > What happens if this doesn't match? Then $1, $2, > $3, and $4 will be unitialized in the next statement. > Better to check that this match happens. > > : my @array=("$1","$2","$3","$4"); > > Why are $1, $2, $3, and $4 in quotes? What's > wrong with this: > > my @array = ( $1, $2, $3, $4 ); > > Or this: > > my @array = //; > > > : } > > HTH, > > Charles K. Clarkson > -- > Mobile Homes Specialist > 254 968-8328 > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > -- Jeff Pan [EMAIL PROTECTED] -- http://www.fastmail.fm - Send your email first class -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>