Terry,
You could loop the contents of the file and find the line you are
looking for...(i.e:
open(CURRENTFILE, "$source_directory/$file") or die "Cannot open $file: $!";
foreach $_ ( <CURRENTFILE> ) {
# do something like:
print "$_\n"; # to print each line
if ($_ =~ </some pattern/>) {
... # Do whatever it is you want to do
}
}
or you could use the while loop instead
while ($line = <CURRENTFILE>) {
if ($line =~ /some pattern/) {
... # Do whatever it is you want to do
}
}
not exactly sure this will work or if it's what you are looking for. But,
take a look into pattern matching you may find some useful information there
that could help you in your search.
-Wes
> -----Original Message-----
> From: Terry Franklin [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 03, 2001 9: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
>
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl