in reply to Re: processing a lot of files
in thread processing a lot of files

This is not clear, particularly '$_'. I can process using open, but I run into
problems with opendir and readdir. I want to change the format of the files.
my $dir = "dir/files"; opendir my $dh,"$dir"; my @files = raddir $dh; for my $f(@files){ #Each file is the same format. #so, I should be able reformat # with read, and write here #currently I am using: my $i = 1; open (my $out, $f); while(<$_>){ my @fields = split /\t/; my $well_position = $fields[0]; my $sample = $fields[1]; $sample =~ /(\d+)(.*)/; my $barcode = $fields[2]; my $block_id = $fields[3]; my $name = substr($block_id,11); my $outfile = "$out$i"; print Fi "$well_position\t$1\t$2\t$barcode\t$name\n"; } $i++; } closedir($dh);
Still stuck }

Replies are listed 'Best First'.
Re^3: processing a lot of files
by Utilitarian (Vicar) on Jul 28, 2009 at 20:12 UTC
    try the following on the command line
    perl -e 'opendir DIR, "./";@directory =readdir(DIR);for $entry (@direc +tory){print "$entry\n";}'
    in your while loop in the failing example $f is a string with the name of a file in it, you have to open, process and close the file inside the loop