Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: print or die

by lhoward (Vicar)
on Jul 02, 2001 at 23:14 UTC ( #93287=note: print w/replies, xml ) Need Help??


in reply to print or die

When dealing w/ a heredoc string you put your "or die" w/ the original print statment:
print FILE <<UNTIL_I_SAY_STOP or die "ERROR Writing to FILE: $!"; blah, blah, blah UNTIL_I_SAY_STOP
It works similarly whenever you want to do something else after the heredoc...
my $sub=substr(<<EOT,3,3); abc123def EOT print "sub=\"$sub\"\n";
prints out 123.

You can even get fancy (or hard to read depending on your preference) and use multiple heredocs in the same call:

print <<EOT1,<<EOT2; foo EOT1 bar EOT2

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2019-08-25 00:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?