Tuesday, March 07, 2006

Reset $. at EOF

When using perl $. variables, you may need to reset $. for each new file.

for example to add #!/usr/bin/perl to each .pl in the current dir do

perl -i -lpe 'print "#!/usr/bin/perl\n" if $. ==1 ; close ARGV if eof' *.pl

No comments: