in reply to Simple parse of file - getting started
#!/usr/bin/perl use strict; use warnings; while (<DATA>) { last if /AGF30/; } exit unless defined; unless (/%/) { while (<DATA>) { last if /%/; } } exit unless defined; my $ir_value = substr $_ => -10; for my $c (1 .. 2) { no warnings 'misc'; $_ = <DATA> err exit; } my $ysp_value = substr $_ => -10; print "\$ir_value = $ir_value"; print "\$ysp_value = $ysp_value"; __DATA__ one line two line three line bla AGF30 foor four line feeble % 0123456789 one more two more ABCDEFGHIJ end
Running this gives:
(That's 10 characters, including the newline).$ir_value = 123456789 $ysp_value = BCDEFGHIJ
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Simple parse of file - getting started
by RickF71 (Initiate) on Sep 30, 2003 at 18:36 UTC |