in reply to famous one liners

I'm afraid this doesn't appear to work on anything with comments... For example, try running it on this script:

print "Foo.\n"; $foo='bar'; # This is a comment print "No, $foo.\n"; # Another comment.

...and it will go something like this:

C:\test\scratch>copy con obs.pl #!/usr/local/bin/perl $input = $ARGV[0]; open(thefile,"$input"); @file = <thefile>; close thefile; open(newfile,">$input"); $counter = 0; foreach $line(@file) { $counter++; if ($counter != 1) { $line =~ s/\s+$//; $line =~ s/^\s+//; } print newfile "$line"; } close newfile; ^Z 1 file(s) copied. C:\test\scratch>copy con test2.pl print "Foo.\n"; $foo='bar'; # This is a comment print "No, $foo.\n"; # Another comment. ^Z 1 file(s) copied. C:\test\scratch>test2.pl Foo. No, bar. C:\test\scratch>obs test2.pl C:\test\scratch>type test2.pl print "Foo.\n"; $foo='bar'; # This is a commentprint "No, $foo.\n"; # Another comment. C:\test\scratch>test2.pl Foo.

Replies are listed 'Best First'.
RE: RE: famous one liners
by Octavian (Monk) on Oct 30, 2000 at 20:06 UTC
    oh yeah, never tested that, I dont use comments, bad habit, I know, but it makes it harder for me to read perl code if comments are in there.