मैं निम्नलिखित चेतावनी मिलती है:अजीब बात
"सेल्सियस पर संयोजन या स्ट्रिंग में अप्रारंभीकृत मूल्य का उपयोग (।): \ उपकरण \ test.pl लाइन 17, डेटा लाइन 1."
लेकिन __DATA__
की अगली पंक्ति बिना किसी चेतावनी के कार्रवाई की जाएगी और इन मिलती है:
test1b.txt: परीक्षण test1c.txt: परीक्षण: परीक्षण
अधिक अजीब बात है कि जब मैं एक पंक्ति जोड़ें: print "$line:".$'."\n";
चेतावनी गायब हो गया।
किसी कुछ सुराग है?
#!/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 following line pass without no warning.
my $result="$line:".eval($output)."\n";
print $result;
}
__DATA__
test1a.txt
test1b.txt
test1c.txt
अच्छा बिंदु! मैं rarelly 'eval' का उपयोग करें। कुछ लिंक इस तरह के http://stackoverflow.com/questions/10909127/perl-why-doesnt-eval-set-1, के रूप में इसके उपयोग के बारे में अधिक धारणा, दे। – user2462304