Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Cannot work on second file after reading first file.

by sn1987a (Chaplain)
on Feb 28, 2014 at 18:45 UTC ( #1076594=note: print w/replies, xml ) Need Help??

in reply to Cannot work on second file after reading first file.

The immediate problem is the undef $/; in open_po. Replace it with local ($/);

A couple notes on my process for debugging this:

First, I used Data::Dumper to dump the result of call $csv->getline_all to see the entire parse being returned. This verified the only thing being returned was the header row.

Then I commented out the call to open_po and saw that the file was not being parsed correctly. This meant the problem was some state being globally modifed in open_po.

Study of that sub lead to the problem

Replies are listed 'Best First'.
Re^2: Cannot work on second file after reading first file.
by 1straw (Novice) on Feb 28, 2014 at 19:06 UTC

    Thank you sn1987a! This solved the problem.

    I will learn to use Data::Dumper & read the debugger tutorial suggested as well.


    1) A subroutine to open and read a CSV file worked fine in isolation but stopped working when integrated into larger script.

    2) The problem stemmed from an earlier subroutine (open_po) which globally modified the input record separator ($/) through: undef $/;

    3) The problem code was modified to change the state locally, according to sn1987a's post to: local ($/);

    4) This modification solved the problem.

    Thank you all for your help!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2019-04-21 06:22 GMT
Find Nodes?
    Voting Booth?
    I am most likely to install a new module from CPAN if:

    Results (110 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!