a369 has asked for the wisdom of the Perl Monks concerning the following question:
The following script get warning: "Use of uninitialized value in concatenation (.) or string at C:\tools\test.pl line 17, <DATA> line 1." But the next line of __DATA__ will be processed without any warning and get these: test1b.txt:test test1c.txt:test :test More strange thing is that when I add a line: print "$line:".$'."\n"; The warning disappeared. Anybody have some clues?
#file: test.pl #!/usr/bin/perl -w use strict; my $pattern='test'; my $output='$&'; while(<DATA>) { chomp; my $line=$_; chomp($line); $line=~/$pattern/; #print "$line:".$'."\n"; #why uncommenting this line make the fo +llowing line pass without no warning. my $result="$line:".eval($output)."\n"; print $result; } __DATA__ test1a.txt test1b.txt test1c.txt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: strange thing in perl's eval function
by 2teez (Vicar) on Jun 07, 2013 at 07:39 UTC | |
by a369 (Initiate) on Jun 07, 2013 at 07:59 UTC | |
|
Re: strange thing in perl's eval function
by choroba (Cardinal) on Jun 07, 2013 at 06:49 UTC | |
by a369 (Initiate) on Jun 07, 2013 at 08:07 UTC | |
|
Re: strange thing in perl's eval function (re match vars)
by Anonymous Monk on Jun 07, 2013 at 07:17 UTC | |
by a369 (Initiate) on Jun 07, 2013 at 07:42 UTC | |
by Anonymous Monk on Jun 07, 2013 at 08:18 UTC |