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.
|