Re: Extract text from argument

2002-08-01 Thread Robin Norwood
FlashGuy [EMAIL PROTECTED] writes: Hi all, I have the following line in my Perl script $test=$ARGV[0] which dumps the following results =D:\temp\test\filename I need to extract only the filename to the right of the last \ and put that into a variable. There could only be one \ in

Re: Extract text from argument

2002-08-01 Thread FlashGuy
I took a look on www.perldoc.com and checked out split. I can't figure out how to do it from the examples? Help? On Thu, 01 Aug 2002 11:48:22 -0400, FlashGuy wrote: You mean split? On 01 Aug 2002 11:41:51 -0400, Robin Norwood wrote: FlashGuy [EMAIL PROTECTED] writes: Hi all,

RE: Extract text from argument

2002-08-01 Thread Shishir K. Singh
I took a look on www.perldoc.com and checked out split. I can't figure out how to do it from the examples? Help? Try out the following piece of code : use File::Spec; use strict; my $test = C:\\temp\\test\\filename; my ($volume,$directories,$file) =

[Robin Norwood rnorwood@redhat.com] Re: Extract text from argument

2002-08-01 Thread Robin Norwood
---BeginMessage--- No, 'split' is a built-in function, which you could also use. The reason I recommend File::Spec is that it is portable and standard. Generally, if a cpan module exists which covers your task, I'd use it. The 'split' method would be: my $file = (split /\\/, $test)[-1]; Which

RE: Extract text from argument

2002-08-01 Thread nkuipers
I suggest looking into the File::Basename module, which is bundled with perl. Most current documentation can be found at: http://search.cpan.org/doc/JHI/perl-5.8.0/lib/File/Basename.pm I suppose you could also use a regex...something like this perhaps? /.*(\\\w+)$/ cheers, nathanael --