Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by Anonymous Monk
on Jul 01, 2011 at 10:02 UTC ( #912318=note: print w/replies, xml ) Need Help??


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

Congratulations, you're getting closer :)

Your if logic is clear now, and correct, you're almost finished

But, your code once again does not compile, and has not been tidied, and you're still not push-ing onto the array

You attempt to compensate by using an index, but you're using it on the wrong variable

strict tells you about this
Global symbol "@lin" requires explicit package name
Global symbol "@arr" requires explicit package name

There is no @lin array, and @arr does not exist outside of the if block, where you assign to it, instead of pushing

You need to increase the scope of @arr, by declaring it outside the while loop, the same as you did $fg

You need to push $lin onto @arr

Unsure of what i'm talking about? You should read the basic datatypes, three, Arrays: A Tutorial/Reference, Lexical scoping like a fox

Replies are listed 'Best First'.
Re^6: to copy certain content in file & repeat it .
by harshmane (Initiate) on Jul 01, 2011 at 10:55 UTC
    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.

      i am not using push because my file is very huge around 400 lines so i dont want to run out of mem

      If you're concerned about memory, why did you chose the approach of building an array?

      If you want your program to work , given the approach you've chosen, you have to put data in the array, otherwise there is no data to print later (at which point you can empty the array).

      and also i am not using any module ..

      How is that relevant?

      so if you can write the certain part where i am making mistake

      No thanks. I explained in sufficient detail how you should make the changes. If I make the changes for you, you learn nothing. I'm attempting to teach you to fish (Give a fish or teach to fish?), if you're willing.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://912318]
help
Chatterbox?
[Corion]: I'm looking into Firefox Accounts (to self-host bookmark synchronization, among other things) and the one thing I like about their documentation is that they include test vectors for ...
[Corion]: ... their hashes. Even though their backends claim to be open, they don't really seem to be geared towards self-hosting them, so I'm pondering writing a (simplicistic) Perl backend for my needs

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2017-11-18 17:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (277 votes). Check out past polls.

    Notices?