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: Re: [Zhris] Have to exclude the first and last line of the file : help me: Edit Log



vishwakar
Novice

Dec 24, 2010, 11:37 AM


Views: 3937
Re: [Zhris] Have to exclude the first and last line of the file : help me



opendir(DIR, $DATDIR) or die "can't opendir $dir: $! \n";
@files=readdir(DIR);
closedir DIR;
foreach $file (@files) {
if (-f "$dir$file")
{
#$moveloc="/export/elk2/sm425k/new/"; # Make sure the directory is already made.
#$new = "$moveloc";
$old = "$dir$file";
$new = "$WORKDIR";
move($old, $new) or die "Copy Faild: $!";
}
}

@list = reverse sort(@files);

open(DAT, "$WORKDIR/$list[0]") || die("Could not open file!");
open my $inputfh, '<', '$list[0]' ;
my @lines = <$inputfh>;
close $inputfh;
shift @lines;
pop @lines;
foreach $line(@lines)
{
print " $line \n";
}


Code
 

ya i know that the array consists of the data
which has removed first and last line.. but the
above logic i am using is not doing that ..

first i ll get a number of files ,, i have to move them
to a directory and select a file with the latest time stamp..
so i used reverse sort which was working fine
so $list[0] consits of the file which i have to read
and will be as mentioned above...
i think i made u clear.. please can we use some what like
nested array in perl .. i meant array inside a
array inside array


(This post was edited by vishwakar on Dec 24, 2010, 11:46 AM)


Edit Log:
Post edited by vishwakar (Novice) on Dec 24, 2010, 11:46 AM


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

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