[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

re: [MacPerl] match "/" at end of string ???



dshaffer@classroom.net writes:
} here's an easy one...
} 
} 
} what is the best way to to check if string has  a "/" at the end?
} 
} $slashdirpath = "images/porsches/my911s/";
} 
} if ($slashdirpath =~ /$\//) {

You've got this backwards, and there's a cleaner way to write it:

if ($slashdirpath =~ m,/$,) {

$ matches the end of line.  You don't have to use / to delimit the
regular expressions you're trying to match, although you do then have to
use the m operator explicitly.

}    print "slash path does have a slash after it\n";
} } else {
}     print "slash path does NOT have a slash after it\n";
} }
} 
} this does not work...please help!!!
} 
} thank you 
}    dave
} 
---
--------
Paul J. Schinder
NASA Goddard Space Flight Center,
Code 693, Greenbelt, MD 20771 USA
schinder@pjstoaster.pg.md.us