Computing.Net > Forums > Unix > Renaming file using Perl

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Renaming file using Perl

Reply to Message Icon

Name: nimi
Date: July 18, 2006 at 20:37:53 Pacific
OS: NA
CPU/Ram: NA
Product: NA
Comment:

Hi

My source filename is as following
MGHTC_INT_10July.txt

__________________________________
My current script is
$strSubA_Dir="/SDCT/output";

local ($strFile)= @_;

$strOutFileA="$strSubA_Dir/strFile".".TBL1";
open (OUTFILEA, ">$strOutFileA");

produces the following filename
MGHTC_INT_10July.txt.TBL1


but I want to append the name TBL1 at the beginning of the filename.
TBL1_MGHTC_INT_10July.txt


Please help me

Thanks
Nimi



Sponsored Link
Ads by Google

Response Number 1
Name: FishMonger
Date: July 18, 2006 at 23:35:12 Pacific
Reply:

my $strSubA_Dir = "/SDCT/output";

my $strFile = shift;

my $strOutFileA = "$strSubA_Dir/TBL1_$strFile";

open (OUTFILEA, ">$strOutFileA") || die $!;


0

Response Number 2
Name: FishMonger
Date: July 18, 2006 at 23:39:17 Pacific
Reply:

BTW, that doesn't rename the file...it creates a new empty file.

Run these 2 commands (from the command line) to learn the difference.

perldoc -f rename

perldoc -f open


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Renaming file using Perl

help: parsing html file using perl www.computing.net/answers/unix/help-parsing-html-file-using-perl-/7851.html

Renaming files with awk www.computing.net/answers/unix/renaming-files-with-awk/8036.html

How to search for files using PERL www.computing.net/answers/unix/how-to-search-for-files-using-perl/7500.html