Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: simple Perl script template

by marinersk (Priest)
on Apr 09, 2015 at 12:14 UTC ( [id://1122921]=note: print w/replies, xml ) Need Help??


in reply to Re: simple Perl script template
in thread simple Perl script template

That's an interesting design choice. Why do you want to punish the remaining files (die) just because one of them turns out to be unopenable?

Replies are listed 'Best First'.
Re^3: simple Perl script template
by Dumu (Monk) on Apr 09, 2015 at 12:49 UTC
    I like the idea of just warning, in case only one of the files can't be written.
      Hi Dumu, marinersk,

      In case of using 'warn' 'next' should be added to suppress unnecessary error messages (I suppose strictures are on) eg.:

      unless (open my $fh, '>', $fname) { warn "Cannot open $fname - $!\n"; next; }
      In case of error we have to rerun the script after fixing the reason. In this sense there is no difference between 'die' and 'warn' version. But 'die' version is smaller -> "small is beautiful"

        Ah, I see where you are coming from.

        In my world, the error would more likely be in the form of having one of the filenames be impossible to use (such as having a colon or a subdirectory that doesn't exist, that sort of thing) but to be of the most service to me personally, the remaining files on the command line should still get created. The only correction then is to run again with just the one corrected filename.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1122921]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 09:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found