Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: __DATA__ read/write as configuration file

by broquaint (Abbot)
on Jul 17, 2003 at 23:47 UTC ( #275451=note: print w/replies, xml ) Need Help??


in reply to __DATA__ read/write as configuration file

How do I do this? read __DATA__ then seek to 0 then write over it?
Yes, just open up the current script and write to it like you would any other file e.g
use Fatal qw/ open seek /; open(my $d => '+<', $0); seek $d => 0, 2; print $d @ARGV; __DATA__ foo bar
This will append @ARGV to the __DATA__ section of the currently executing script. Of course modify the seek as you see fit and if you're going to completely overwrite it then remember it's position with a quick tell.
HTH

_________
broquaint

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://275451]
help
Chatterbox?
[marto]: believe in derp coin
[Corion]: Oh - I see ...
[LanX]: like http://cb60. datenzoo.de/:// perlmonks.org/ index.pl?node_id= 1215217
[Discipulus]: username links i bet
[Corion]: (also, let me recommend https://mini-cb60. datenzoo.de/ over that, as it has https :)
[LanX]: all links
[Corion]: I guess I should make the certificate valid for both hostnames
[LanX]: and broken links ;p
Corion wonders about how/where mini-cb60 (re)writes the links ...
[Discipulus]: base_url ?

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2018-05-25 15:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?