J
jason
Pardon the perl noobie post, this one is silly one I'm sure, but
nonetheless, I'm stuck on it. why doesn't $_ substitute with the data
when the program is passed the string as such. The eventual objective
of the program being to test the string against a list of regexes.
perl test.pl 'xxxxxxxxxxx test1 xxxxxxxxxxxxxxx'
note commented line works!
Along the same lines, how could I pass regex lines in that same data
to condition that a string fed to the program does in fact match.
Many thanks.
#!/usr/bin/perl -w
use strict;
my $request = shift @ARGV;
print $request;
my $p='n';
while(<DATA>) {
print $_;
if ($request =~ $_)
# if ($request =~ 'test1')
{
$p='y';
}
}
if ($p =~ 'y')
{
print "\n Passed! \n";
}
else
{
print "\n Failed! \n";
}
__DATA__
test1
test2
test3
nonetheless, I'm stuck on it. why doesn't $_ substitute with the data
when the program is passed the string as such. The eventual objective
of the program being to test the string against a list of regexes.
perl test.pl 'xxxxxxxxxxx test1 xxxxxxxxxxxxxxx'
note commented line works!
Along the same lines, how could I pass regex lines in that same data
to condition that a string fed to the program does in fact match.
Many thanks.
#!/usr/bin/perl -w
use strict;
my $request = shift @ARGV;
print $request;
my $p='n';
while(<DATA>) {
print $_;
if ($request =~ $_)
# if ($request =~ 'test1')
{
$p='y';
}
}
if ($p =~ 'y')
{
print "\n Passed! \n";
}
else
{
print "\n Failed! \n";
}
__DATA__
test1
test2
test3