in reply to Re: Check last character of a string
in thread Check last character of a string

Well it fails as in I need the string to end with \ because I use it as a folder name adding filenames to it. So when the ARGV does not end with \ the adding goes wrong.

Replies are listed 'Best First'.
Re^3: Check last character of a string
by Corion (Patriarch) on Aug 06, 2008 at 09:31 UTC

    Have you thought about using File::Spec->catfile instead?

Re^3: Check last character of a string
by Perlbotics (Archbishop) on Aug 06, 2008 at 09:51 UTC
    Hi, for me this works:
    #!/usr/bin/perl use strict; my @tests = qw( path1 paht2\ ); for my $location (@tests) { print "before: '$location'\n"; $location .= '\\' unless $location =~ m(\\$); print "after: '$location'\n"; } __END__ before: 'path1' after: 'path1\' before: 'paht2\' after: 'paht2\'