Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading a Specific Entry in PERL

Status
Not open for further replies.

dtmnuclear

Programmer
Apr 20, 2008
1
US
I am trying to read a specific entry in a text file with differing spacings and separations. I know the line and column numbers where this entry will appear, but I do not know how to reference this value, or how to extract it to another file.

Ultimately, I would like to open the file, read the entry, print the entry to another file, write a new value over the entry, and close the newly updated file.

Any help would be greatly appreciated as I am a novice (at best) with Perl programming. Many thanks!
 
open FILE,"< /path/to/file" or die "$!\n";
open OUT,">/paht/to/outfile" or die "$!\n";
while (<FILE>) {
($v1,$v2,$v3) = split (/delimiter/,$_);
print OUT "which ever value needed\n" if ($.== linenumber);
}
close OUT;
close FILE;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top