Main Page | Report this Page
Computers Forum Index  »  Computer Languages (Perl - Modules)  »  filename stripping, a-la the patch(1) --strip=NUM...
Page 1 of 1    

filename stripping, a-la the patch(1) --strip=NUM...

Author Message
Ivan Shmakov...
Posted: Wed Sep 30, 2009 6:30 pm
Guest
I wonder, is there an existing module to do filename (path)
stripping, like it is implemented in, e. g., patch(1)?

STRIP (0, "/a/b/c/d") => "/a/b/c/d" ;
STRIP (1, "/a/b/c/d") => "a/b/c/d" ;
STRIP (2, "/a/b/c/d") => "b/c/d" ;
STRIP (3, "/a/b/c/d") => "c/d" ;
STRIP (4, "/a/b/c/d") => "d" ;
STRIP (5, "/a/b/c/d") => "d" ;

And if there's no such module, would there be any specific
advices on how to write such a code and on how to wrap it into a
module?

PS. Even better if it would do it the other way around, too, like:

STRIP (-1, "/a/b/c/d") => "d" ;
STRIP (-2, "/a/b/c/d") => "c/d" ;
STRIP (-3, "/a/b/c/d") => "b/c/d" ;
STRIP (-4, "/a/b/c/d") => "a/b/c/d" ;
STRIP (-5, "/a/b/c/d") => "/a/b/c/d" ;
STRIP (-6, "/a/b/c/d") => "/a/b/c/d" ;

--
FSF associate member #7257
 
 
Page 1 of 1    
All times are GMT
The time now is Mon Nov 30, 2009 2:29 am