----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 06, 2002 6:07 AM
Subject: nonzero $! value after closing a pipe normally

>Hi all,
>
>I have a code part like the following.
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>open MYPROFILE, "cat mytxtfile |";

Why not say:
  open MYPROFILE, "cat mytextfile |" or pr_my_error_routine “close error in MYPROFILE 
with $!\n”;

Then have the die or exit in the pr_my_error_routine...

or

  my $status=open MYPROFILE, "cat mytxtfile |";
  unless($status) {
    pr_my_error_routine “close error in MYPROFILE with $!\n”;
  }

  You can't rely on $! not to be holding an 'error' already that you haven't checked 
for...or, so
has been my experience.

Shawn

>if ( $! != 0 ) {
>  print "h1 -> $!\n";
>}
>while (<MYPROFILE>) {
>next if /^(tcp|udp)/;
>print;
>}
>close MYPROFILE or die "bad: $! $?";
>
>if ( $! != 0 ) {
>  pr_my_error_routine “close error in MYPROFILE with $!\n”;
>}
><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
>As a beginner user, I try to use my error routine instead of die method
>after a simple check
>of last command exit code.
>
>Here if I use a text file
>     open MYPROFILE, "mytxtfile "
>instead of a pipe it works. My problem is non-zero value after close of a
>pipe. die works (I mean it doesn’t die as expected), but I can’t use if ( $!
>!= 0 )  … instead of die.
>
>TIA,
>
>OKI


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to