Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

famous one liners

by Octavian (Monk)
on Oct 28, 2000 at 00:19 UTC ( [id://38874]=obfuscated: print w/replies, xml ) Need Help??

I am a new member of this glorious place, and thing seem a bit foggy for me still, but it appears that you are all discussing different ways to make your perl scripts harder to read? Well, I have a simple program that works just fine for me, this is my rmreturn script:
#!/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;

Replies are listed 'Best First'.
RE: famous one liners
by myocom (Deacon) on Oct 28, 2000 at 02:20 UTC

    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.
      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.
Re: famous one liners
by TomDLux (Vicar) on Dec 07, 2005 at 16:36 UTC

    I love the way you print to a file named input.

    --
    TTTATCGGTCGTTATATAGATGTTTGCA

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://38874]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found