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*
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|