Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^5: Assistance fixing a "format" call

by Marshall (Canon)
on Apr 04, 2012 at 03:47 UTC ( [id://963357]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Assistance fixing a "format" call
in thread Assistance fixing a "format" call

There can be only one __DATA__ segment, however there is another way! Use a heredoc and assign that to a variable, then you can open that variable for reading just like a file! WoW! This is way cool. Note the reference (\$data2) in the open statement.
#!/usr/bin/perl -w use strict; my $data2 =<<END; This is an example of another way to do this than the DATA segment END open DATA2, '<', \$data2 or die $!; while (<DATA2>) { print; } __END__ Prints: This is an example of another way to do this than the DATA segment
Note that it is also possible to open a variable for writing! This is handy sometimes to avoid making a temporary file that you have to delete.

Log In?
Username:
Password:

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

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

    No recent polls found