Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re:{2} Unix 'grep -v' equivalency in Perl (was: Perl Regex Question)

by jeroenes (Priest)
on Jul 10, 2001 at 15:28 UTC ( #95272=note: print w/replies, xml ) Need Help??


in reply to Re: Unix 'grep -v' equivalency in Perl (was: Perl Regex Question)
in thread Unix 'grep -v' equivalency in Perl (was: Perl Regex Question)

Yet another brief addition: the message $! tells you the cause of the addition, but not the source. Zaxo already told you that leaving that newline out makes die tell the terminal which line of code generated that error.

However, that's not immediately informative. The command probably interpretets a variable to generate the syscall, so in general it's a good idea to provide that information :

open( INPUT, $filename ) or die "Could not open $filename: $!"; # or rename( $old, $new ) or die "Could not rename $old to $new: $!";

As a third step, you can use Carp to print out the chain of callers. This is useful when your code is distributed over more than one file.

  • Comment on Re:{2} Unix 'grep -v' equivalency in Perl (was: Perl Regex Question)
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://95272]
help
Chatterbox?
[LanX]: ]t
[LanX]: am I the only one who first thinks scifi when a post starts with "Solaris"?

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2017-03-23 19:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (294 votes). Check out past polls.