Hi all,
I made those changes here...actually copied from the old file and made changes to it. I did follow your advice and changed it but didn't upload the file with those changes.:)
Ok..I struggled with it and found that if i read the file as an array as shown below in the code I was able to read each line in the file but not with Tie::File. Can some one tell me the reason?
#!/usr/bin/perl
use strict;
use warnings;
use Tie::File;
use Fcntl;
#Variable Declaration
my @array;
my $line="";
my @data;
my $map_dir="";
my $dir="";
my $part_no="";
my $chg_lvl="";
my $int_lock="";
my $t_spec="";
my @list="";
my $formatted_list="";
my $i;
#Program Main
if ($#ARGV == -1)
{
print "\n";
print "Enter a file containing part number, <R> to Quit: ";
chomp($file_name=<>);
}
else
{
$file_name=$ARGV[1];
}
open (FILE,"$file_name");
##########
These two lines are commented out
###################
#tie (@data,'Tie::File',$file, mode=>O_RDWR) or die "Can't tie to $fil
+e:$^E\n";
#(tied @data)->defer;
##############
##I am reading the file as an array here
################
@data=<FILE>;
foreach (@data)
{
($map_dir,$dir,$part_no,$chg_lvl,$int_lock,$t_spec) = split /\s+/;
print "@list";
print "$formatted_list";
print " $map_dir,$dir,$part_no,$chg_lvl,$int_lock,$t_spec";
}
#(tied @data)->flush;
So is there a problem using Tie::File?
Thanks
|