Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: print or die

by lhoward (Vicar)
on Jul 02, 2001 at 23:14 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://93287]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-25 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found