Sounds like homework to me. Anyway, here's a program (reading
from DATA) that will do what you want. Requires 5.8.1 with
the defined-or patch.
#!/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:
$ir_value = 123456789
$ysp_value = BCDEFGHIJ
(That's 10 characters, including the newline).
Abigail
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.