Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Check last character of a string

by theroninwins (Friar)
on Aug 06, 2008 at 09:28 UTC ( [id://702577]=note: print w/replies, xml ) Need Help??


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\'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://702577]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-25 12:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found