Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Most effective bash to perl for directory listing

by ZWcarp (Beadle)
on Jul 18, 2012 at 18:29 UTC ( #982515=note: print w/ replies, xml ) Need Help??


in reply to Re: Most effective bash to perl for directory listing
in thread Most effective bash to perl for directory listing

Wow that is awesome...Sorry.. I removed a lot of stuff from the scripts to make it simpler for the post, in mine it uses the current directory. Is there a way to get glob to output just the directory names but not their entire paths (without just regexing it)---> This is the current output of what you posted

../results//jobs ../results//logs ../results//step0_tophat ../results//step1_2cuffcompare ../results//step1_cufflinks ../results//step2_cuffmerge ../results//step3_cuffdiff ../results//step4_createTranscriptome ../results//step6_bowtie_pe ../results//step7_bowtie_se ../results//step8_bowtie_hg19 ../results//step9_tophat_unmapped_hg19
This is what I was looking for, if it is possible:
jobs logs step0_tophat step1_2cuffcompare step1_cufflinks step2_cuffmerge step3_cuffdiff step4_createTranscriptome step6_bowtie_pe step7_bowtie_se step8_bowtie_hg19 step9_tophat_unmapped_hg19
Thanks so much for your time!

On a side note, I really want to learn more shorthand tricks like this, but they are really hard to find without asking a direct question... are you aware of any resources that instruct specifically on useful shorthand alternatives .. for example the difference between my script and your response.


Comment on Re^2: Most effective bash to perl for directory listing
Select or Download Code
Re^3: Most effective bash to perl for directory listing
by BrowserUk (Pope) on Jul 18, 2012 at 19:07 UTC
    Is there a way to get glob to output just the directory names but not their entire paths (without just regexing it)

    No. But regexing it isn't hard:

    perl -E"say for map{ s[$ARGV[0]/][]; $_} glob qq[$ARGV[0]/*]"
    are you aware of any resources that instruct specifically on useful shorthand alternatives

    Erm. There was a thread a few years called something like Cheap idioms that had some.

    Typing "idioms" into the search box top left brings up some similar threads.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Re^3: Most effective bash to perl for directory listing
by aaron_baugher (Deacon) on Jul 18, 2012 at 22:00 UTC
    Is there a way to get glob to output just the directory names but not their entire paths?

    Yes. glob returns pathnames matching the pattern you give it. So if you give it ../results/*, it'll return the filenames in that directory in that format beginning with ../results/, just like the shell command find will do. So if you don't want the rest of the path, chdir into the directory first and then use glob just on the filenames:

    chdir $ARGV[0] or die $!; print "$_\n" for glob '*';

    Aaron B.
    Available for small or large Perl jobs; see my home node.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://982515]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2014-07-30 22:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (241 votes), past polls