in reply to Re^2: Elegant Way of Inserting Text at the Start of the File
in thread Elegant Way of Inserting Text at the Start of the File
#!/usr/bin/perl use warnings; use strict; my $string="Hello"; { local @ARGV = ("$ARGV[0]"); local $^I = '.bac'; while(<>){ if ($. == 1) { # if line no is 1 print "$string$/"; print; # Also print the current line } else { print; } } }
|
|---|