[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-WebCGI] Reading several lines from a file into a scalar? (Getting the text from a HTMLfile # 2.)



Hi, I posted a question (Getting the text from a HTMLfile. / match
problem ?)
before, I'm still working on that problem , so far I have come up with
the code below: 
But one big problem remains.
After the until statement I still need to assign the text between some
HTML comments to a scalar like below
I need to get the following result:
$some_name = "TEXT TEXT TEXT<br>TEXT <b>TEXT</b> TEXT<br>";

I cant read line by line since the text that needs to be assigned can be
on sevral lines,
insteed I need to read the file so that it starts with getting the
scalars name in the first comment then assignes the text after that
comment until it m/<!--END -->/  (matches the end tag).

Is this possible ?



Example from HTML File
###################
<!--VALUE:NAME=some_name -->
TEXT TEXT TEXT<br>
TEXT <b>TEXT</b> TEXT<br>
<!--END -->

Snippets from my code:
##############################
#!perl

open(INFILE,"<$TENTAFIL") or die "Can't open file\n";
@filen=<INFILE>; 
close(INFILE);   

until ($delar eq 'OK')
{
foreach $line (@filen)
{
chomp $line;
if ($line m/^<!--VALUES:\+/)
{
$line =~ s/^<!--VALUES://;
$line =~ s/$-->//;
$values = $line;
################################  @arrline ??
@arrline = split(/&/,$values);
foreach $i (0 .. $#values) {
     $values[$i] =~ s/\+/ /g;
     ($key, $value) = split(/=/,$values[$i],2);
    $values{$key}  = $value;
$delar = 'OK';
}
}
} 

foreach $line (@filen)
{
chomp $line;
if ($line m/^<!--VALUE:\+/)
{
$line =~ s/^<!--VALUE://;
$line =~ s/$-->//;
$values2 = $line; 
($key, $value) = split(/=/,$values2);
$values{$value}  = $text; 
} 
}
##########################

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org