ways to change the first char from a filename (with full path)
From: Rod Za (rodzadra_at_yahoo.com)
Date: 06/29/04
- Next message: Gunnar Hjalmarsson: "Re: Installing a module when you have limited permissions"
- Previous message: Gunnar Hjalmarsson: "Re: Extracting fields from a data file"
- Next in thread: Thomas Kinzer: "RE: ways to change the first char from a filename (with full path)"
- Maybe reply: Thomas Kinzer: "RE: ways to change the first char from a filename (with full path)"
- Reply: Gunnar Hjalmarsson: "Re: ways to change the first char from a filename (with full path)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 29 Jun 2004 09:03:42 -0700 (PDT) To: beginners@perl.org
Hi all,
i'm trying to make a code that get a file name (with full path) and change the first char of the
filename. Someone can say me if there's a better way to do this?:
_BEGIN_
#!/usr/bin/perl -w
my($file) = $ARGV[0]; #receives the filename
my @tmp = split(/\//,$file); #split the path
$tmp[$#tmp] =~ s/.(\w+)/c$1/g; #change the first char of the filename
my $IPPFile = join('/',@tmp); #join again path+'/'+filename
print "Original Filename: $file - Changed Filename: $IPPFile\n"; #print the result
_END_
e.g. ./filename.pl /var/spool/cups/d00001
will print:
Original Filename: /var/spool/cups/d00001 - Changed Filename: /var/spool/cups/c00001
Thank you.
Rod
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
- Next message: Gunnar Hjalmarsson: "Re: Installing a module when you have limited permissions"
- Previous message: Gunnar Hjalmarsson: "Re: Extracting fields from a data file"
- Next in thread: Thomas Kinzer: "RE: ways to change the first char from a filename (with full path)"
- Maybe reply: Thomas Kinzer: "RE: ways to change the first char from a filename (with full path)"
- Reply: Gunnar Hjalmarsson: "Re: ways to change the first char from a filename (with full path)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|