> ------_=_NextPart_001_01C524BC.E5934C9B > Content-Type: text/plain; > charset="us-ascii" > Content-Transfer-Encoding: quoted-printable > > Hi all, > =20 > I am trying to evaluate a string, and determine if the last charater of > the string has a backslash '\' . The piece of code I am using doesn't > appear to work. What I've found with this peice of code is that if the > string does contain a \, then the following code still adds another > slash. If there is not backslash in the string, the the code appears to > work fine by adding a backslash. Any ideas?
You mean something like ... ===================== begin code =========================== #!/usr/bin/perl use strict; use warnings; my @directory = ( 'foo\\bar', 'foo\\bar\\baz\\', '\\foo\\bar\\baz\\waldo' ) ; foreach my $directory (@directory) { print "before: $directory\n"; $directory .= '\\' unless $directory =~ m/\\$/; print " after: $directory\n\n"; } ====================== end code ============================ Produces the following output lawrence /tmp > perl test.pl before: foo\bar after: foo\bar\ before: foo\bar\baz\ after: foo\bar\baz\ before: \foo\bar\baz\waldo after: \foo\bar\baz\waldo\ lawrence /tmp > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>