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

Re^4: How can you sysread an entire file?

by BrowserUk (Pope)
on Jan 13, 2006 at 23:15 UTC ( #523109=note: print w/ replies, xml ) Need Help??


in reply to Re^3: How can you sysread an entire file?
in thread How can you sysread an entire file?

I think I made an interesting discovery. As you suggest above, if I do this it only makes one copy of the file in memory:

P:\test>perl -le" my $s; do{ local $/; $s=<>}; print length $s; system qq[tasklist /fi \"pid eq $$\" ]" 1000000.dat 11000001 Image Name PID Session Name Session# Mem Usag +e ========================= ====== ================ ======== =========== += perl.exe 604 0 12,860 +K

And if I do it this way it uses two copies:

P:\test>perl -le" my $s=do{ local $/; <>}; print length $s; system qq[tasklist /fi \"pid eq $$\" ]" 1000000.dat 11000001 Image Name PID Session Name Session# Mem Usag +e ========================= ====== ================ ======== =========== += perl.exe 1372 0 23,624 +K

But what fooled me, as I was using my perl shell, is that if you eval the statement, only one copy is made:

P:\test>perl -le" my $s = eval q[do{ local $/; <>}]; print length $s; system qq[tasklist /fi \"pid eq $$\" ]" 1000000.dat 11000001 Image Name PID Session Name Session# Mem Usag +e ========================= ====== ================ ======== =========== += perl.exe 1764 0 12,880 +K

And I can't quite figure out why that should be so?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^4: How can you sysread an entire file?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-10-01 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (6 votes), past polls