
vishwakar
Novice
Dec 24, 2010, 11:37 AM
Views: 3157
|
|
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"; }
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)
|