I gave up the below code in favour of the module ;)
Pick at it if you will.
lee
accepts path
returns dir, fn
if ($path !~ /\.(html?|xml)$/)
if ($path !~/(\\|\/)$/){
$path =~ m/(\\|\/)/;
$path.=$1;
}
return ($path, "");
} else {
my $sep = rindex($path,"\\") +1;
$sep = rindex($path,"/") +1 if $sep<=0;
return ( substr($path, 0, $sep), substr($path, $sep) );
}
lee
At 16:39 27/03/2001 -0600, Dirk Bremer wrote:
>I would like something without the overhead of a module.
>
>Dirk Bremer - Systems Programmer II - AMS Department - NISC
>636-922-9158 ext. 652 fax 636-447-4471
>
><mailto:[EMAIL PROTECTED]>
>
>----- Original Message -----
>From: <[EMAIL PROTECTED]>
>To: "Dirk Bremer" <[EMAIL PROTECTED]>
>Cc: "perl-win32-users" <[EMAIL PROTECTED]>
>Sent: Tuesday, March 27, 2001 4:05 PM
>Subject: Re: Regex Help
>
>
> >
> >
> > Try using this:
> >
> > use File::Basename; # for picking apart file specs
> >
> > # filename, directory, extension
> > #
> > ($filena,$ldir,$ext) = fileparse($ARGV[0],'\..*');
> >
> >
> >
> >
> >
>
> > "Dirk Bremer"
> <[EMAIL PROTECTED]>
>
> > Sent
> by: To: "perl-win32-users"
>
> > [EMAIL PROTECTED]
> <[EMAIL PROTECTED]>
> > eState.com cc:
>
> >
> Subject: Regex Help
> >
>
> > 03/27/01 05:03
> PM
>
> > Please respond to "Dirk
> Bremer"
>
> >
>
> >
>
> >
> >
> > I want to build a regular expression that will separate a filename string
> > into the root name, filename, and extension name, placing
> > the results in $1, $2, $3. For example,
> > given the filename "d:\doc1_directories\journals\test\b11111_01_emfe.jrn",
> > I would like the regex to return 3 different items, i.e.:
> >
> > d:\doc1_directories\journals\test\
> > b11111_01_emfe
> > jrn
> >
> > If possible, I would like it to work with filename strings that utilize
> > either forward slashes "/" or backward slashes "\". So far,
> > I am able to get to the filename and extension using:
> >
> > my $f = 'd:\doc1_directories\journals\test\b11111_01_emfe.jrn';
> > $f =~ /([^\/\\]+)\.(.*)$/;
> >
> > which returns:
> >
> > $1 = b11111_01_emfe
> > $2 = jrn
> >
> > I have tried various combinations to get the root-part without success.
> > This regex should also be able to handle filename strings
> > that do not have the root part, i.e.
> >
> > b11111_01_emfe.jrn
> >
> > where $1 would be undefined. Your suggestions will be appreciated.
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users