Hello! I wrote something recently, and then had to go through it and actually seperate things into a few lines to get it to work (not that I did it right the first time...) It's a simple code to make a list of files dropping out the first few levels of file paths. The code in question is here:
use File::Find; open (OUT, ">filelist.txt"); find( sub { $temp = $File::Find::name; $temp =~ s/C:\/users\/User\/Music\/(.*)/$1/gi; print OUT "$temp\n"; }, "C:/users/User/Music/"); close OUT;
If you can't tell just by looking at it that I'm running Windows, you probably can't help me here :~)

It's Strawberry Perl 5.8

I recall reading once that someone wrote a web spider in one line...I'm not really good at one liners. Is there a way to squish
$temp = $File::Find::name; $temp =~ s/C:\/users\/User\/Music\/(.*)/$1/gi; print OUT "$temp\n";
into two or even one lines? And does anyone know a good place to start looking for something like a brevity tutorial? I recently watched a podcast where the speaker said, "If statements are obsolete if you know how to use the space-ship operator!" I'm not so much looking to obfuscate, but I'd like to save a few keystrokes.

Thanks and Cheers!
~Petras

Ready.
poke 53280,0
poke 53281,0
ctrl+2 load "zork",8,1

West of House

In reply to How to make code smaller--saving steps and writing one liners by Petras

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.