Re: $_ in condition

jason_at_cyberpine.com
Date: 08/12/04


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.



Relevant Pages

  • Re: $_ in condition
    ... > chomp; # this should fix the problem ... This did not appear to fix the issue, ... $ perl m2.pl 'test2' ... $ perl m2.pl 'test3' ...
    (comp.lang.perl)
  • [GIT PULL] block changes for 2.6.28
    ... This is the bulk of the block layer changes for 2.6.28. ... Fix up comments about matching flags between bio and rq ... Add 'discard' request handling ... Support 'discard sectors' operation in translation layer support core ...
    (Linux-Kernel)
  • [GIT PULL] first block round for 2.6.31
    ... cciss: use schedule_timeout_interruptible ... mg_disk: fix dependency on libata ... Add blk_make_request(), takes bio, returns a request ... swim3: dequeue in-flight request ...
    (Linux-Kernel)
  • Re: [PATCH 2.6.15-rc6] block: Make CDROMEJECT more robust
    ... it can't be a write request if there's no data attached. ... >> The bug was in the SCSI layer, and James already has the fix integrated ... >> Do this in the eject tool, if it's required for some devices. ... So the medium removal command does require write permission on the ...
    (Linux-Kernel)
  • Re: Notices
    ... An unchecked checkbox is not sent in $_REQUEST and if you do something with $_REQUESTyou'll get a notice. ... I'm a recovering perl programmer so conciseness is still important. ... It's a bit tedious at times to fix harmless missing index notices when you just want to test something. ...
    (comp.lang.php)