[prev in list] [next in list] [prev in thread] [next in thread]
List: perl-win32-users
Subject: Re: regex and filename
From: "$Bill Luebkert" <dbecoll () adelphia ! net>
Date: 2003-11-27 13:37:40
[Download RAW message or body]
Beckett Richard-qswi266 wrote:
> Guys,
>
> Someone must have already done this, but I know I can't!
>
> I have an input file name, and using:
> use File::Basename;
> fileparse_set_fstype("MSWin32");
> my $file = fileparse ("$ARGV[0]");
> my $path = dirname ("$ARGV[0]");
>
> I am splitting the input file name into $file and $path.
>
> I can handle the path side of things, but I want to end up with an $outfile
> which is the same name as $file, but with either the .xxx replaced as .xls,
> or with .xls appended.
>
> i.e.
> if $file = log.txt, $outfile = log.xls
> if $file = whatever.you.likeitotbe, $outfile = whatever.you.likeitotbe.xls
> if $file = some.stupid.file.name.log, $outfile = some.stupid.file.name.xls
>
> For some reason "my @output = split ("\.", $file);" isn't giving me what I
> expect.
use File::Basename;
my ($name, $path, $ext) = fileparse ($ARGV[0], '\..*$');
# print "path='$path', name='$name', ext='$ext'\n";
$ext = '.xls';
print "$path$name$ext\n";
--
,-/- __ _ _ $Bill Luebkert Mailto:dbecoll@adelphia.net
(_/ / ) // // DBE Collectibles Mailto:dbe@todbe.com
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic