PERL HELP

I need to get a subsring of the name of a file opened through @argv. I
need the first letter of the name of the file, but it needs to be able to
come from any directory.

I need just the file name part, not the directory information.

Can anyone help?

@sources = @ARGV; # save what was passed

foreach $source (@sources) {

$the_variable_i_want = subsr($source, 0, 1);

}

Its been a while since I’ve been around Perl syntax (Go PHP!), but… I’m
assuming that @sources includes the full directory, for example,
/foo/bar/ho/ho/what.conf. You could split the text between the /'s (into
$source[]), and then use $var = substr($source[-1],0,1);


Sean S. <?$s=“moc.seiticoeg@osomynus”;$s=ereg_replace(
“osom”,“noom”,$s);$s=strrev($s);echo"mailto:$s";?> Hex(RGB) ->
http://thedoh.dyndns.org/hexrgb/index.php

“Mark Lyon” <mark@marklyon.org> wrote in message
news:3B0F078B.3C29D49A@marklyon.org
> I need to get a subsring of the name of a file opened through @argv. I
> need the first letter of the name of the file, but it needs to be able
> to come from any directory.
>
> I need just the file name part, not the directory information.
>
> Can anyone help?
>
>
> @sources = @ARGV; # save what was passed
>
> foreach $source (@sources) {
>
> $the_variable_i_want = subsr($source, 0, 1);
>
> }

Yeah. wound up doing that. had to think for a few mins. Mac Perl has some
really strange quirks.

“Sean S.” wrote:

> Its been a while since I’ve been around Perl syntax (Go PHP!), but…
> I’m assuming that @sources includes the full directory, for example,
> /foo/bar/ho/ho/what.conf. You could split the text between the /'s (into
> $source[]), and then use $var = substr($source[-1],0,1);
>
> –
> Sean S. <?$s=“moc.seiticoeg@osomynus”;$s=ereg_replace(
> “osom”,“noom”,$s);$s=strrev($s);echo"mailto:$s";?> Hex(RGB) ->
> http://thedoh.dyndns.org/hexrgb/index.php
>
> “Mark Lyon” <mark@marklyon.org> wrote in message
> news:3B0F078B.3C29D49A@marklyon.org
> > I need to get a subsring of the name of a file opened through @argv. I
> > need the first letter of the name of the file, but it needs to be able
> > to come from any directory.
> >
> > I need just the file name part, not the directory information.
> >
> > Can anyone help?
> >
> >
> > @sources = @ARGV; # save what was passed
> >
> > foreach $source (@sources) {
> >
> > $the_variable_i_want = subsr($source, 0, 1);
> >
> > }