Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: to copy certain content in file & repeat it .

by Anonymous Monk
on Jun 30, 2011 at 10:39 UTC ( #912144=note: print w/ replies, xml ) Need Help??


in reply to Re^2: to copy certain content in file & repeat it .
in thread to copy certain content in file & repeat it .

Hi, the code you posted does not compile, part of asking a question effectively, is to make sure your code compiles before posting.

 

while(<FH>){ ...

This reads from a file until it reaches the end. Filehandles are iterators. Once you reach the end, the subsequent while(<FH>) loop will not be entered

 

@arr =$_;

This sets @arr to the value of $_; It doesn't add values to @arr, for that you need the push function


Comment on Re^3: to copy certain content in file & repeat it .
Select or Download Code
Re^4: to copy certain content in file & repeat it .
by harshmane (Initiate) on Jul 01, 2011 at 09:27 UTC
    i m rewriting the current code here i m printing the give n part but i want it in between.
    use warnings; use strict; my $fg=0; my $i=0; open(FF ,"lib"); open (FF1,>lib1"); while(<FF>) { my $lin =$_; print FF1 $lin; if ($lin=~m/pattern to be patched for stat copying/) { $fg=1; } if ($fg) { $lin=$_; my @arr =$lin[$i]; $i++; } if($lin=~m/pattern where to stop copying & repeating/) { $fg=0; } } if ($fg==0) { for (my $j=0;$j<$i;$j++) { print FF1 @arr[$j]; } }
    i want to actuaaly print the given para in between here using these script i am print @ end of file.
        i am not using push because my file is very huge around 400 lines so i dont want to run out of mem and also i am not using any module .. so if you can write the certain part where i am making mistake.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (15)
As of 2014-12-17 21:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (34 votes), past polls