in reply to [SOLVED] copying a file with .bak extension
From How can I use Perl's i option from within a program? the -i option changes $^I which in turn changes how <> works. That means the magic only works inside a while loop that uses <>. Your code with -i added on for me made a .bak copy but cleared the original and printed to the command line. The following code does what you requested.
#!/perl -i.bak while(<>) { print; if(eof) { print "\n"; print "##Copyright (C) 2012 by firstName lastName\n" ; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: copying a file with .bak extension
by Anonymous Monk on Nov 07, 2012 at 19:20 UTC | |
by Lotus1 (Vicar) on Nov 07, 2012 at 19:46 UTC |
In Section
Seekers of Perl Wisdom