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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.