Jensen Kenneth B Sra Afpc/Dpdmpq wrote: > > Trying to get this to work on one line, but not having any success. In my > boredom I re-wrote the find command using perl4, and in tweaking it I'm > running into a problem. When I type in a starting search path as > "./something/something" I want to replace the "." with the current working > directory. Since I am forced to use perl4,
WHY?? > the only way I know to grab the > directory is using system commands "pwd" or "dirs -l". Those system commands > append a carriage return, which is where my problem comes in. Here's some of > the lines I've tried > > $_spath = shift; > print "$_spath\n"; > $path = `pwd`; > #$_spath =~ s/^\./(($path=`pwd`) =~ s/\n//))/e; > #($_spath =~ s/^\./$path=`pwd`/e) =~ chop($_spath); > #($chop($path)) =~ $_spath =~ s/^\./$path = `pwd`/e; > #($_spath =~ s/^\./($path=`pwd`) =~ chop($path)/e); > $_spath =~ s/^\./chop(`pwd`)/e; $_spath =~ s{^\.} { $path = `pwd`; chop $path; $path }e; > print "$_spath\n"; > > I've tried dozens of ways in one command, but can't get rid of that carriage > return. Chop works fine as long as I don't try to do it inside the > substitution, reason for that? It works, it's just that you have to return the path not the return value of chop. > In a nutshell I am just trying to make my little searching script identify a > path beginning with "." and replace that with the pwd, so I don't have to > type out absolute paths every time. FWIW, here's that script > > #!/usr/contrib/bin/perl #!/usr/contrib/bin/perl -w > ($_pattern, $_start) = (shift, shift); > print "Starting search at: $_start\n"; > > chdir "$_start"; Useless use of quotes. You should verify that chdir worked. unless ( chdir $_start ) { print STDERR "Cannot chdir to $_start: $!"; exit 1; } > opendir (DIR, "$_start"); Useless use of quotes. You should verify that opendir worked. unless ( opendir( DIR, $_start ) ) { print STDERR "Cannot open $_start: $!"; exit 1; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]