Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by BrowserUk (Patriarch)
on Jan 13, 2006 at 23:15 UTC ( [id://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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-26 05:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found