"Nishi Bhonsle" schreef:
> I have a string such as
> instance/bit/bitGroup/default/tz/l_cs
> where the last directory stands for os languages.
>
> I have to get the last directory and assign it to a var such as
> $mylang = l_cs, in the above example.
> How can i achieve that?
my $s = q{instance/bit/bitGroup/default/tz/l_cs};
my ($n) = ($s =~ m~([^/]+)$~);
print $n;
Alternative:
my $s = q{instance/bit/bitGroup/default/tz/l_cs};
my $n = (split q{/}, $s)[-1];
print $n;
But if this string is a direct result from examining your filesystem,
then also look into File::Basename and File::Spec.
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/