Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

(tye)Re: Filehandles and Arrays

by tye (Cardinal)
on May 08, 2001 at 07:09 UTC ( #78754=note: print w/ replies, xml ) Need Help??


in reply to Re: (ar0n) Re: Filehandles and Arrays
in thread Filehandles and Arrays

Well, I'm not who you asked for so feel free to ignore me. I've said it before and it works for me: my @lines= do { local *ARGV; @ARGV= $name; <> };
I have tested it while in the middle of using <> to read from files given on the command line and it read the lines from the named file and then the next <> resumed right where it had left off.

Perhaps you could post some code that demonstrates how it fails (as I was never completely sure that it was foolproof).

        - tye (but my friends call me "Tye")


Comment on (tye)Re: Filehandles and Arrays
Select or Download Code
(tye)Re2: Filehandles and Arrays
by tye (Cardinal) on May 08, 2001 at 19:07 UTC

    ChemBoy mentioned that this didn't work for him so I tested with Perl 5.004_01 and got an empty array and no error message (though subsequent <>s resumed where they had left off). ChemBoy seems to get different results from either of my tests.

    So perhaps this overly-cute hack works for 5.6 but fails in different ways for earlier versions. More data is required before I'd draw any firm conclusions, but at least isn't just my word against ChemBoy's now.

            - tye (but my friends call me "Tye")
Re: (tye)Re: Filehandles and Arrays
by ChemBoy (Priest) on May 08, 2001 at 19:21 UTC

    I kicked all of these around some, and I'm still confused. Possibly this is a local issue to me, possibly not. In summary, I got ar0n's technique to work when no file was being read from the command line (in the debugger, at least), but not the modification suggested by merlyn and tye (who I would not dream of ignoring), and neither when a file was being read. But tye says it works for him, and tye is an honorable man...

    So, below are what I did and what happened, and if I'm making a stupid mistake I'll be very happy to find out what it is. I'm only including the results trying to read from two files at once, because it's long enough already, and the other ones don't add anything much.

    For reference, This is perl, version 5.004_04 built for IP27-irix

    Pseudo-update: and it appears that it is indeed relevant. Oh, why can't they install 5.6 here?Oh well, at least I'm not confused any more. :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2014-09-21 21:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls