CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Split input .dat files based on first 16 chars HELP

 



ofmike
New User

Nov 21, 2011, 8:29 AM

Post #1 of 1 (321 views)
Split input .dat files based on first 16 chars HELP Can't Post

Alright so here is what I'm trying to do, and what I have so far.

# Read a file and write out the same file with transformations
# 1) Change filename of input to filename-subname on output.
# 2) Each record in the input file will have a 16 character subname
# 3) The same record in the output will have the 16 characters removed
# 4) One or more output files will be created based on how many unique subnames are on the input records
# 5) Input records are not sorted by subname
use File::Basename;

($name,$path,$suffix) = fileparse($fullname,@suffixlist);
$name = fileparse($fullname,@suffixlist);

$basename = basename($fullname,@suffixlist);
$dirname = dirname($fullname);


open(INFILE, "<$basename");
open(OUTFILE, ">$file-$subname.$suffix");
while(<INFILE>)
{
my($line) = $_;
}
#strip trailing newline from the line
chomp($line);

#set the line to the first 16 characters
$line = substr($_ 0, 16);
{
my($subname) = $line;
}
close FILE




Just tried to run it received this error:
Missing comma after first argument to substr function at subNameTransform1.pl line 44, near "16)".

Can someone please help me get this working? I'm really terrible with perl, your help would be greatly appreciated.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives