Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Variable numbers of folders...

by LazerRed (Pilgrim)
on Jul 25, 2003 at 18:39 UTC ( #277935=note: print w/ replies, xml ) Need Help??


in reply to Variable numbers of folders...

Something like:

opendir(DIR, $directory) or die "Failed to open $directory: $!"; while (defined($filename = readdir(DIR))) { #Do stuff to each file $filename } closedir(DIR);
You could easily wrap in a foreach block if you have multiple directories specified.

LR

Whip me, Beat me, Make me use Y-ModemG.

Update: Also, I might add, Learning Perl and Perl Cookbook are invaluable resources to have on hand.


Comment on Re: Variable numbers of folders...
Select or Download Code
Re: Re: Variable numbers of folders...
by bioinformatics (Friar) on Jul 28, 2003 at 17:39 UTC
    I have tried to implement your suggested code into the program, but have found it isn't workig very well. Apparently, it is unable to open the directory. This could be because I'm not entering the name in a readable form, but I'm not sure. Here's where I'm at:
    #! usr/local/bin/perl print STDOUT "Hello\!\n"; print STDOUT "This program will take a folder of Affymetrix text files + and put\n"; print STDOUT "their signal data in a format useful for Cyber-T\.\n"; print STDOUT "Please enter the name and location of the directory to p +arse\:\n"; $directory=<STDIN>; open (OUTPUTFILE,">data.csv"); opendir(DIR, "$directory") or die "Failed to open $directory: $!"; while (defined(@filename = readdir(DIR))) { @spliced_data=splice(@filename, 0, 15); foreach $_(@filename) { ($a, $b, $c, $d, $e, $f)=split(/\t/); push(@final_data, "$d\n");} print OUTPUTFILE "@final_data"; } closedir(DIR);
    Thanks for your help!!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-09-19 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (129 votes), past polls