in reply to Referencing string: Can't use string as a SCALAR ref

P0w3rK!d,
Ok - completely misread the question the first time. Try taking a look at File::Basename, but here's a RE to try if you are 100% of your filenames and know there will be no gotchas.
my $strFileA = 'C:\foo\a\b\c\123.xml'; my ($filename) = ($strFileA =~ /\\([^\\]*)$/); print $filename,"\n";

Cheers - L~R

Replies are listed 'Best First'.
Re: Re: Referencing string: Can't use string as a SCALAR ref
by P0w3rK!d (Pilgrim) on May 12, 2003 at 18:33 UTC
    Thank you :) I have it working now. I'm just curious if I can do it a better way.

    -P0w3rK!d

      There is a better way to do it. (Which happens to be Limbic~Region's first suggestion.) As an added bonus, it also makes the code more portable to other OS's (as long as you have the script setup a directory or something rather than hard-coding it.)

      use File::Basename; my $file = basename($filestring); print $file,$/;

      antirice    
      The first rule of Perl club is - use Perl
      The
      ith rule of Perl club is - follow rule i - 1 for i > 1

Re: Re: Referencing string: Can't use string as a SCALAR ref
by P0w3rK!d (Pilgrim) on May 12, 2003 at 18:17 UTC
    $strFileA comes in as a function parameter.