There is only one person in the @coders array because I am testing. Here is what I get when I run this:#!/usr/bin/perl use strict; my $targetdir = 'bmd/production'; my @coders = qw(fleischer); foreach my $c (@coders) { print "$c\n"; open(IN,"$c-assignments.dat") or die "Can't open input: $!\n"; my @coderfiles; while (<IN>) { chop; if ($_ =~ /\w/) { push(@coderfiles,$_); } } close IN; foreach my $f (@coderfiles) { print "$f\n"; my ($countrydir) = split(/\-/,$f); my $ofn = "$countrydir/$f"; print "$ofn\n"; my $nfn = "/usr/local/brat/data/$targetdir/$c/$countrydir/$f"; print "$nfn\n"; open(IN,$ofn.'.txt') or die "Can't open input: $!\n"; open(OUT,">$nfn".'.txt') or die "Can't open output: $!\n"; while (<IN>) { print OUT $_; } close IN; close OUT; open(OUT,">$nfn\.ann") or die "Can't open output: $!"; print OUT ''; close OUT; } }
But the script is in the directory above uk and...fleischer uk-07-m-01 uk/uk-07-m-01 /usr/local/brat/data/bmd/production/fleischer/uk/uk-07-m-01 Can't open input: No such file or directory
It appears the .txt filetype is not getting appended to the filename. I have tried expressing the filename every way I can think of, for example "$ofn\.txt" which I normally do and have done a thousand times before, and I get the same result. Just for laughs, I commented out everything below the first open in the foreach loop, and addedbash-3.2$ ls uk/uk-07-m-01.txt uk/uk-07-m-01.txt
And I getprint "$ofn\.txt\n"; print $ofn.'.txt'."\n"; print "$nfn\.txt\n"; print $nfn.'.txt'."\n";
WTF?!?fleischer uk-07-m-01 uk/uk-07-m-01 /usr/local/brat/data/bmd/production/fleischer/uk/uk-07-m-01 .txtk-07-m-01 .txtk-07-m-01 .txt/local/brat/data/bmd/production/fleischer/uk/uk-07-m-01 .txt/local/brat/data/bmd/production/fleischer/uk/uk-07-m-01
What am I doing wrong?
In reply to File that exists won't open by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |