Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^2: unwanted ARGV in subroutine

by runrig (Abbot)
on Oct 29, 2012 at 22:19 UTC ( #1001430=note: print w/replies, xml ) Need Help??

in reply to Re: unwanted ARGV in subroutine
in thread unwanted ARGV in subroutine

And if the file is huge, the OP shouldn't be loading it into memory, and should write to a temp file, and then rename it at the end.

Replies are listed 'Best First'.
Re^3: unwanted ARGV in subroutine
by perl_walker (Novice) on Oct 30, 2012 at 07:06 UTC

    Hi rizzler

    Try this

    sub addheader{ my($infile,$header)=@_; open(FILE, "$infile"); my $text=do {local $/; <FILE>}; close FILE; open(FILE,">$infile"); print FILE $header; print FILE $text; close FILE; }
      Please don't try that :) it doesn't use error checking ... If you want to copy a file use File::Copy, for moving File::Move

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001430]
[Happy-the-monk]: Discipulus: si!
[Eily]: Discipulus 2018 has to be better than 2017. The latter was kinda odd, but not we got even :D
[Corion]: Eily++ # basic number theory

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2018-01-23 08:54 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (242 votes). Check out past polls.