Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Re: substitution in $0

by Discipulus (Canon)
on Oct 03, 2002 at 12:00 UTC ( [id://202483]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: substitution in $0
in thread substitution in $0

Thanks to all you monks for the precious suggestions you gave to me!
I know my code is still terrible!!
#!perl use strict; use warnings; &changemyself(); sub changemyself{ my $new_value = 10; my $data=6666666666666; #next time this value will be 10 open (COPIA, ">copia"); open (PROG, "+>>$0"); seek (PROG, 0, 0); #I don't know why but it's NECESSARY! while (<PROG>) { s/^( my .data\s*=\s*)\d+(\s*;)/$1.$new_value.$2/e; print COPIA; } close (PROG); # close (COPIA); # # the terrible imitation # of the open (COPIA, "<copia"); # three cards game open (PROG, ">$0"); # while (<COPIA>){print PROG}# close (PROG); # close (COPIA); # unlink ("copia"); # }
Special thank to Helter!
greetings from roma, lor*
PS I never noticed the +>> operator!!! l*

Replies are listed 'Best First'.
Re: Re: Re: Re: substitution in $0
by fglock (Vicar) on Oct 03, 2002 at 12:23 UTC
    open (PROG, "+>>$0"); seek (PROG, 0, 0); #I don't know why but it's NECESSARY!

    Because  >> moves the file position to end-of-file.

Log In?
Username:
Password:

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

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

    No recent polls found