D
Daniel Bergquist
Consider the following chunk of code:
--------------------------------------------------
open (IN, "<:raw", "test2.txt") or die "Can't open test.txt";
chomp($line = <IN>);
# Capture excerpt
$line =~ m/>([^<]+)/;
# Copy first line of excerpt
$pExcerpt = $1;
# Next line
chomp($line = <IN>);
# Untill we have reached the end of the section
until($line =~ m/<\/p>/i) {
# Capture useful text
$line =~ m/([^<]+)/;
chomp($line = <IN>);
}
# Capture the rest of the useful text
$line =~ m/([^<]+)/;
$pExcerpt = "$pExcerpt $1";
print "final: $pExcerpt\n";
-----------------------------------------------------------
The file test2.txt is as follows:
-------------------------------------------------
<p class=p1>I consider myself fortunate to stand before you today as I
make my
defense against all the accusations of the Jews. <i>Acts 26:2</i></p>
----------------------------------------------
When run:
P:\WEBPOP\EXPERI~1>excerpt.pl
defense against all the accusations of the Jews. you today as I make
my
P:\WEBPOP\EXPERI~1>
When I change the concatenation to as follows:
$pExcerpt = "$1 $pExcerpt";
The result is:
P:\WEBPOP\EXPERI~1>excerpt.pl
final: defense against all the accusations of the Jews. I consider
myself fortunate
to stand before you today as I make my
P:\WEBPOP\EXPERI~1>
Which is how I would expect it to work. Why does it not work the first
way(which is the way I need it)?
Perl reports itself as v5.8.3 built for MSWin32-x86-multi-thread,
binary build 809 provided by ActiveState Corp.
Thanks!
Daniel Bergquist
--------------------------------------------------
open (IN, "<:raw", "test2.txt") or die "Can't open test.txt";
chomp($line = <IN>);
# Capture excerpt
$line =~ m/>([^<]+)/;
# Copy first line of excerpt
$pExcerpt = $1;
# Next line
chomp($line = <IN>);
# Untill we have reached the end of the section
until($line =~ m/<\/p>/i) {
# Capture useful text
$line =~ m/([^<]+)/;
chomp($line = <IN>);
}
# Capture the rest of the useful text
$line =~ m/([^<]+)/;
$pExcerpt = "$pExcerpt $1";
print "final: $pExcerpt\n";
-----------------------------------------------------------
The file test2.txt is as follows:
-------------------------------------------------
<p class=p1>I consider myself fortunate to stand before you today as I
make my
defense against all the accusations of the Jews. <i>Acts 26:2</i></p>
----------------------------------------------
When run:
P:\WEBPOP\EXPERI~1>excerpt.pl
defense against all the accusations of the Jews. you today as I make
my
P:\WEBPOP\EXPERI~1>
When I change the concatenation to as follows:
$pExcerpt = "$1 $pExcerpt";
The result is:
P:\WEBPOP\EXPERI~1>excerpt.pl
final: defense against all the accusations of the Jews. I consider
myself fortunate
to stand before you today as I make my
P:\WEBPOP\EXPERI~1>
Which is how I would expect it to work. Why does it not work the first
way(which is the way I need it)?
Perl reports itself as v5.8.3 built for MSWin32-x86-multi-thread,
binary build 809 provided by ActiveState Corp.
Thanks!
Daniel Bergquist