http://qs1969.pair.com?node_id=35541


in reply to Evolution of an Obfuscated Throwaway Script

Okay, so this is really NOT obfuscated, but it is a one liner!
# 1st shot df -h | perl -e '@i = <>;s/(\ +)/\,/g && print for @i[1..@i];' > the.c +sv # 2nd shot df -h | perl -e '/^\w/&&next||s/\ +/\,/g&print for<>' > the.csv
I kinda like the look, but merlyn has already pointed out that s/// for is bad. :)

#!/home/bbq/bin/perl
# Trust no1!

Replies are listed 'Best First'.
RE: (bbq) RE: Evolution of an Obfuscated Throwaway Script
by DrManhattan (Chaplain) on Oct 14, 2000 at 01:58 UTC
    df -h | perl -lpe 's/\s+/,/g' > the.csv
    FORE!

    Sorry, I know it's supposed to be obfuscated, but I can't resist the urge to golf. :)

    -Matt

      I would definitly stand up and clap if it weren't for one small detail. The first line in this case would read:
      Filesystem,Size,Used,Avail,Use%,Mounted,on

      Yeah, I know... I'm being a picky sore looser! :)

      #!/home/bbq/bin/perl
      # Trust no1!
RE: (bbq) RE: Evolution of an Obfuscated Throwaway Script
by mischief (Hermit) on Oct 16, 2000 at 13:39 UTC
    where did merlyn point out that the s/// for is bad? why is this?
      Yeah, just where did I point out that that was bad?

      And remember, I have different rules for Obfuscated vs. Golf vs. Bowling vs. 10-minute hacks vs. actual code that a customer paid for vs. training materials. Don't paint me with a broad sword there, or something like that.

      -- Randal L. Schwartz, Perl hacker