cburger has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I'm trying to change directories within a perl script, but for some reason it doesn't follow correctly into the right directory. Here is the code, if you know what's wrong with it - help is a lot appreciated! Thanks.
#!/usr/bin/perl use File::chdir; use Cwd; use strict; my $dir='/data1/sgb'; chdir '$dir/Hsapiens_fasta_folder'; my @files=<*.fa>; chdir '$dir/targetp-1.1'; my $current=getcwd(); foreach my $file( @files) { print "$file\n"; print "$current\n"; }
so what happens in this script is that instead of print at $current : chdir '$dir/targetp-1.1'; it prints '/data1/sgb'; - i.e. the location of $dir. I have no idea why. Thanks for the help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using change directory within perl script
by tangent (Parson) on Mar 27, 2012 at 04:22 UTC | |
by Anonymous Monk on Nov 27, 2012 at 10:25 UTC | |
|
Re: using change directory within perl script
by jwkrahn (Abbot) on Mar 27, 2012 at 04:16 UTC | |
|
Re: using change directory within perl script
by bms (Monk) on Mar 27, 2012 at 04:11 UTC | |
by Anonymous Monk on Feb 17, 2016 at 23:50 UTC | |
by Anonymous Monk on Feb 18, 2016 at 00:09 UTC |