R
Robert Stelmack
I have embedded some marked text in a large file to indicate chapters and
page numbers. I want to read that file and strip out the page number to be
displayed with the line of text or following text so as to have a page
number reference for the displayed text. I have read and reread the perlre
and looked for examples on the Internet, but I must be missing a basic
concept. I also have O'Reill's Programming Perl book, but the examples are
sometimes hard to apply to what I am trying to do. Here is what I tried to
get to work (with various syntax changes):
#!/usr/bin/perl
$_= "He had come to pass his experience along to me - if <page>10</page>I
cared to have it.";
$PAGE =~ /[<page>][0-9][<\/page>]/;
s,[<page>][0-9][</page>],,g;
printf "(p.$PAGE) contains [$_]:\n";
The output I expected was:
(p.10) contains [He had come to pass his experience along to me - if I cared
to have it.]
....but instead it displayed:
bash-2.05b$ test.cgi
(p.) contains [He had come to pass his experience along to me - if
<page>10</page>I cared to have it.]:
I really want to get my head around pattern matching and binding since all
my working code looks too much like my old FORTRAN programs.
Cheers,
Bob
page numbers. I want to read that file and strip out the page number to be
displayed with the line of text or following text so as to have a page
number reference for the displayed text. I have read and reread the perlre
and looked for examples on the Internet, but I must be missing a basic
concept. I also have O'Reill's Programming Perl book, but the examples are
sometimes hard to apply to what I am trying to do. Here is what I tried to
get to work (with various syntax changes):
#!/usr/bin/perl
$_= "He had come to pass his experience along to me - if <page>10</page>I
cared to have it.";
$PAGE =~ /[<page>][0-9][<\/page>]/;
s,[<page>][0-9][</page>],,g;
printf "(p.$PAGE) contains [$_]:\n";
The output I expected was:
(p.10) contains [He had come to pass his experience along to me - if I cared
to have it.]
....but instead it displayed:
bash-2.05b$ test.cgi
(p.) contains [He had come to pass his experience along to me - if
<page>10</page>I cared to have it.]:
I really want to get my head around pattern matching and binding since all
my working code looks too much like my old FORTRAN programs.
Cheers,
Bob