Re: $_ in condition
jason_at_cyberpine.com
Date: 08/12/04
- Next message: Joe Smith: "Re: $_ in condition"
- Previous message: jason_at_cyberpine.com: "Re: $_ in condition"
- In reply to: Gunnar Hjalmarsson: "Re: $_ in condition"
- Next in thread: Joe Smith: "Re: $_ in condition"
- Reply: Joe Smith: "Re: $_ in condition"
- Reply: Jim Gibson: "Re: $_ in condition"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 12 Aug 2004 11:12:21 -0700
> chomp; # this should fix the problem
Did not appear to fix the problem. And pardon the repost, but to add
further to my confusion on while loops, I made a few changes to the
this little program and added displays. Why doesnt my condition trip
and/or stay set for $p in the below code. Here are the three test
attempts. Also, note how $p displays on top of the first display
until the the last record - why is that????
$ perl m2.pl test2
p=xuest====test2 current====test1
p=xuest====test2 current====test2
request====test2 current====test3 p=x
$ perl m2.pl test3
p=xuest====test3 current====test1
p=xuest====test3 current====test2
request====test3 current====test3 p=y
Passed!
$ perl m2.pl test2
p=xuest====test2 current====test1
p=xuest====test2 current====test2
request====test2 current====test3 p=x
$
#!/usr/bin/perl -w
use strict;
my $request = shift @ARGV;
my $p='x';
while(<DATA>)
{
chomp;
if ($request =~ $_){$p='y';}
print "\n";
print ' request====';
print $request;
print ' current====';
print $_;
print ' p=';
print $p;
print "\n";
}
if ($p =~ 'y') {print "\n Passed! \n";}
__DATA__
test1
test2
test3
Thanks for any help or information.
- Next message: Joe Smith: "Re: $_ in condition"
- Previous message: jason_at_cyberpine.com: "Re: $_ in condition"
- In reply to: Gunnar Hjalmarsson: "Re: $_ in condition"
- Next in thread: Joe Smith: "Re: $_ in condition"
- Reply: Joe Smith: "Re: $_ in condition"
- Reply: Jim Gibson: "Re: $_ in condition"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|