Title: RE: reading portions of a line from a file

; open your file
; loop through each line

$s="your huge string read from your open file";

$a_begin=5;
$a_end=10;

$b_begin=50;
$b_end=100;

$c_begin=280;
$c_end=300;

$a=substr($s,$a_begin,$a_end-$a_begin+1);
$b=substr($s,$b_begin,$b_end-$b_begin+1);
$c=substr($s,$c_begin,$c_end-$c_begin+1);

; do what you want to with $a, $b, and $c
; close your file

-----Original Message-----
From: Terry Franklin [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 03, 2001 11:14 AM
To: '[EMAIL PROTECTED]'
Subject: reading portions of a line from a file


All,

I am in need of doing the following in a perl/tk app i am writing ... I have
very large text files, about 300 characters per line, and thousands of lines
long.

I need to be able to assign variables to, for example, the characters in
positions 5-10, 50-100, and 280-300 in each line

There is no common delimiter to split each line.

So how can I open a file and process each line in such a way?

i.e.

open(CURRENTFILE, "$source_directory/$file") or die "Cannot open $file: $!";

## What would go here??

close CURRENTFILE;

Thx
Terry
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to