[22437] in Perl-Users-Digest
Perl-Users Digest, Issue: 4658 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 3 18:11:03 2003
Date: Mon, 3 Mar 2003 15:10:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 3 Mar 2003 Volume: 10 Number: 4658
Today's topics:
Re: recursively adding arrays of arrays <jhayden@usa.com>
Re: recursively adding arrays of arrays <abigail@abigail.nl>
Re: recursively adding arrays of arrays (Anno Siegel)
SUBSTR or pattern matching? impervious@attbi.com
Re: SUBSTR or pattern matching? (Tad McClellan)
Re: SUBSTR or pattern matching? impervious@attbi.com
Re: SUBSTR or pattern matching? (Walter Roberson)
Re: SUBSTR or pattern matching? impervious@attbi.com
Re: SUBSTR or pattern matching? <ethan@draupnir.gso.saic.com>
Re: SUBSTR or pattern matching? <tore@aursand.no>
Re: SUBSTR or pattern matching? <tore@aursand.no>
Re: SUBSTR or pattern matching? (Tad McClellan)
Text list to html files <greg@racquettech.com>
Re: Text list to html files (Tad McClellan)
Re: Text list to html files <greg@racquettech.com>
Re: Text list to html files (Tad McClellan)
write meta tags <pdhze@yahoo.co>
XML to HTML <ellem52@mail.com>
Re: XML to HTML <tore@aursand.no>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 3 Mar 2003 14:47:27 -0500
From: "ravlin" <jhayden@usa.com>
Subject: Re: recursively adding arrays of arrays
Message-Id: <jjO8a.129$DF5.3331@chrome-fe.eng.netapp.com>
Okay, I added the white space back in :) I was confused at first. If I
understand you correctly, is this how it would end up (I added a test5 line
for question below):
{
var1=var1 $testgroup[0]{'vars'}[0] =
"var1=var1"
var2=var2 $testgroup[0]{'vars'}[1] =
"var2=var2"
{ $testgroup[1]{}
{ $testgroup[2]{}
var3=var3 $testgroup[2]{'vars'}[0] =
"var3=var3"
test5 $testgroup[2]{'test'}[0] =
"test5"
{ $testgroup[3]{}
test1 $testgroup[3]{'test'}[0] =
"test1"
test2 $testgroup[3]{'test'}[1] =
"test2"
}
{ $testgroup[3]{}
}
}
{ $testgroup[2]{}
test3 $testgroup[2]{'test'}[0] =
"test3"
test4 $testgroup[2]{'test'}[1] =
"test4"
}
}
}
If this is right, there is one problem with it. var3 should only be valid
for test1, test2 and test5 since it's directly above test5 and the block.
But, if I'm reading it right, test3 and test4 are a part of testgroup
element2 along with var3. I would want to make sure var3 isn't valid for
test3 and test4. To make this less confusing, I added a test5. Wouldn't
test5 and test3 be the same even though the scope of those tests would be
different? Thanks for your help!
-Jon
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3E63A254.73916211@earthlink.net...
> ravlin wrote:
> [snip]
>
> How about you manually construct a bit of perl code which produces the
> same data structure as you want your sample data to produce.
>
> Your data was something like:
> {
> var1=var1
> var2=var2
> {
> { var3=var3
> { test1
> test2 }
> { } }
> { test3
> test4 } } }
>
> (Yes, I know I'm ommitting a lot of whitespace. So sue me.)
>
> I *think* (but am not entirely sure) that you want this to produce:
>
> my @testgroup = (
> { 'vars' => [ qw( var1=var1 var2=var2 ) ] },
> [ {},
> [ { 'vars' => [ qw( var3=var3 ) ] },
> [ { 'test' => [ qw( test1 test2 ) ] } ]
> [ ] ],
> [ { 'test' => [ qw( test3 test4 ) ] } ] ] );
>
> So, each level consists of a hashref (as it's first element), and, for
> each "{" ... "}" group immediately within it, an arrayref.
>
> Is this right?
>
>
> --
> $;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
> my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
> $__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: 03 Mar 2003 20:06:01 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: recursively adding arrays of arrays
Message-Id: <slrnb67dd9.n5i.abigail@alexandra.abigail.nl>
ravlin (jhayden@usa.com) wrote on MMMCDLXXI September MCMXCIII in
<URL:news:9pM8a.124$DF5.3515@chrome-fe.eng.netapp.com>:
{}
{} "Abigail" <abigail@abigail.nl> wrote in message
{} news:slrnb63rso.4ov.abigail@alexandra.abigail.nl...
{} > ravlin (jhayden@usa.com) wrote on MMMCDLXIX September MCMXCIII in
{} > <URL:news:pG28a.57211$If5.3162089@twister.southeast.rr.com>:
{} > ||
{} > || var2=2 # $testgroup[0]{'vars'}[1] = "var2=2"
{} >
{} > Ok, so $testgroup [0] is a reference to a hash.
{} >
{} > || { # $testgroup[0][0]
{} >
{} > But now, $testgroup [0] is a reference to an array.
{} >
{} > What's it going to be?
{}
{} Ah, yes, I see the dilema. I probably meant something like:
{}
{} $testgroup[0]{'vars'}[1] = "var2=2"
Ok, so $testgroup[0] is a reference to a hash.
{} and
{} $testgroup[0][1]
But now, $testgroup[0] is a reference to an array.
Wait. Didn't we do this already?
{} I guess, don't look so much at what the values should be. maybe a solution
{} or idea on how to solve my problem. How do I keep track of nested blocks of
{} data and to keep the data local to it's scope. I know this is a lot to
{} ask...sorry. Any pointers would be appreciated.
Perhaps you want YAML?
Abigail
--
perl -we 'eval {die ["Just another Perl Hacker\n"]}; print ${${@}}[$#{@{${@}}}]'
------------------------------
Date: 3 Mar 2003 20:48:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: recursively adding arrays of arrays
Message-Id: <b40f25$iqr$1@mamenchi.zrz.TU-Berlin.DE>
ravlin <jhayden@usa.com> wrote in comp.lang.perl.misc:
Please don't top-post. Put your reply where it belongs: below the
quoted text you're replying to.
> Okay, I added the white space back in :) I was confused at first. If I
^^^^^^^^^^^^^^^^^^^
Not sure if that's an improvement. Your lines are way too long.
> understand you correctly, is this how it would end up (I added a test5 line
> for question below):
>
> {
> var1=var1 $testgroup[0]{'vars'}[0] =
> "var1=var1"
> var2=var2 $testgroup[0]{'vars'}[1] =
> "var2=var2"
> { $testgroup[1]{}
> { $testgroup[2]{}
> var3=var3 $testgroup[2]{'vars'}[0] =
> "var3=var3"
> test5 $testgroup[2]{'test'}[0] =
> "test5"
> { $testgroup[3]{}
> test1 $testgroup[3]{'test'}[0] =
> "test1"
> test2 $testgroup[3]{'test'}[1] =
> "test2"
> }
> { $testgroup[3]{}
> }
> }
> { $testgroup[2]{}
> test3 $testgroup[2]{'test'}[0] =
> "test3"
> test4 $testgroup[2]{'test'}[1] =
> "test4"
> }
> }
> }
>
> If this is right, there is one problem with it. var3 should only be valid
> for test1, test2 and test5 since it's directly above test5 and the block.
> But, if I'm reading it right, test3 and test4 are a part of testgroup
> element2 along with var3. I would want to make sure var3 isn't valid for
> test3 and test4. To make this less confusing, I added a test5. Wouldn't
> test5 and test3 be the same even though the scope of those tests would be
> different? Thanks for your help!
>
> -Jon
>
> "Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
> news:3E63A254.73916211@earthlink.net...
> > ravlin wrote:
> > [snip]
> >
> > How about you manually construct a bit of perl code which produces the
> > same data structure as you want your sample data to produce.
One could go a step farther and ask why the OP doesn't construct a bit
of Perl code that actually runs the tests.
> > Your data was something like:
> > {
> > var1=var1
> > var2=var2
These used to be "var1=1", "var2=2", etc. I'm only mentioning it
because the change makes my simplistic solution below fail.
> > {
> > { var3=var3
> > { test1
> > test2 }
> > { } }
> > { test3
> > test4 } } }
> >
> > (Yes, I know I'm ommitting a lot of whitespace. So sue me.)
[snip]
That is almost Perl syntax. If we interpret the assignments as local
assignments to package variables, and "test1" etc. as calls to Perl
subs defined in terms of these variables, the calls to the tests happens
with just those assignments to the variables the OP has in mind.
The simplistic (and somewhat buggy) solution is to run
s/\b([[:alpha:]]\w*)\b(=\w+)?/$2 ? "local \$$1$2;" : "$1();"/eg;
over the text and eval() it.
A little more seriously, the specification could (with little change)
be written as a Perl program in the first place:
{
local $var1 = 1;
local $var2 = 2;
{ #...
{ test1();
Substituting different test routines, runs of this code could produce
reports about the settings or do the actual testing.
Anno
------------------------------
Date: Mon, 03 Mar 2003 20:45:30 GMT
From: impervious@attbi.com
Subject: SUBSTR or pattern matching?
Message-Id: <que76vctuialp9vo5hkvdeflrku8jd8mfv@4ax.com>
What is the best technique to use when trying to work with a string
that contains a date and you want to find the day? Ie. in a string
like this is want to find out that the day is the 25th:
12/25/2000 blah blah blah blah
However, for the single digit months, the line will read:
3/25/2000 blah acih jklm wish
So I can't use substr($_, 3, 2); in both cases because the day will be
offset by one depending on how many digits the month has. So my
question is, would pattern matching help solve this?
And how could I trim everything beyond the date and 'blah' to the end
of line so that I ended up with
3/25/2000 blah
------------------------------
Date: Mon, 3 Mar 2003 14:58:11 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: SUBSTR or pattern matching?
Message-Id: <slrnb67gf3.4da.tadmc@magna.augustmail.com>
impervious@attbi.com <impervious@attbi.com> wrote:
> What is the best technique to use when trying to work with a string
> that contains a date and you want to find the day? Ie. in a string
> like this is want to find out that the day is the 25th:
>
> 12/25/2000 blah blah blah blah
if ( my($mon, $day, $year) = m#^(\d\d?)/(\d\d?)/(\d{4})# ) {
print "day of the month is $day\n";
}
> And how could I trim everything beyond the date and 'blah' to the end
> of line so that I ended up with
>
> 3/25/2000 blah
s#^(\d\d?/\d\d?/\d{4} \S+).*#$1#;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 03 Mar 2003 21:26:32 GMT
From: impervious@attbi.com
Subject: Re: SUBSTR or pattern matching?
Message-Id: <3uh76vk711qqet502b0l0kt6954uf2e0td@4ax.com>
On Mon, 3 Mar 2003 14:58:11 -0600, tadmc@augustmail.com (Tad
McClellan) wrote:
> if ( my($mon, $day, $year) = m#^(\d\d?)/(\d\d?)/(\d{4})# ) {
> print "day of the month is $day\n";
> }
>
Thanks! Hadn't thought of that at all.
>> And how could I trim everything beyond the date and 'blah' to the end
>> of line so that I ended up with
>>
>> 3/25/2000 blah
>
>
> s#^(\d\d?/\d\d?/\d{4} \S+).*#$1#;
I understand the front part of that line, but am not sure how to
interpret this part ).*#$1#; Could you elaborate on exactly what
that is doing?
------------------------------
Date: 3 Mar 2003 21:27:43 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: SUBSTR or pattern matching?
Message-Id: <b40hcf$5vg$1@canopus.cc.umanitoba.ca>
In article <que76vctuialp9vo5hkvdeflrku8jd8mfv@4ax.com>,
<impervious@attbi.com> wrote:
:However, for the single digit months, the line will read:
:3/25/2000 blah acih jklm wish
:So I can't use substr($_, 3, 2); in both cases because the day will be
:offset by one depending on how many digits the month has.
substr($_, 2 + (substr($_, 1, 1) eq '/'), 2)
Of course this doesn't take into account the possibility that
the day itself might only have a single digit -- I'm just pointing
out that the objection you indicated is easily overcome.
--
"[...] it's all part of one's right to be publicly stupid." -- Dave Smey
------------------------------
Date: Mon, 03 Mar 2003 21:44:22 GMT
From: impervious@attbi.com
Subject: Re: SUBSTR or pattern matching?
Message-Id: <uvi76v04u7c959ti58vilro59o7bpd6t5v@4ax.com>
On 3 Mar 2003 21:27:43 GMT, roberson@ibd.nrc-cnrc.gc.ca (Walter
Roberson) wrote:
>:So I can't use substr($_, 3, 2); in both cases because the day will be
>:offset by one depending on how many digits the month has.
>
>substr($_, 2 + (substr($_, 1, 1) eq '/'), 2)
>
>Of course this doesn't take into account the possibility that
>the day itself might only have a single digit -- I'm just pointing
>out that the objection you indicated is easily overcome.
Thanks Walter.
Apparently, one of the nice things about Perl is that there is always
more than one way to do anything. It is so much richer than some of
the other languages I've programmed in but also that much harder to
learn. How in the world do you ever remember all the intricacies?
------------------------------
Date: 03 Mar 2003 14:09:34 -0800
From: Ethan Brown <ethan@draupnir.gso.saic.com>
Subject: Re: SUBSTR or pattern matching?
Message-Id: <vrel5okspt.fsf@draupnir.gso.saic.com>
>>>>> "impervious" == impervious <impervious@attbi.com> writes:
impervious> What is the best technique to use when trying to work with a string
impervious> that contains a date and you want to find the day? Ie. in a string
impervious> like this is want to find out that the day is the 25th:
impervious> 12/25/2000 blah blah blah blah
impervious> However, for the single digit months, the line will read:
impervious> 3/25/2000 blah acih jklm wish
impervious> So I can't use substr($_, 3, 2); in both cases because the day will be
impervious> offset by one depending on how many digits the month has. So my
impervious> question is, would pattern matching help solve this?
#!/usr/local/bin/perl -w
use strict;
my $str = '3/25/2000 blah acih jklm wish';
$str =~ m|^\d{1,2}/(\d{1,2}?)/|;
print "The day is $1\n" if $1;
impervious> And how could I trim everything beyond the date and 'blah' to the end
impervious> of line so that I ended up with
impervious> 3/25/2000 blah
$str =~ m|(^\d+/\d+/\d+\s+\S+)|;
print "The first stuff is $1\n" if $1;
Or if all lines have the form
MM/DD/YYYY blah acih jklm wish, just
$str =~ m/(^\S+\s+\S+)/;
print "The first stuff is $1\n" if $1;
--Ethan Brown
--In a band? Use http://www.WheresTheGig.com for free.
------------------------------
Date: Mon, 03 Mar 2003 23:23:34 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: SUBSTR or pattern matching?
Message-Id: <pan.2003.03.03.22.20.08.923592@aursand.no>
On Mon, 03 Mar 2003 20:45:30 +0000, imperviou wrote:
> 12/25/2000 blah blah blah blah
> 3/25/2000 blah acih jklm wish
if ( m,^(\d+)/(\d+)/(\d+), ) {
my $month = $1;
my $day = $2;
my $year = $3;
}
> And how could I trim everything beyond the date and 'blah' to
> the end of line so that I ended up with
> 3/25/2000 blah
s,^(\d+/\d+/\d+ \S+).*,$1,;
--
Tore Aursand - tore@aursand.no - http://www.aursand.no/
------------------------------
Date: Mon, 03 Mar 2003 23:23:34 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: SUBSTR or pattern matching?
Message-Id: <pan.2003.03.03.22.21.59.757686@aursand.no>
On Mon, 03 Mar 2003 21:44:22 +0000, imperviou wrote:
> Apparently, one of the nice things about Perl is that there is always
> more than one way to do anything. It is so much richer than some of the
> other languages I've programmed in but also that much harder to learn.
> How in the world do you ever remember all the intricacies?
You don't remember it; it all becomes a part of your instinct. It's a
lifestyle in the end.
That happens of course _after_ you've lost all your friends, your
girlfriend has left you, and when the closes thing to sex you'll ever get
is watching Baywatch. :)
--
Tore Aursand - tore@aursand.no - http://www.aursand.no/
------------------------------
Date: Mon, 3 Mar 2003 16:38:19 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: SUBSTR or pattern matching?
Message-Id: <slrnb67mar.4rd.tadmc@magna.augustmail.com>
impervious@attbi.com <impervious@attbi.com> wrote:
> On Mon, 3 Mar 2003 14:58:11 -0600, tadmc@augustmail.com (Tad
> McClellan) wrote:
>>> And how could I trim everything beyond the date and 'blah' to the end
>>> of line so that I ended up with
>>>
>>> 3/25/2000 blah
>>
>>
>> s#^(\d\d?/\d\d?/\d{4} \S+).*#$1#;
>
> I understand the front part of that line, but am not sure how to
> interpret this part ).*#$1#; Could you elaborate on exactly what
> that is doing?
Matching all of the stuff that you don't want while outside
of the capturing parenthesis, and then putting back in only
what _was_ inside of the capturing parenthesis.
I used s### instead of s/// so I wouldn't have to backslash the slashes.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 03 Mar 2003 20:17:31 GMT
From: Greg Raven <greg@racquettech.com>
Subject: Text list to html files
Message-Id: <3E63B85B.30607@racquettech.com>
I have a text file containing roughly 4,500 names of tennis players, and
their birthdates, in the form:
1|1|Javier Sanchez (1968)
1|1|Fang Li (1973)
...
12|31|Brook Buck (1985)
The list is already sorted by month number, then by day number within
that month, then by player name, and I can set the separators to be
pipes, commas, tabs, you-name-it.
What I would like is to be able to process this list using perl, so that
all the birthdays for January 1 (for example) are on an .html page
called 1-1.html, in a simple table form, and I'd like to be able to
generate these individual .html files with tables for all days of the
year with one command.
I don't know much perl, but I do know that this well within perl's
capabilities.
Any help will be greatly appreciated.
Thanks in advance.
Greg Raven (greg at racquettech dot com)
U.S. Racquet Stringers' Association
Del Mar, CA
------------------------------
Date: Mon, 3 Mar 2003 15:06:47 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Text list to html files
Message-Id: <slrnb67gv7.4da.tadmc@magna.augustmail.com>
Greg Raven <greg@racquettech.com> wrote:
> I have a text file containing roughly 4,500 names of tennis players, and
> their birthdates, in the form:
>
> 1|1|Javier Sanchez (1968)
> 1|1|Fang Li (1973)
> ...
> 12|31|Brook Buck (1985)
>
> The list is already sorted by month number, then by day number within
> that month, then by player name, and I can set the separators to be
> pipes, commas, tabs, you-name-it.
>
> What I would like is to be able to process this list using perl, so that
> all the birthdays for January 1 (for example) are on an .html page
> called 1-1.html,
--------------------------
#!/usr/bin/perl
use strict;
use warnings;
my $prev='';
while ( <DATA> ) {
chomp;
my($mon, $day, $player) = split m/\|/;
my $date = "$mon-$day";
if ( $date ne $prev ) {
open BDAY, ">$date.html" or die "could not open '$date.html' $!";
}
print BDAY "$player was born on $date\n";
$prev = $date;
}
__DATA__
1|1|Javier Sanchez (1968)
1|1|Fang Li (1973)
12|31|Brook Buck (1985)
--------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 03 Mar 2003 22:29:14 GMT
From: Greg Raven <greg@racquettech.com>
Subject: Re: Text list to html files
Message-Id: <3E63D735.1020005@racquettech.com>
--------------020604000102050007010105
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Thanks a million. This really put me back on track. I had hacked out
something that got only the first player for each month, and I wasn't
even to the part of writing it out to the file.
You didn't include it, but I assumed that DATA needs to be opened and
closed, so I added that code to what you provided. It runs blazingly
fast -- you gotta love perl.
I'll now set up some subroutines for the header and footer, and for the
table code. Formatting will be handled by CSS, so that's already done.
Again, thanks.
Tad McClellan wrote:
>Greg Raven <greg@racquettech.com> wrote:
>
>
>>I have a text file containing roughly 4,500 names of tennis players, and
>>their birthdates, in the form:
>>
>>1|1|Javier Sanchez (1968)
>>1|1|Fang Li (1973)
>>...
>>12|31|Brook Buck (1985)
>>
>>The list is already sorted by month number, then by day number within
>>that month, then by player name, and I can set the separators to be
>>pipes, commas, tabs, you-name-it.
>>
>>What I would like is to be able to process this list using perl, so that
>>all the birthdays for January 1 (for example) are on an .html page
>>called 1-1.html,
>>
>>
>
>
>--------------------------
>#!/usr/bin/perl
>use strict;
>use warnings;
>
>my $prev='';
>while ( <DATA> ) {
> chomp;
> my($mon, $day, $player) = split m/\|/;
> my $date = "$mon-$day";
>
> if ( $date ne $prev ) {
> open BDAY, ">$date.html" or die "could not open '$date.html' $!";
> }
>
> print BDAY "$player was born on $date\n";
> $prev = $date;
>}
>
>__DATA__
>1|1|Javier Sanchez (1968)
>1|1|Fang Li (1973)
>12|31|Brook Buck (1985)
>--------------------------
>
>
>
>
--
Greg Raven, MRT
U.S. Racquet Stringers Association
PO Box 40
Del Mar, CA 92014
858-481-3545 vox ext. 18
858-481-0624 fax
--------------020604000102050007010105
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body>
Thanks a million. This really put me back on track. I had hacked out something
that got only the first player for each month, and I wasn't even to the part
of writing it out to the file.<br>
<br>
You didn't include it, but I assumed that DATA needs to be opened and closed,
so I added that code to what you provided. It runs blazingly fast -- you
gotta love perl.<br>
<br>
I'll now set up some subroutines for the header and footer, and for the table
code. Formatting will be handled by CSS, so that's already done.<br>
<br>
Again, thanks.<br>
<br>
Tad McClellan wrote:<br>
<blockquote type="cite"
cite="midslrnb67gv7.4da.tadmc@magna.augustmail.com">
<pre wrap="">Greg Raven <a class="moz-txt-link-rfc2396E" href="mailto:greg@racquettech.com"><greg@racquettech.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I have a text file containing roughly 4,500 names of tennis players, and
their birthdates, in the form:
1|1|Javier Sanchez (1968)
1|1|Fang Li (1973)
...
12|31|Brook Buck (1985)
The list is already sorted by month number, then by day number within
that month, then by player name, and I can set the separators to be
pipes, commas, tabs, you-name-it.
What I would like is to be able to process this list using perl, so that
all the birthdays for January 1 (for example) are on an .html page
called 1-1.html,
</pre>
</blockquote>
<pre wrap=""><!---->
--------------------------
#!/usr/bin/perl
use strict;
use warnings;
my $prev='';
while ( <DATA> ) {
chomp;
my($mon, $day, $player) = split m/\|/;
my $date = "$mon-$day";
if ( $date ne $prev ) {
open BDAY, ">$date.html" or die "could not open '$date.html' $!";
}
print BDAY "$player was born on $date\n";
$prev = $date;
}
__DATA__
1|1|Javier Sanchez (1968)
1|1|Fang Li (1973)
12|31|Brook Buck (1985)
--------------------------
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="$mailwrapcol">--
Greg Raven, MRT
U.S. Racquet Stringers Association
PO Box 40
Del Mar, CA 92014
858-481-3545 vox ext. 18
858-481-0624 fax</pre>
<br>
</body>
</html>
--------------020604000102050007010105--
------------------------------
Date: Mon, 3 Mar 2003 16:49:49 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Text list to html files
Message-Id: <slrnb67n0d.4rd.tadmc@magna.augustmail.com>
Greg Raven <greg@racquettech.com> wrote:
>
> --------------020604000102050007010105
> Content-Type: text/plain; charset=us-ascii; format=flowed
> Content-Transfer-Encoding: 7bit
MIME in newsgroups makes less folks read what you have to say.
Consider turning that off for news.
> Thanks a million.
You're welcome.
You can pay me back by reading the Posting Guidelines that are
posted here frequently, and stop with the top-posting and full-quoting.
> You didn't include it, but I assumed that DATA needs to be opened and
> closed,
No, my program runs fine exactly as I posted it.
The DATA filehandle is special (the Posting Guidelines mention that too).
If you want to open a Real File then you should choose a filehandle
name *other* than DATA.
[snip TOFU]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 03 Mar 2003 20:55:50 GMT
From: piet <pdhze@yahoo.co>
Subject: write meta tags
Message-Id: <Usenet.nihkebrp@localhost>
I have a script which reads meta tags. and it looks like this
#!/usr/bin/perl -w
use strict;
use HTML::TreeBuilder 3;
use HTML::Headparser;
..
foreach my $file_name (<@ARGV>) {
my $tree = HTML::TreeBuilder->new;
$tree->parse_file($file_name);
my @meta = $tree->find_by_tag_name('meta');
my $p = HTML::HeadParser->new;
$p->parse_file($file_name);
for (@meta) {
if ($_->attr('name')) {
......
Now, I want to know how to write a tag with perl.
Is there a specific funtion for this?
Txs
Piet
------------------------------
Date: Mon, 03 Mar 2003 16:09:46 -0500
From: LM <ellem52@mail.com>
Subject: XML to HTML
Message-Id: <tsg76v80e16ofrbe0g1k2587ckpps1230e@4ax.com>
I have a 2.5 MB XML file I'd like to convert to HTML to be viewed in a
browser. (duh)
Several people have suggested Perl as being perfect for this I have
looked on CPAN and dl'd XML:XSLT.
Are there any other modules I will need to accomplish this task? And
do I have the right one to begin with?
--
There's more than one way to do it, but only some of them work
------------------------------
Date: Mon, 03 Mar 2003 23:23:34 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: XML to HTML
Message-Id: <pan.2003.03.03.22.22.58.182749@aursand.no>
On Mon, 03 Mar 2003 16:09:46 -0500, LM wrote:
> I have a 2.5 MB XML file I'd like to convert to HTML to be viewed in a
> browser. (duh)
Why don't you just (...) write a stylesheet for the XML file?
--
Tore Aursand - tore@aursand.no - http://www.aursand.no/
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4658
***************************************