Re: $_ in condition
jason_at_cyberpine.com
Date: 08/12/04
- Next message: jason_at_cyberpine.com: "Re: $_ in condition"
- Previous message: A. Sinan Unur: "Re: Perl - Parse UNC Path in a string variable"
- In reply to: Gunnar Hjalmarsson: "Re: $_ in condition"
- Next in thread: Joe Smith: "Re: $_ in condition"
- Reply: Joe Smith: "Re: $_ in condition"
- Reply: Gunnar Hjalmarsson: "Re: $_ in condition"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 12 Aug 2004 10:43:02 -0700
> chomp; # this should fix the problem
This did not appear to fix the issue, and actually the code only
appears to "pass" when I send it the last entry in the data.
$ perl m2.pl 'test2'
test2
Failed!
$ perl m2.pl 'test3'
test3
Passed!
The code I'm testing with:
#!/usr/bin/perl -w
use strict;
my $request = shift @ARGV;
print $request;
my $p='n';
while(<DATA>) {
chomp;
if ($request =~ $_)
{
$p='y';
}
}
if ($p =~ 'y')
{
print "\n Passed! \n";
}
else
{
print "\n Failed! \n";
}
__DATA__
test1
test2
test3
Thanks for any help or information.
- Next message: jason_at_cyberpine.com: "Re: $_ in condition"
- Previous message: A. Sinan Unur: "Re: Perl - Parse UNC Path in a string variable"
- In reply to: Gunnar Hjalmarsson: "Re: $_ in condition"
- Next in thread: Joe Smith: "Re: $_ in condition"
- Reply: Joe Smith: "Re: $_ in condition"
- Reply: Gunnar Hjalmarsson: "Re: $_ in condition"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|