[22454] in Perl-Users-Digest
Perl-Users Digest, Issue: 4675 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 6 14:11:24 2003
Date: Thu, 6 Mar 2003 11:10:12 -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 Thu, 6 Mar 2003 Volume: 10 Number: 4675
Today's topics:
Re: Print lines of file until certain string found? (Sara)
Re: Print lines of file until certain string found? <tzz@lifelogs.com>
Re: Print lines of file until certain string found? (Bulat Baltin)
Re: Print lines of file until certain string found? <usenet@dwall.fastmail.fm>
Re: printing hash values (Sara)
Re: printing hash values (Nataku)
Problem Implementing Sleep() Function - Need Help (DannyBoy)
Re: Problem Implementing Sleep() Function - Need Help <me@verizon.invalid>
Problem Implementing Sleep() Function (DannyBoy)
proposed revision to perlfaq4: expanding variables in s <tzz@lifelogs.com>
Re: proposed revision to perlfaq4: expanding variables <nospam@nospam.org>
Re: proposed revision to perlfaq4: expanding variables <nobull@mail.com>
Where to put html code in loop <usrsa@racquettech.com>
Re: Where to put html code in loop <me@verizon.invalid>
Re: Where to put html code in loop <usrsa@racquettech.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Mar 2003 09:49:54 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: Print lines of file until certain string found?
Message-Id: <776e0325.0303060504.34c496bc@posting.google.com>
genericax@hotmail.com (Sara) wrote in message news:<776e0325.0303051016.66d99dd9@posting.google.com>...
> mschaer@quantaservices.com (A. M. Schaer) wrote in message news:<cad2e56c.0303050725.7cde98a4@posting.google.com>...
> > What I am trying to do is have Perl open a file, print the lines of
> > the file until it encounters a marker, <!--perl-->, then stop
> > printing; however the code below doesn't do that; it just keeps
> > printing the first line of the file over and over again; I know
> > there's a flaw in my logic somewhere, but I just can't see it.
> >
> > Thanks.
> >
> > #!/usr/bin/perl
> > ###this doesnt do what I thought
> > $file="calexample.html";
> > open (CURRFILE, $file) ||
> > die ("Cant open file");
> > $var='<!--perl-->';
> >
> > while ($line= <CURRFILE>) {
> > #!~ does not match
> > #=~ matches
> > until ($line =~/$var/i)
> > {
> > print $line;
> > }
> > }
>
> Don' t think you really need that "until" clause inside a "while".
> Also shoot that $line var too while you're at it? In fact, let's just
> go with s nice tite once-liner:
>
> print until ( ($_ = <CURRFILE>) =~ /$var/i);
>
> -Gx
Sorry I forgot one thing- if you need to protect $_, you can localize
it:
print until ( (local $_ = <CURRFILE>) =~ /$var/i);
^
Useful if you need to use $_ from some previous expession, or if
you're already in another loop.
Cheers,
Gx
------------------------------
Date: Thu, 06 Mar 2003 13:10:39 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Print lines of file until certain string found?
Message-Id: <4nvfyw1i3k.fsf@lockgroove.bwh.harvard.edu>
On 5 Mar 2003, mschaer@quantaservices.com wrote:
> What I am trying to do is have Perl open a file, print the lines of
> the file until it encounters a marker, <!--perl-->, then stop
> printing; however the code below doesn't do that; it just keeps
> printing the first line of the file over and over again; I know
> there's a flaw in my logic somewhere, but I just can't see it.
Learn the basic Perl switches (-p and -n most of all) -
"perldoc perlrun". They will simplify your life greatly. Call the
script below with the name of the file you want to process.
#!/usr/bin/perl -p
# this doesn't have to be in a BEGIN block, but then it will be
# executed for every line you process
BEGIN { $marker = '<!--perl-->' }
exit if m/$marker/;
Ted
------------------------------
Date: 6 Mar 2003 10:10:40 -0800
From: bulat@cn.donetsk.ua (Bulat Baltin)
Subject: Re: Print lines of file until certain string found?
Message-Id: <9136cc7f.0303060754.1529a1ec@posting.google.com>
mschaer@quantaservices.com (A. M. Schaer) wrote in message news:<cad2e56c.0303050725.7cde98a4@posting.google.com>...
> What I am trying to do is have Perl open a file, print the lines of
> the file until it encounters a marker, <!--perl-->, then stop
> printing; however the code below doesn't do that; it just keeps
> printing the first line of the file over and over again; I know
> there's a flaw in my logic somewhere, but I just can't see it.
>
> Thanks.
>
> #!/usr/bin/perl
> ###this doesnt do what I thought
> $file="calexample.html";
> open (CURRFILE, $file) ||
> die ("Cant open file");
> $var='<!--perl-->';
>
> while ($line= <CURRFILE>) {
> #!~ does not match
> #=~ matches
> until ($line =~/$var/i)
> {
> print $line;
> }
> }
You have to use 'unless' instead of 'until'. 'until' is a loop by
itself that's why you get stuck in it.
Regards,
Bulat Baltin.
------------------------------
Date: Thu, 06 Mar 2003 18:58:02 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Print lines of file until certain string found?
Message-Id: <Xns93368E14F546dkwwashere@216.168.3.30>
Sara <genericax@hotmail.com> wrote on 06 Mar 2003:
> Sorry I forgot one thing- if you need to protect $_, you can
> localize it:
>
> print until ( (local $_ = <CURRFILE>) =~ /$var/i);
> ^
>
> Useful if you need to use $_ from some previous expession, or if
> you're already in another loop.
Granted, but I think I'd rather use a new lexical variable than try to
remember which copy of $_ I'm using.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: 6 Mar 2003 09:51:04 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: printing hash values
Message-Id: <776e0325.0303060515.58ef1271@posting.google.com>
dwlepage@yahoo.com (david) wrote in message news:<b09a22ae.0303051922.4654a4eb@posting.google.com>...
> If I have lexical values:
> my ($keyname, $keyvalue, $search, $replace);
> my %uid ();
>
> What would be the best way to print the contents of my hash once it
> has been populated? I am new to perl and am having a hard time
> visualizing the whole hash concept. Any suggestions?
> Thanks,
You don't really say what the hash contains. If it's just keys and
scalar values, then you can use Tad's suggestion and use the simple
loop.
However, a hash can also contain references to other data structures
such as arrays and other hashes, which in turn can contain references,
etc. In those cases, "data dumper" can be useful, or if you know the
structure, you can "roll your own" custom dump.
HOWEVER, if all you want to do is INSPECT the contents of the hash,
and not necessarily print it as part of your requirements, then I
suggest you just use
#!/usr/bin/perl -wd
^
which will drag the code into the debugger. Place a break at a line
after the hash is populated, and type:
db> x %uid
or
db> x keys %uid
or
db> x sort keys %uid
or .. whatever you need...
The debugger will pull apart pretty much any structure and present it
to you in a nice format. If you're new to perl, I recommend you learn
the debugger. With only a few commands, mainly "c", "x", "b", "n", and
"s" you can really see how your code is working. It will save you
hours of analysis. Trust me my only regret with perl debugging is that
I starting using it too late in my Perl career..
Good luck,
Gx
------------------------------
Date: 6 Mar 2003 10:10:35 -0800
From: Crapnut566@yahoo.com (Nataku)
Subject: Re: printing hash values
Message-Id: <7e48fc99.0303060753.51a2b63c@posting.google.com>
There is always the old fashioned way.
while( my( $key, $value ) = each %HASH ){
print "$key => $value\n";
}
The <each> function returns a new key/value pair each time around the
loop. Also possible :
foreach my $key ( keys %HASH ){
print "$key => $HASH{$key}\n";
}
Slightly more intuitive, but less efficient, as the <keys> operator
returns ALL they keys of the hash at once in a big list. If you have
a huge hash its probably better to use each - unless you have a bug
chunk of RAM you dont mind throwing to perl.
Chris Lowth <dont@want.spam> wrote in message news:<6gD9a.76$rB4.23651@newsfep1-win.server.ntli.net>...
> david wrote:
>
> > If I have lexical values:
> > my ($keyname, $keyvalue, $search, $replace);
> > my %uid ();
> >
> > What would be the best way to print the contents of my hash once it
> > has been populated? I am new to perl and am having a hard time
> > visualizing the whole hash concept. Any suggestions?
> > Thanks,
>
> For "visualising" the hash contents (for debugging, checking etc) I use
> "Data::Dumper". Use it like this..
>
> use Data::Dumper;
> my %uid = ( );
>
> .. code to populate %uid ..
>
> print Dumper( \%uid );
>
> Chris
------------------------------
Date: 6 Mar 2003 09:53:43 -0800
From: dan4606@hotmail.com (DannyBoy)
Subject: Problem Implementing Sleep() Function - Need Help
Message-Id: <6d72f570.0303060953.361274f8@posting.google.com>
Hello Everyone,
I'm trying to write a small script that will run another script that
performs a certain function. I want it to run and then sleep for about
120 seconds. so far I've been having problems implementing this. I'm
using ActivePerl 5.8.0.805. My code looks like this:
#!/usr/local/bin/perl -w
use strict;
my $file = "C:\\WINNT\\system32\\perl\\perlstat.pl";
while (1) {
print 'Sleeping...', scalar localtime;
do `$file`;
sleep 120;
print 'slept. ', scalar localtime, "\n";
}
When I run the script the output looks like this:
C:\>C:\WINNT\system32\perl\pstatservice.pl
Sleeping...Thu Mar 6 12:00:29 2003Null filename used at
C:\WINNT\system32\perl\
pstatservice.pl line 11.
the pstatservice.pl script calls another script that generates an html
file. This html file is generated one time which means the script runs
once but then it encounters that error. I haven't been able to figure
out why I get this or how to fix the problem.
Thanks
Dan
------------------------------
Date: Thu, 06 Mar 2003 18:12:31 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: Problem Implementing Sleep() Function - Need Help
Message-Id: <jcM9a.26389$8f7.8901@nwrdny02.gnilink.net>
"DannyBoy" <dan4606@hotmail.com> wrote in message
news:6d72f570.0303060953.361274f8@posting.google.com...
> my $file = "C:\\WINNT\\system32\\perl\\perlstat.pl";
> while (1) {
> print 'Sleeping...', scalar localtime;
> do `$file`;
You probably want to use double quotes:
do "$file";
or eliminate the do:
`$file`;
Using backticks will result in executing $file and returns the stdout. If
$file doesn't print anything to stdout, and then you are left with:
do '';
------------------------------
Date: 6 Mar 2003 10:58:44 -0800
From: dan4606@hotmail.com (DannyBoy)
Subject: Problem Implementing Sleep() Function
Message-Id: <6d72f570.0303061058.1e85a021@posting.google.com>
I've been having truoble implementing this perl script:
#!/usr/local/bin/perl -w
use strict;
$| = 1;
my $file = "C:\\WINNT\\system32\\perl\\perlstat.pl";
while (1) {
print 'Sleeping...', scalar localtime;
do `$file`;
sleep 120;
print 'slept. ', scalar localtime, "\n";
}
The command to run it and the output is as follows:
C:\>C:\WINNT\system32\perl\pstatservice.pl
Sleeping...Thu Mar 6 13:56:24 2003Null filename used at
C:\WINNT\system32\perl\
pstatservice.pl line 11.
I'm using Active perl 5.8 for win32 systems. pstatservice.pl is a
script that simple calls another script to run and then sleeps for a
given time interval. This script works the first time around but then
generates taht error and exits. Any help would be appreciated.
Thanks,
Dan
------------------------------
Date: Thu, 06 Mar 2003 12:07:20 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: proposed revision to perlfaq4: expanding variables in strings
Message-Id: <4nfzq04e5z.fsf_-_@lockgroove.bwh.harvard.edu>
On Thu, 6 Mar 2003, nospam@nospam.org wrote:
> "Brian McCauley" <nobull@mail.com> wrote in message
> news:u9el5k96sf.fsf@wcl-l.bham.ac.uk...
>> "Christian Caron" <nospam@nospam.org> writes:
>>
>> > but I would want:
>> >
>> > "Hello, somename" (because $username can be assigned to any
>> > names).
>>
>> This is FAQ: "How can I expand variables in text strings?"
>>
>> Can you please advise us how the question could have been better
>> phrased so that you would not have missed it when you checked the
>> FAQ? (I'm assuming you were not too selfish/lazy to bother looking
>> in the FAQ before you posted)
>>
>
> My English is not so bad, but I do not often use words like
> "expand". Anyway, when I checked it, I saw it was related to
> regular expressions (replace), not "interpolation" (is that the
> right word?), so I was confused about how it could have helped me.
>
> I think Ted's answer to use sprintf and/or printf was a good idea
> (it worked for me).
Hrm, I have to agree here, the FAQ is a little misguiding here. I'm
sure a newbie would *love* to learn all about s/\$(\w+)/${$1}/g and
s/(\$\w+)/$1/eeg (substitutions mentioned in the answer to this FAQ),
but even the "general" solution of s/\$(\w+)/$user_defs{$1}/g with a
%user_defs hash is too complex (and I would not recommend it over the
equivalent sprintf in a million years).
Granted, the answer "use sprintf or printf" does not answer the FAQ
itself, but in 95% of the cases it will help those who read the FAQ
entry. So I left the original suggestions in place.
Working with:
perlfaq4 - Data Manipulation ($Revision: 1.25 $, $Date: 2002/05/30 07:04:25 $)
I would propose the patch appended here. Please comment before I go
and bother people with it :)
Thanks
Ted
--- perlfaq4.pod.original 2003-03-06 12:15:06.000000000 -0500
+++ perlfaq4.pod 2003-03-06 12:17:24.000000000 -0500
@@ -904,6 +904,19 @@
$text = 'this has a $foo in it and a $bar';
+First of all, are you sure you can't use sprintf and printf? For
+general formatting, they are very useful. For instance, you
+could expand $foo and $bar in the example above like so:
+
+ $text = sprintf('this has a %s in it and a %s', $foo, $bar);
+
+Essentially, sprintf formats a string with placeholders such as
+%s, replacing the placeholders with actual data. See the
+sprintf() documentation (perldoc -f sprintf) for more information.
+
+If you really want to expand (interpolate) the data in $text, you
+could try substitution.
+
If those were both global variables, then this would
suffice:
------------------------------
Date: Thu, 6 Mar 2003 13:19:16 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: Re: proposed revision to perlfaq4: expanding variables in strings
Message-Id: <b483f4$ham3@nrn2.NRCan.gc.ca>
"Ted Zlatanov" <tzz@lifelogs.com> wrote in message
news:4nfzq04e5z.fsf_-_@lockgroove.bwh.harvard.edu...
> On Thu, 6 Mar 2003, nospam@nospam.org wrote:
> > "Brian McCauley" <nobull@mail.com> wrote in message
> > news:u9el5k96sf.fsf@wcl-l.bham.ac.uk...
> >> "Christian Caron" <nospam@nospam.org> writes:
> >> Can you please advise us how the question could have been better
> >> phrased so that you would not have missed it when you checked the
> >> FAQ? (I'm assuming you were not too selfish/lazy to bother looking
> >> in the FAQ before you posted)
> >>
> >
> > My English is not so bad, but I do not often use words like
> > "expand". Anyway, when I checked it, I saw it was related to
> > regular expressions (replace), not "interpolation" (is that the
> > right word?), so I was confused about how it could have helped me.
> >
> I would propose the patch appended here. Please comment before I go
> and bother people with it :)
>
> Thanks
> Ted
>
> --- perlfaq4.pod.original 2003-03-06 12:15:06.000000000 -0500
> +++ perlfaq4.pod 2003-03-06 12:17:24.000000000 -0500
> @@ -904,6 +904,19 @@
>
> $text = 'this has a $foo in it and a $bar';
>
> +First of all, are you sure you can't use sprintf and printf? For
> +general formatting, they are very useful. For instance, you
> +could expand $foo and $bar in the example above like so:
> +
> + $text = sprintf('this has a %s in it and a %s', $foo, $bar);
> +
> +Essentially, sprintf formats a string with placeholders such as
> +%s, replacing the placeholders with actual data. See the
> +sprintf() documentation (perldoc -f sprintf) for more information.
> +
> +If you really want to expand (interpolate) the data in $text, you
> +could try substitution.
> +
> If those were both global variables, then this would
> suffice:
That is a perfect answer to me. I would see that in the FAQ, and it would
answer my question right away.
Thanks!
------------------------------
Date: 06 Mar 2003 18:35:45 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: proposed revision to perlfaq4: expanding variables in strings
Message-Id: <u9llzs737i.fsf@wcl-l.bham.ac.uk>
Ted Zlatanov <tzz@lifelogs.com> writes:
> On Thu, 6 Mar 2003, nospam@nospam.org wrote:
> > "Brian McCauley" <nobull@mail.com> wrote in message
> > news:u9el5k96sf.fsf@wcl-l.bham.ac.uk...
> >> "Christian Caron" <nospam@nospam.org> writes:
> >>
> >> > but I would want:
> >> >
> >> > "Hello, somename" (because $username can be assigned to any
> >> > names).
> >>
> >> This is FAQ: "How can I expand variables in text strings?"
> >>
> >> Can you please advise us how the question could have been better
> >> phrased so that you would not have missed it when you checked the
> >> FAQ?
> >
> > My English is not so bad, but I do not often use words like
> > "expand". Anyway, when I checked it, I saw it was related to
> > regular expressions (replace), not "interpolation" (is that the
> > right word?), so I was confused about how it could have helped me.
Valid point - the question really should contain some variation on the
word 'interpolate'.
> > I think Ted's answer to use sprintf and/or printf was a good idea
> > (it worked for me).
>
> Hrm, I have to agree here, the FAQ is a little misguiding here. I'm
> sure a newbie would *love* to learn all about s/\$(\w+)/${$1}/g and
> s/(\$\w+)/$1/eeg (substitutions mentioned in the answer to this FAQ),
> but even the "general" solution of s/\$(\w+)/$user_defs{$1}/g with a
> %user_defs hash is too complex (and I would not recommend it over the
> equivalent sprintf in a million years).
>
> Granted, the answer "use sprintf or printf" does not answer the FAQ
> itself, but in 95% of the cases it will help those who read the FAQ
> entry.
I disagree - I'd not expect it to be of help in more than 20% of
cases. Also it's not the answer to the question.
> So I left the original suggestions in place.
When we last discussed this (thread "interpolation function?" in
comp.lang.perl.moderated last month) Brian "perlfaq" D Foy gave the
impression that he didn't want this answer to get too bloated.
I would therefore try to keep it short.
> I would propose the patch appended here. Please comment before I go
> and bother people with it :)
The main criticism of that patch is that it still doesn't give the
'right' answer to the question 'how do I subject the contents of a
variable to processing by the Perl interpolation engine?'. I'm sure
that most people to whom this FAQ is relevant would think that this
is the question they are asking. (I'm not saying they'd understand
what they were asking well enought to necessary come up with those
words).
Now, in some cases, the answer that's currently in the FAQ, or the
"use sprintf" answers would actually serve them better than the answer
to the question that they think they need to ask. Buy there's still a
significant fraction who are asking the right question and the current
FAQ's refusal to anser it is perverse.
I would replace the question completely...
How can I expand/interpolate variables in text strings?
$text = 'this has a $foo in it...\n ...and a $bar';
# Assume $text does not contain "\nEND\n"
chop ( $text = chop "<<END\n$text\nEND\n" );
die if $@;
This is dangerous if the text comes form an untrusted
source, consider:
$text = '@{[ system "rm -rf /" ]}';
If you only need to process simple scalars then you can do
limit the parts of the string that are passed to eval()
like this:
$text =~ s/(\$\w+)/$1/eeg;
die if $@; # needed /ee, not /e
This still gives unrestricted access to your scalar vari-
ables. It is often better to use a hash:
%user_defs = (
foo => 23,
bar => 19,
);
$text =~ s/\$(\w+)/$user_defs{$1}/g;
For other variations on the theme of text templates see
the sprintf() function and numerous modules on CPAN.
As a diff against 5.8.0...
--- perlfaq4.pod Thu Mar 6 18:03:55 2003
+++ perlfaq4-bam.pod Thu Mar 6 18:28:36 2003
@@ -539,6 +539,9 @@
This won't expand C<"\n"> or C<"\t"> or any other special escapes.
+See also ``How can I expand/interpolate variables in text strings?'' in this
+section of the FAQ.
+
=head2 How do I remove consecutive pairs of characters?
To turn C<"abbcccd"> into C<"abccd">:
@@ -565,7 +568,7 @@
Version 5.004 of Perl had a bug that gave list context to the
expression in C<${...}>, but this is fixed in version 5.005.
-See also ``How can I expand variables in text strings?'' in this
+See also ``How can I expand/interpolate variables in text strings?'' in this
section of the FAQ.
=head2 How do I find matching/nesting anything?
@@ -898,25 +901,26 @@
If Text::Soundex does not do what you are looking for, you might want
to consider the String::Approx module available at CPAN.
-=head2 How can I expand variables in text strings?
-
-Let's assume that you have a string like:
+=head2 How can I expand/interpolate variables in text strings?
- $text = 'this has a $foo in it and a $bar';
+ $text = 'this has a $foo in it...\n ...and a $bar';
+ # Assume $text does not contain "\nEND\n"
+ chop ( $text = chop "<<END\n$text\nEND\n" );
+ die if $@;
-If those were both global variables, then this would
-suffice:
+This is dangerous if the text comes form an untrusted source,
+consider:
- $text =~ s/\$(\w+)/${$1}/g; # no /e needed
+ $text = '@{[ system "rm -rf /" ]}';
-But since they are probably lexicals, or at least, they could
-be, you'd have to do this:
+If you only need to process simple scalars then you can do limit the
+parts of the string that are passed to eval() like this:
$text =~ s/(\$\w+)/$1/eeg;
die if $@; # needed /ee, not /e
-It's probably better in the general case to treat those
-variables as entries in some special hash. For example:
+This still gives unrestricted access to your scalar variables. It is
+often better to use a hash:
%user_defs = (
foo => 23,
@@ -924,8 +928,8 @@
);
$text =~ s/\$(\w+)/$user_defs{$1}/g;
-See also ``How do I expand function calls in a string?'' in this section
-of the FAQ.
+For other variations on the theme of text templates see the sprintf()
+function and numerous modules on CPAN.
=head2 What's wrong with always quoting "$vars"?
------------------------------
Date: 06 Mar 2003 17:30:49 GMT
From: Greg Raven <usrsa@racquettech.com>
Subject: Where to put html code in loop
Message-Id: <usrsa-E5B574.09304806032003@spectator.sj.sys.us.xo.net>
I have (thanks to Tad McClellan and this newsgroup) a bit of perl code
that takes a pipe-delimited text file and breaks it into 366 html
separate html files. However, I am having difficulty adding in the html
code for the end of each html page. If I put it immediately after:
$prev = $ date;
... it writes the "closing" code (shown below in the &bodyend
subroutine) after each line it gets from the text file, which is no
good. If I have it as shown below, the "closing" html code is written
only to the last file -- that is, for December 31.
I suspect I need another while statement, but I've been unable to come
up with one that works.
(You will note that I have omitted the other subroutines that initialize
the html, write the <title>, start the <body>, and start the table, and
the references to those subroutines in the body of the code.)
#!/usr/bin/perl
use strict;
use warnings;
my $prev='';
while ( <DATA> ) {
chomp;
my($monthNumber, $day, $monthName, $player) = split m/\|/;
my $date = "$monthNumber-$day";
if ( $date ne $prev ) {
open BDAY, ">$date.html" or die "could not open '$date.html' $!";
print BDAY "$monthName $day";
print BDAY "$monthName $day";
}
print BDAY "$player";
$prev = $date;
}
&bodyend;
sub bodyend {
print BDAY <<EOD;
</table></td></tr></table>
</div>
</body>
</html>
EOD
}
__DATA__
1|1|January|Javier Sanchez (1968)
1|1|January|Fang Li (1973)
1|1|January|Leos Friedl (1977)
12|31|December|George Clifford Richey (1946)
12|31|December|Antonia Matic (1984)
12|31|December|Brook Buck (1985)
------------------------------
Date: Thu, 06 Mar 2003 17:41:05 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: Where to put html code in loop
Message-Id: <RKL9a.26379$8f7.17984@nwrdny02.gnilink.net>
"Greg Raven" <usrsa@racquettech.com> wrote in message
news:usrsa-E5B574.09304806032003@spectator.sj.sys.us.xo.net...
> my $date = "$monthNumber-$day";
>
> if ( $date ne $prev ) {
if ($prev ne '') {
&bodyend;
close BDAY;
}
> open BDAY, ">$date.html" or die "could not open '$date.html' $!";
> print BDAY "$monthName $day";
I would suggest adding the code above, printing the end of the html, then
closing the file.
------------------------------
Date: 06 Mar 2003 17:54:44 GMT
From: Greg Raven <usrsa@racquettech.com>
Subject: Re: Where to put html code in loop
Message-Id: <usrsa-7C5319.09544406032003@spectator.sj.sys.us.xo.net>
In article <RKL9a.26379$8f7.17984@nwrdny02.gnilink.net>,
"dw" <me@verizon.invalid> wrote:
> "Greg Raven" <usrsa@racquettech.com> wrote in message
> news:usrsa-E5B574.09304806032003@spectator.sj.sys.us.xo.net...
> > my $date = "$monthNumber-$day";
> >
> > if ( $date ne $prev ) {
>
>
> if ($prev ne '') {
> &bodyend;
> close BDAY;
> }
>
> > open BDAY, ">$date.html" or die "could not open '$date.html' $!";
> > print BDAY "$monthName $day";
>
> I would suggest adding the code above, printing the end of the html, then
> closing the file.
That works. I couldn't figure out what to check for to add the code at
the "beginning" of the loop, so I was trying to add it at various places
in various ways at the end of the loop -- with no success. Thanks!
--
Greg Raven (greg at racquettech dot com)
U.S. Racquet Stringers Association
Solana Beach, CA
------------------------------
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 4675
***************************************