Re: substitute using directory name

2008-09-03 Thread Louis-Philippe
just the folder name? test the snippet I posted earlier... it should do it for you! L-P 2008/9/3 brian54321uk <[EMAIL PROTECTED]> > Thanks for the input, having tested Shawns solution, I will probably find > at a later date that it is vital I include the full pathname in future > output, so will

Re: substitute using directory name

2008-09-03 Thread brian54321uk
Thanks for the input, having tested Shawns solution, I will probably find at a later date that it is vital I include the full pathname in future output, so will subject the file to a second pass to get rid of the full pathname whilst I am at my present testing point. However, I would like to get

Re: substitute using directory name

2008-09-03 Thread Louis-Philippe
what Shawn just wrote could be ok for you Brian, but only if you change working directory while processing files, because his script uses cwd() to get directory (which reads 'current working directory') the other option would be to say: use File::Basename; use File::Spec; my @alldirs = File::Spe

Re: substitute using directory name

2008-09-03 Thread Mr. Shawn H. Corey
On Wed, 2008-09-03 at 16:47 +0100, brian54321uk wrote: > Just tested this out and unfortunately instead of dirname replacing > abc123, I get a . That's because the dirname is a '.' Try: use Cwd; if( (my $dir = dirname( $file )) eq '.' ){ $dir = cwd(); } -- Just my 0.0002 million dollar

Re: substitute using directory name

2008-09-03 Thread brian54321uk
Mr. Shawn H. Corey wrote: On Wed, 2008-09-03 at 14:55 +0100, brian54321uk wrote: Hi I would like to replace a string of characters in a file to the name of the directory it is in. Thefore, in the example below, I would like to know how to replace "?" open( F, $ARGV[0] ); while( ) { s!ab

Re: substitute using directory name

2008-09-03 Thread Mr. Shawn H. Corey
On Wed, 2008-09-03 at 14:55 +0100, brian54321uk wrote: > Hi > I would like to replace a string of characters in a file to the name of > the directory it is in. > Thefore, in the example below, I would like to know how to replace "?" > > > open( F, $ARGV[0] ); > > while( ) { > > s!abc123!?!;

substitute using directory name

2008-09-03 Thread brian54321uk
Hi I would like to replace a string of characters in a file to the name of the directory it is in. Thefore, in the example below, I would like to know how to replace "?" open( F, $ARGV[0] ); while( ) { s!abc123!?!; s!xyz123!123xyz!; { print; } } Any help much appreciated. Brian