Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Why is file being slurped in instead of line by line?

by ahmad (Hermit)
on Aug 26, 2006 at 16:35 UTC ( #569814=note: print w/replies, xml ) Need Help??


in reply to Why is file being slurped in instead of line by line?

Hello ,

To make your code works fine ,

1. remove "undef $/;" line ... which makes the whloe data as one line ( removes line sperator )

2. remove "my @data;" from the top ... and declare it inside the loop ... which means ... it re-assigned a new data for each loop like

my @data = split (/\t/, $line);

HTH

  • Comment on Re: Why is file being slurped in instead of line by line?

Replies are listed 'Best First'.
Re^2: Why is file being slurped in instead of line by line?
by zshzn (Hermit) on Aug 26, 2006 at 21:46 UTC
    Point #2 is not necessary to his issue, nor will it actually fix a problem in his code execution. That already "works fine", if not optimally.

      ahmad's point is however a good one. It is generally good practice to limit the scope of variables as far as is reasonable. It reduces the chance that a variable will be inadvertantly modified and the purpose of the variable is generally clearer.


      DWIM is Perl's answer to Gödel
        I agree. However, he explained it as "To make your code works fine", and my issue was that the relevence could be misunderstood, being that the second point isn't going to make the code work any finer than it already did, or at least not in the way that the first point does. If that makes sense, that is.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-09-30 05:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (125 votes). Check out past polls.

    Notices?