Here is one way to do it...

The regular expression checks to see if the last character (the one prior to
$) is a slash.




my $dir = 'd:/abs/fez:';

if ( $dir =~ m/\/$/ )
{
   print "Ends in a slash\n";
}
else
{
   print "No slash\n";
}







-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 11, 2002 9:55 AM
To: [EMAIL PROTECTED]
Subject: [Perl-unix-users] extract the last character or a string




Hi,

How do you extract the last character of a string

I basically want to see if a list of directory strings have a slash at the
end
or not.

For eg if

$dir = 'd:/abs/fez';

I know can use the length function to get the length of $dir but how do I
extract the last character ie. z and then do my tests ?

Any help appreciated.

Thanks
Kwabena




_____________________________________________________

This transmission has been issued by a member of the HSBC Group 
"HSBC" for the information of the addressee only and should not be 
reproduced and / or distributed to any other person. Each page attached 
hereto must be read in conjunction with any disclaimer which forms part 
of it. Unless otherwise stated, this transmission is neither an offer nor
the 
solicitation of an offer to sell or purchase any investment. Its contents
are 
based on information obtained from sources believed to be reliable but
HSBC makes no representation and accepts no responsibility or liability as 
to its completeness or accuracy.

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to