develooper Front page | perl.beginners | Postings from May 2007

File Handling. Reading and Writting.

Thread Next
From:
Bruno Schroeder
Date:
May 14, 2007 17:33
Subject:
File Handling. Reading and Writting.
Message ID:
20070514220358.10089.qmail@lists.develooper.com
Hello All.

    I am trying to read and write in a file, I am using something like:

open (FILE, "+<teste_rw.txt") or die "I couldn't open the file.";
for my $line (<FILE>) {
 print $line;
 if($line eq "X\n")
 {
        print FILE "b\n"
 } else
 {
        print FILE "c\n"
 }
}
print FILE "Y\n";
close FILE;

In the attached file, I whant to write inside the $modify_class, 
$modify_method and $modify_parameter tests.

   Thnak you.
Bruno


begin 666 checkTracev10.pl
M=7-E('-T<FEC=#L-"@T*(V-H96-K5')A8V4N<&P-"B-,:7-T(')E8W5R<VEV
M96QY(&EN(&5V97)Y('-U8F9O;&1E<B!O9B!A(&EN:71I86P@9&ER96-T;W)Y
M+"!A;&P@=')A8V4M:6X@#0HC86YD('1R86-E+6]U="!E>'!R97-S:6]N<R!T
M:&%T(&%R92!N;W0@86-C;W)D:6YG('1O('1H92!M971H;V0G<R!N86UE+@T*
M#0HC1VQA8F%L(%9A<FEA8FQE<SH-"FUY("1F:6QE7V-O=6YT(#T@,#L-"FUY
M("1P86-K86=E(#T@(CQP86-K86=E/B([#0IM>2 D8VQA<W,@/2 B/&-L87-S
M/B([#0IM>2 D;65T:&]D(#T@(CQM971H;V0^(CL-"FUY($!P87)A;65T97)S
M(#T@(B([#0IM>2 D8VQA<W-?;6ES=&%K95]C;W5N=" ](# [#0IM>2 D;65T
M:&]D7VUI<W1A:V5?8V]U;G0@/2 P.PT*;7D@)'!A<F%M971E<E]M:7-T86ME
M7V-O=6YT(#T@,#L-"FUY("1V97)I9GE?8VQA<W,@/2 B=')U92([#0IM>2 D
M=F5R:69Y7VUE=&AO9" ](")T<G5E(CL-"FUY("1V97)I9GE?<&%R86UE=&5R
M(#T@(G1R=64B.PT*;7D@)&UO9&EF>5]C;&%S<R ](")T<G5E(CL-"FUY("1M
M;V1I9GE?;65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T*"0EC;&]S92AF:6QE*3L-
&"@E]#0I]
`
end


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About