Hello John, I know I am missing something basic here also, but tell me in the example (my $projectId) = $projectDocDir =~ m!.*/(\w+)/!; why isn't the /1_0001.doc being printed as well?
Open my Eyes! Regards, Jaimee -----Original Message----- From: John W. Krahn [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 01, 2002 4:18 PM To: [EMAIL PROTECTED] Subject: Re: string manipulation Garrett Esperum wrote: > > Hi all, Hello, > I am using Solaris, Perl 5. > I am having some problems manipulating strings. > The string I am manipulating is: > > /export/home/user/www/doc-root/dir/projects/19463/1_0001.doc > > I am trying to take out the "19463" part from the string and insert it into > a variable. > > Example of my code to do this: > > $projectId = substr($projectDocDir, length($dir), index($projectDocDir, "/", > length($dir))); > > The $dir variable contains the path > "/export/home/user/www/doc-root/dir/projects". > > When I run my script, the string "1946" is returned, the last "3" is not. > What am I doing wrong?? Either of these should work: (my $projectId) = $projectDocDir =~ m!.*/(\w+)/!; # or my $projectId = (split /\//, $projectDocDir)[-2]; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]