On Fri, 2008-11-07 at 05:55 -0800, Jeff P. wrote: > --- On Fri, 11/7/08, Brent Clark <[EMAIL PROTECTED]> wrote: > > > From: Brent Clark <[EMAIL PROTECTED]> > > Subject: Regex path > > To: beginners@perl.org > > Date: Friday, November 7, 2008, 1:46 PM > > Hiya > > > > I have some paths like so. > > > > /home/brent/cgi-bin/scripts/common/ticktaktoe > > /home/brent/cgi-bin/scripts/agent/ticktaktoe > > > > > > Im trying to get $q to be populated with common or agent. > > > > use File::Basename; > my $path = dirname("/home/brent/cgi-bin/scripts/common/ticktaktoe"); > > my ($var) = $path =~ /.*\/(.+)$/;
my $var = basename( $path ); dirname and basename work on both files and directories :) See `perldoc File::Basename` for details. -- Just my 0.00000002 million dollars worth, Shawn The map is not the territory, the dossier is not the person, the model is not reality, and the universe is indifferent to your beliefs. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/