
brosskgm
User
Mar 19, 2013, 10:25 AM
Post #9 of 13
(190 views)
|
|
Re: [Laurent_R] Find & Replace
[In reply to]
|
Can't Post
|
|
Thanks, I have been looking at that. Still lost. Don't understand how to work this to what I'm trying to do. They all seem to be talking about file path etc. It's way to advanced for me. All the code I'm seeing they all have the full name hard coded. Not good with Perl.
use File::Basename; $fullname = "/usr/local/src/perl-5.6.1.tar.gz"; // I don't know the full name. $file = basename($fullname); # file="perl-5.6.1.tar.gz" $dir = dirname($fullname); # dir="/usr/local/src" ($file,$dir,$ext) = fileparse($fullname, qr/\..*/); # dir="/usr/local/src/" file="perl-5" ext=".6.1.tar.gz" ($file,$dir,$ext) = fileparse($fullname, qr/\.[^.]*/); # dir="/usr/local/src/" file="perl-5.6.1.tar" ext=".gz" ($file,$dir,$ext) = fileparse($fullname, qr/\.\D.*/); # dir="/usr/local/src/" file="perl-5.6.1" ext=".tar.gz" ($file,$dir,$bak) = fileparse("/tmp/file.bak", qr/~+$/, qr/\.(bak|orig|save)/) # dir="/tmp/" file="file" ext=".bak" ($file,$dir,$bak) = fileparse("/tmp/file~", qr/~+$/, qr/\.(bak|orig|save)/) # dir="/tmp/" file="file" ext="~"
|