[22636] in Perl-Users-Digest
Perl-Users Digest, Issue: 4857 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 17 09:05:53 2003
Date: Thu, 17 Apr 2003 06:05:09 -0700 (PDT)
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, 17 Apr 2003 Volume: 10 Number: 4857
Today's topics:
approximate substitution <ubl@schaffhausen.de>
Re: Can I die and also write to a log file? (Anno Siegel)
Re: Can I use a hash slice through an anonymous hashref (Sara)
Re: Can I use a hash slice through an anonymous hashref (Sara)
Re: CGI Error "unitialized constant" Help <nobull@mail.com>
Re: changing qx{} shell <w.koenig@acm.org>
Re: conditional 'use' <nobull@mail.com>
Re: conditional 'use' <Andrew.McGregor@amtrak.co.uk>
embedded Perl in C++: Crash when Dynaloader wants to lo <mail@thomaskuhn.de>
foreach how do I get out of the loop? sthg like "break; (milka)
Re: foreach how do I get out of the loop? sthg like "br <ubl@schaffhausen.de>
Re: foreach how do I get out of the loop? sthg like "br <bigus AT creationfactor DOT net>
Re: foreach how do I get out of the loop? sthg like "br <Andrew.McGregor@amtrak.co.uk>
Re: foreach how do I get out of the loop? sthg like "br <bernard.el-hagin@DODGE_THISlido-tech.net>
How to read one line from a text file (Francesco Moi)
Re: How to run Perl code ? <bart.lateur@pandora.be>
Re: How to run Perl code ? <gzm@citiz.net>
killing unix processes by name ... <as@hotmail.com>
Re: killing unix processes by name ... <ian@WINDOZEdigiserv.net>
Re: My 1st japh!! <bik.mido@tiscalinet.it>
Re: Nesting tables with perl CGI <nobull@mail.com>
Re: Nesting tables with perl CGI <Andrew.McGregor@amtrak.co.uk>
Re: New Perl Beginners Site <bigus AT creationfactor DOT net>
Re: New Perl Beginners Site <bart.lateur@pandora.be>
Re: newbie:substitution in a variable name (Anno Siegel)
Re: regexp. for a two dates delimited with a minus <FizgigNO@SPAMequanimityREMOVETHISTO.nl>
Re: regexp. for a two dates delimited with a minus (Anno Siegel)
Re: Stumped! <nobull@mail.com>
Re: Why is this expression so slow?? (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 17 Apr 2003 11:00:54 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: approximate substitution
Message-Id: <b7ltlj$9p3$1@news.dtag.de>
Hi,
I was playing around a little with different approximate substitution
methods. What I want to achieve in the end is to search user input for
strings that look like entries in a database and wrap those string with
HTML links containing the corresponding record id.
An example would be this:
%word2id = ( "some String" => 200 );
input: just some text including same Sting bla bla
output: just talking some <a href="200.html">same Sting</a> bla bla
The concrete application is for use in an online forum about roses and
here is some of the code I came up with:
<code>
use strict;
use String::Approx 'asubstitute';
my %roses = (
"Aachener Dom" => 1,
);
my $text = <>;
foreach my $rose (keys %roses) {
if(my($replaced) = asubstitute($rose, qq{<a
href="$roses{$rose}">\$&</a>}, ["g", "i"], $text)) {
$text = $replaced
}
}
print $text;
</code>
Unfortunately, either my brain or String::Approx substitution seems to
be a bit buggy because sometimes if there is no more text after a fuzzy
match, then the text in the replacement after the magic var $& is not
inserted into the resulting text:
Here is some input and output:
bash-2.05a$ perl fuzzy_roses.pl
nur ein test aacherner dom und mehr worte
nur ein test <a href="1">aacherner dom </a>und mehr worte
bash-2.05a$ perl fuzzy_roses.pl
nur ein test aacherner dom
nur ein test <a href="1">aacherner dom
Maybe I should split my input into strings of words that can be
candidates for a fuzzy match (e.g. for a 2 word pattern, match the
pattern against any 2 words in the input string). That would also
eliminate the problem, that the fuzzy match (especially if the matching
word is actually an exact match) sometimes includes characters from
other words surrounding the matching string.
Hmm, I just wanted to ask, whether anybody knows of a better algorithm
to do this kind of stuff or even better a module that does what I want.
Thanx,
->malte
------------------------------
Date: 17 Apr 2003 10:36:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Can I die and also write to a log file?
Message-Id: <b7m02r$gq0$1@mamenchi.zrz.TU-Berlin.DE>
Sherman Willden <sherman.willden@hp.com> wrote in comp.lang.perl.misc:
> Can I use die and also write to a log file? I am using perl perl,
> v5.6.1 built for MSWin32-x86-multi-thread
>
> I quit using die because I had to also write to a log file. I am also
> generating a message that indicates the script and the line number as
> shown in _Progamming Perl, 2nd Edition_, page 157. So I open an error
> log (EL) and write to it like the if statement shown below.
> if ( "$DIR" eq "" ) {
> print '"', __FILE__, '", line, ', __LINE__, ", Unknown directory
> $DIR\n";
> print EL '"', __FILE__, '", line, ', __LINE__, ", Unknown
> directory $DIR\n";
> print "Exiting $0\n";
> print EL "Exiting $0\n";
> close(EL);
> exit 1;
> }
>
> This results in the below message:
> "C:\BuildScripts\V2.1A\Windows\TryExit.pl", line, 15, Unknown
> directory C:\mydir
>
> Is there an easier way?
You can use an "END {}" block to issue a final log message. "END" is
executed whenever your program exits, whether normally, through die()
or even through exit(). The only exceptions are uncaught signals,
and leaving the program through exec().
Anno
------------------------------
Date: 17 Apr 2003 05:40:30 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Can I use a hash slice through an anonymous hashref?
Message-Id: <776e0325.0304170440.62b9c5c4@posting.google.com>
Bart Lateur <bart.lateur@pandora.be> wrote in message news:<p9br9v06djnmpvghj8cmdhsqvh1pjahatr@4ax.com>...
> Sara wrote:
>
> > It seems sort of strange that we write
> >
> > $href->{cat}=1; # for a hashref
> > $href{cat} =1; # for a hash
> >
> >but for slices, the -> vanishes.
>
> Yes and no. The -> is a special syntax that, unfortunately cannot be
> used for slices. But you can still access a single item in a hashref in
> the same syntax as the slices, so the "->" syntax is the special case,
> really:
>
> @{$h}{@keys} = @values;
>
> ${$h}{$key} = $value;
>
> The latter is the same as
>
> $h->{$key} = $value;
Bart & Uri:
Thanks for the details, I do recall in Camel that -> was termed
"syntactical sugar" as you suggested, but as you point out it doesn't
extend to slices.
As you point out, Uri, P6 will make hash notation clearer.
Cheers!
Gx
------------------------------
Date: 17 Apr 2003 05:40:42 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Can I use a hash slice through an anonymous hashref?
Message-Id: <776e0325.0304170440.50af7219@posting.google.com>
Bart Lateur <bart.lateur@pandora.be> wrote in message news:<p9br9v06djnmpvghj8cmdhsqvh1pjahatr@4ax.com>...
> Sara wrote:
>
> > It seems sort of strange that we write
> >
> > $href->{cat}=1; # for a hashref
> > $href{cat} =1; # for a hash
> >
> >but for slices, the -> vanishes.
>
> Yes and no. The -> is a special syntax that, unfortunately cannot be
> used for slices. But you can still access a single item in a hashref in
> the same syntax as the slices, so the "->" syntax is the special case,
> really:
>
> @{$h}{@keys} = @values;
>
> ${$h}{$key} = $value;
>
> The latter is the same as
>
> $h->{$key} = $value;
Bart & Uri:
Thanks for the details, I do recall in Camel that -> was termed
"syntactical sugar" as you suggested, but as you point out it doesn't
extend to slices.
As you point out, Uri, P6 will make hash notation clearer.
Cheers!
Gx
------------------------------
Date: 17 Apr 2003 08:40:43 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: CGI Error "unitialized constant" Help
Message-Id: <u9n0ip8tc4.fsf@wcl-l.bham.ac.uk>
tadmc@augustmail.com (Tad McClellan) writes:
> Hyzer <mchyzer@yahoo.com> wrote:
>
> > Subject: CGI Error "unitialized constant" Help
> ^^^^^^^^^^^^^^^^^^^^
>
> There is no such Perl message...
>
>
> > [Wed Apr 16 19:39:45 2003] null: Use of uninitialized value in concatenation
> > (.) at Gizmo/Table.pm line 615.
> >
> > I checked this particular case, and there is no way that the variable is
> > unitialized,
>
>
> Yes there is, you just aren't seeing it.
Er, actually the OP is making the normal error in reading this
message.
The message says "uninitialized value".
This is not IMNSHO a meaningful concept.
The OP is subconciously changing it to "uninitialized variable".
It should, in fact, be read as "undefined value".
In some cases an uninitialized variable is the source of the
undefined value, but there are, also, many other possibilities.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 17 Apr 2003 13:42:35 +0200
From: Winfried Koenig <w.koenig@acm.org>
Subject: Re: changing qx{} shell
Message-Id: <3E9E932B.8030905@acm.org>
Zeljko Vrba wrote:
> How to change the shell invoked by qx{}? I'm running some scripts
> under Win32 with cygwin installed. The perl invokes cmd.exe and
> nothing works (because of broken quoting, redirection, etc.). How
> to make it call bash? Thanks!
Set the the environment variable 'PERL5SHELL'. See perldoc perlrun.
Winfried Koenig
------------------------------
Date: 17 Apr 2003 08:46:26 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: conditional 'use'
Message-Id: <u9he8x8t2l.fsf@wcl-l.bham.ac.uk>
Mark Seger <mark.seger@hp.com> writes:
> Using a 'use' statement to load Zlib, all I need to do is:
>
> use Compress::Zlib;
> $Z=gzopen();
> when I put in a "require" pointing to Compress/Zlib.pm instead, all I
> did was change my open call to:
>
> $Z=Compress::Zlib->gzopen();
>
> and it all seemed to work. Is this indeed the right way to do it?
So long as you can be sure the gzopen() function ingores it's argument
list then this is OK. If not then you should do:
$Z=Compress::Zlib::gzopen();
> is there addiitional 'stuff' required?
Whether or not a module needs its import method called varies from
module to module. On the whole you don't need to call the import
method if you are prepared to use fully qualified names.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 17 Apr 2003 10:41:34 +0100
From: Andrew McGregor <Andrew.McGregor@amtrak.co.uk>
Subject: Re: conditional 'use'
Message-Id: <3E9E76CE.8030604@amtrak.co.uk>
Mark Seger wrote:
> I'm sure this is easy enough to do if you've already done it before, but
> I haven't and so am not sure how.
>
> Basically I have a script that uses 'Compress::Zlib' when it's there but
> I don't want to use it when it's not. Since you can't conditionalize a
> "use", I assume you use a "require" instead.
>
> Using a 'use' statement to load Zlib, all I need to do is:
>
> use Compress::Zlib;
> $Z=gzopen();
> $Z->gzwrite();
> $Z->gzclose();
>
> when I put in a "require" pointing to Compress/Zlib.pm instead, all I
> did was change my open call to:
>
> $Z=Compress::Zlib->gzopen();
>
> and it all seemed to work. Is this indeed the right way to do it? is
> there addiitional 'stuff' required?
>
This may not be exactly what you are after, but is one way to know if a
module is around.
#!/usr/local/bin/perl
use strict;
use warnings;
eval {
require Sys::HostnamE or die;
};
if ($@) {
print "not found\n";
# can't do stuff with module here
}
else {
print "exists\n";
# do stuff with module here
}
~
------------------------------
Date: Thu, 17 Apr 2003 09:15:24 +0200
From: Thomas Kuhn <mail@thomaskuhn.de>
Subject: embedded Perl in C++: Crash when Dynaloader wants to load SharedObjects
Message-Id: <b7lkai$27nvr$3@ID-109749.news.dfncis.de>
I have problems with C++ using Perl.
My machine is an AIX 64-Bit with the XLC Version 6 Compiler and Perl5.8.
After Initializing with
EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
static void
//#ifdef __aix
xs_init(pTHX)
//#else
//xs_init(pTHXo)
//#endif
{
char *file = __FILE__;
/* DynaLoader is a special case */
dXSUB_SYS;
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
}
...
I tried to call
rc = perl_parse(m_pPerlInterpreter, xs_init, argc, const_cast<char *
*>(args), NULL);
and then my Program crashed, with segmentation fault and Debugreport
that the SharedObjects couldn't be loaded. I also linked the perl.exp
with the boot_Dynaload
Symbol.
With Windows the same program works fine
...Now I really don't know what to do...
...please help me
------------------------------
Date: 17 Apr 2003 04:15:11 -0700
From: milka5000@yahoo.com (milka)
Subject: foreach how do I get out of the loop? sthg like "break;" exists?
Message-Id: <28fddbd4.0304170315.747184b6@posting.google.com>
I'm new to perl and I have copied this part of code (subroutine) from
a similar one. I only want to read the first line of the file but I
don't know what to replace "foreach" with! so I decided to just try to
exit the loop. but I can't seem to find how. If someone could tell me,
as well as if I'm using the wrap command correctly to replace "8T8"
with "|" I will be much grateful!! Thank you!
sub view_pick {
$viewcnt=1;
$cnt=0;
foreach $st (@PAPER)
{
if ($st =~ /\n$/)
{
chop($st);
}
($id, $title, $image, $comment) = split(/|/, $st);
wrap("8T8", '|', $title);
wrap("8T8", '|', $image);
wrap("8T8", '|', $comment);
if($image ne '')
{
print "<a href=\"http://www.ekfrasi.net/metam_lyk/papers.php?nr=1&id=$id\">";
print "<img src=\"http://www.ekfrasi.net/metam_lyk/images/newspapers/$image\"
height=\"120\"border=\"0\">";
print "</a>";
}
$cnt++;
if ($cnt >= $viewcnt) { here something like "break;"? }
}
}
------------------------------
Date: Thu, 17 Apr 2003 13:25:38 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: foreach how do I get out of the loop? sthg like "break;" exists?
Message-Id: <b7m64u$cne$1@news.dtag.de>
milka wrote:
> I'm new to perl and I have copied this part of code (subroutine) from
> a similar one. I only want to read the first line of the file but I
> don't know what to replace "foreach" with! so I decided to just try to
> exit the loop. but I can't seem to find how. If someone could tell me,
> as well as if I'm using the wrap command correctly to replace "8T8"
> with "|" I will be much grateful!! Thank you!
Yes, last is what you are looking for. But beware, that what you are
trying to do is somewhat hypocritic.
First you say "foreach", but then you don't deal with all elements. Not
very nice.
There are also some other problems with your code. You should look into
use strict;
and Perl's handling of booleans.
This:
> if($image ne '')
can be much nicer written as:
if($image)
or maybe
if(defined $image)
if 0 is a valid value for $image.
Hope this helps,
->malte
------------------------------
Date: Thu, 17 Apr 2003 12:44:38 +0100
From: "Bigus" <bigus AT creationfactor DOT net>
Subject: Re: foreach how do I get out of the loop? sthg like "break;" exists?
Message-Id: <b7m438$kme@newton.cc.rl.ac.uk>
> if ($st =~ /\n$/)
> {
> chop($st);
> }
This is not an answer to your question, but you can replace those lines
with:
chomp $st;
It removes any line-breaks etc from the end of the string.
Regards
Bigus
------------------------------
Date: Thu, 17 Apr 2003 13:15:28 +0100
From: Andrew McGregor <Andrew.McGregor@amtrak.co.uk>
Subject: Re: foreach how do I get out of the loop? sthg like "break;" exists?
Message-Id: <3E9E9AE0.3090007@amtrak.co.uk>
milka wrote:
> I'm new to perl and I have copied this part of code (subroutine) from
> a similar one. I only want to read the first line of the file but I
> don't know what to replace "foreach" with! so I decided to just try to
> exit the loop. but I can't seem to find how. If someone could tell me,
> as well as if I'm using the wrap command correctly to replace "8T8"
> with "|" I will be much grateful!! Thank you!
> sub view_pick {
> $viewcnt=1;
> $cnt=0;
> foreach $st (@PAPER)
> {
> if ($st =~ /\n$/)
> {
> chop($st);
> }
> ($id, $title, $image, $comment) = split(/|/, $st);
>
> wrap("8T8", '|', $title);
> wrap("8T8", '|', $image);
> wrap("8T8", '|', $comment);
>
> if($image ne '')
> {
> print "<a href=\"http://www.ekfrasi.net/metam_lyk/papers.php?nr=1&id=$id\">";
> print "<img src=\"http://www.ekfrasi.net/metam_lyk/images/newspapers/$image\"
> height=\"120\"border=\"0\">";
> print "</a>";
> }
> $cnt++;
> if ($cnt >= $viewcnt) { here something like "break;"? }
> }
> }
last if ($cnt >= $viewcnt);
perldoc -f last
If you already have the file in an array then try something like:
($id, $title, $image, $comment) = split(/|/, $PAPER[0]);
But you probably don't want to ready the entire file anyway, so:
open (my $fh, $file) or die $!;
chomp (my $first_line = <$fh>);
close $fh;
------------------------------
Date: Thu, 17 Apr 2003 12:22:38 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: foreach how do I get out of the loop? sthg like "break;" exists?
Message-Id: <slrnb9t73m.1tc.bernard.el-hagin@gdndev25.lido-tech>
In article <3E9E9AE0.3090007@amtrak.co.uk>, Andrew McGregor wrote:
> milka wrote:
[...]
> If you already have the file in an array then try something like:
>
> ($id, $title, $image, $comment) = split(/|/, $PAPER[0]);
split /\|/, $PAPER[0];
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: 17 Apr 2003 05:59:29 -0700
From: francescomoi@europe.com (Francesco Moi)
Subject: How to read one line from a text file
Message-Id: <5b829932.0304170459.109ca09c@posting.google.com>
Hello.
I'm trying to read one unique line from a text file.
Until know, I've succeeded in performing this by
making a loop:
$filename= 'foo.txt';
$count = trim(str_replace($filename,'',`wc -l $filename`));
open (F, $filename);
$linenumber = 1;
while(<F>)
{
@Field = split '\\t';
if ($linenumber = $count)
{
print "$Field[4]\n";
}
$linenumber++;
}
It works, but I consider it wastes too many resources, doesn`t
it?
Does anybody know a faster way to read one line? Thanx.
------------------------------
Date: Thu, 17 Apr 2003 08:01:07 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: How to run Perl code ?
Message-Id: <fkns9vsj6q2q31v88vpp5ltcco3j984skg@4ax.com>
GZM wrote:
> I want to know how to run Perl code such as:
> Print "test ";
>
> No display when I type "Perl Print 'test'" in bash shell .
That's known as the one-liner. Use the -e option. And perl is case
sensitive, most (ney, all) keywords are lower case.
bash? then use single quotes:
perl -e 'print "test\n"';
See also perlrun, included with the docs (type "perldoc perlrun") at the
command prompt, or even "man perlrun"), or see it online:
<http://www.perldoc.com/perl5.8.0/pod/perlrun.html>
--
Bart.
------------------------------
Date: Thu, 17 Apr 2003 17:29:57 +0800
From: "GZM" <gzm@citiz.net>
Subject: Re: How to run Perl code ?
Message-Id: <b7lruv$6jb$1@mail.cn99.com>
Thanks all of you .
"GZM" <gzm@citiz.net> ~{P4HkO{O"PBNE~}:b7leq4$2qeu$1@mail.cn99.com...
> Hai:
> I want to know how to run Perl code such as:
> Print "test ";
>
> No display when I type "Perl Print 'test'" in bash shell .
>
>
> Asp Gao
> =======================
>
>
------------------------------
Date: Thu, 17 Apr 2003 11:56:38 GMT
From: Devop <as@hotmail.com>
Subject: killing unix processes by name ...
Message-Id: <3E9E986C.E265715B@hotmail.com>
--------------F9DF40F7686EEBF228366832
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi.
Can any one suggest how *nix processes can be killed by name using perl
scripts ???
thanks
this same question has been sent to other groups :-)
thanks in advance
rgds
--------------F9DF40F7686EEBF228366832
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi.
<p>Can any one suggest how *nix processes can be killed by <b><u>name</u></b>
using perl scripts ???
<br>thanks
<br>
<p>this same question has been sent to other groups :-)
<br>thanks in advance
<p>rgds</html>
--------------F9DF40F7686EEBF228366832--
------------------------------
Date: Thu, 17 Apr 2003 12:26:16 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: killing unix processes by name ...
Message-Id: <j67t9vglf91r78vm6cfp59psma6n3c89bn@4ax.com>
Keywords: Remove WINDOZE to reply
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In a fit of excitement on Thu, 17 Apr 2003 11:56:38 GMT, Devop
<as@hotmail.com> managed to scribble:
> Hi.
>
> Can any one suggest how *nix processes can be killed by name using
> perl scripts ???
> thanks
>
>
> this same question has been sent to other groups :-)
> thanks in advance
>
> rgds
I haven't used via Perl, but a cmdline:
$ killall -9 procname
works. This in a system()/exec() call should work too.
Remember, 'killall -9 perl' could be disasterous though.. so be
cautious =)
Regards,
Ian
-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0
iQA/AwUBPp6dLmfqtj251CDhEQLoggCg633nQTuflbJr8227x/b2jkAxJbcAn0NY
dQDDh+yCohoR6KnrUd+4Uc54
=x8zd
-----END PGP SIGNATURE-----
--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Scripting, Web design, development & hosting.
------------------------------
Date: Thu, 17 Apr 2003 10:10:00 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: My 1st japh!!
Message-Id: <egls9vomut1i36afq1gn2bibhghm386va9@4ax.com>
On 16 Apr 2003 23:46:42 GMT, ctcgag@hotmail.com wrote:
>Well, the problem is that the string "12AC" isn't packed, so
>unpack isn't the right tool for that particular job. (Not
OK, so I won't bother any more...
>that someone couldn't use unpack to do it, just that it's not
>the obvious way!)
>
>map hex, split //, "12AC";
If you look at my japh, you'll see that's exactly what I'm doing. The
real problem is that as I said I can't really understand the use of
(un)pack(). I know the docs are quite detailed, but maybe a tutorial
with more examples would be useful[*]. Or I'm just too stupid...
[*] I've never read it, but I know there's an open() tutorial, so this
might not be completely unreasonable.
Michele
--
$\=q.,.,$_=q.print' ,\g,,( w,a'c'e'h,,map{$_-=qif/g/;chr
}107..q[..117,q)[map+hex,split//,join' ,2B,, w$ECDF078D3'
F9'5F3014$,$,];];$\.=$/,s,q,32,g,s,g,112,g,y,' , q,,eval;
------------------------------
Date: 17 Apr 2003 08:49:32 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Nesting tables with perl CGI
Message-Id: <u9d6jl8sxf.fsf@wcl-l.bham.ac.uk>
rob <rbinn@shaw.ca> writes:
> Hello,
> I need help nesting tables within a 1 row 2 - 3 column table . The
> tables to be nested are generated from mysql queries. If someone could
> give me a brief demonstration I am sure I would be able to figure out my
> mistakes. I could post the code if needed, but I think it is a standard
> issue.
Can you explain where your difficulty lies?
Do you understand the HTML part of what you are doing?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 17 Apr 2003 09:09:02 +0100
From: Andrew McGregor <Andrew.McGregor@amtrak.co.uk>
Subject: Re: Nesting tables with perl CGI
Message-Id: <3E9E611E.7070201@amtrak.co.uk>
rob wrote:
> Hello,
> I need help nesting tables within a 1 row 2 - 3 column table . The
> tables to be nested are generated from mysql queries. If someone could
> give me a brief demonstration I am sure I would be able to figure out my
> mistakes. I could post the code if needed, but I think it is a standard
> issue.
> Thanks for any help offered...
> Rob
>
Code would be good as I'm not sure where you are having problems, but:
http://stein.cshl.org/WWW/software/CGI/
Special Forms for Importing HTML-Tag Functions
Example:
use CGI qw/:standard *table start_ul/;
In this example, the following functions are generated in addition to
the standard ones:
1. start_table() (generates a <TABLE> tag)
2. end_table() (generates a </TABLE> tag)
3. start_ul() (generates a <UL> tag)
4. end_ul() (generates a </UL> tag)
------------------------------
Date: Thu, 17 Apr 2003 08:39:20 +0100
From: "Bigus" <bigus AT creationfactor DOT net>
Subject: Re: New Perl Beginners Site
Message-Id: <b7llnb$i18@newton.cc.rl.ac.uk>
"Jayaprakash Rudraraju" <prakashREMOVE@CAPITALSece.arizona.edu> wrote in
message
news:Pine.GSO.4.50.0304161631340.17792-100000@ece2.ece.arizona.edu...
> Thanks for the perl portal.. but some of the links "books" on the main
> page is crashing my netscape on unix machine.
You evidently have a buggy version of Netscape.. Netscape, buggy? Never! ;-)
Bigus
------------------------------
Date: Thu, 17 Apr 2003 08:25:12 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: New Perl Beginners Site
Message-Id: <c5ps9vo2ncfqis3khq2a3hgcp82atrqfmm@4ax.com>
Shlomi Fish wrote:
>There will be more resources as time goes by. Feel free to contribute.
This tutorial has recently been brought to my attention. You might want
to add it to your list.
<http://www.sthomas.net/roberts-perl-tutorial.htm>
--
Bart.
------------------------------
Date: 17 Apr 2003 11:46:20 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: newbie:substitution in a variable name
Message-Id: <b7m46c$gq0$3@mamenchi.zrz.TU-Berlin.DE>
Tad McClellan <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> Alexander Eisenhuth <stacom@stacom-software.de> wrote:
>
> > how can I access the value of these variables in a loop:
> >
> > my $B_01MASK = 0x01;
> > my $B_02MASK = 0x02;
> > my $B_03MASK = 0x04;
> > my $B_04MASK = 0x08;
> > my $B_05MASK = 0x10;
> > my $B_06MASK = 0x20;
> > my $B_07MASK = 0x40;
> > my $B_08MASK = 0x80;
>
>
> By using "Symbolic references".
>
> But DON'T do that!
>
> perldoc -q variable
>
> "How can I use a variable as a variable name?"
>
> and
>
> http://www.plover.com/~mjd/perl/varvarname.html
> http://www.plover.com/~mjd/perl/varvarname2.html
> http://www.plover.com/~mjd/perl/varvarname3.html
>
>
> > my $i = 1;
> > while ($i < 9) {
> > print "name of var:B_0$i\MASK value:", ?? , "\n";
> > $i ++;
> > }
>
>
> Use a single hash containing 8 pairs rather than 8 individual scalars:
>
> --------------------------
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my %mask = (
> B_01MASK => 0x01,
> B_02MASK => 0x02,
> B_03MASK => 0x04,
> # ...
> );
>
> for ( my $i='01'; $i lt '09'; $i++ ) {
> print "name of var:B_${i}MASK value:", $mask{ "B_${i}MASK" } , "\n";
> }
> --------------------------
>
> Or, better yet:
>
> my %B_mask = (
> '01' => 0x01,
> '02' => 0x02,
> '03' => 0x04,
> # ...
> );
>
> and access it with: $B_mask{$i}
This variant won't work. The keys have leading zeroes, but $i doesn't.
For this approach an array (with integer indices) would be appropriate.
Anno
------------------------------
Date: Thu, 17 Apr 2003 10:49:03 +0200
From: "Fizgig" <FizgigNO@SPAMequanimityREMOVETHISTO.nl>
Subject: Re: regexp. for a two dates delimited with a minus
Message-Id: <3e9e6a80$0$49099$e4fe514c@news.xs4all.nl>
Thank you for your replies Gunnar, Lao and kz15
A special requirement is that it should be one complete regular expression
that does all the work.
The reason for this is that a component i use only accepts a single regular
expression as a "mask" for text input, and i can't change that.
Fizig
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:b7keqv$1t8p6$1@ID-184292.news.dfncis.de...
> Fizgig wrote:
> > I need a regexp for a string with this format
> >
> > DD.MM.YYYY-DD.MM.YYYY
> >
> > I have already a great working expression for a single date;
>
> <snip>
>
> > How can i get it working for two dates delimited with a minus?
>
> If you don't want to drop that 'terrible' regexp, you can of course do
> something like:
>
> sub datecheck {
> my @parts = split /-/, shift;
> my $df =
>
'(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1
[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|
[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])0
0))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6
-9]|[2-9]\d)?\d{2})';
> return ($parts[0] =~ /$df/ and $parts[1] =~ /$df/) ? 0 : 1;
> }
>
> datecheck($string) returns 0 if okay, or else 1.
>
> / Gunnar
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>
------------------------------
Date: 17 Apr 2003 09:37:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: regexp. for a two dates delimited with a minus
Message-Id: <b7lskb$esf$1@mamenchi.zrz.TU-Berlin.DE>
Fizgig <FizgigNO@SPAMequanimityREMOVETHISTO.nl> wrote in comp.lang.perl.misc:
> Thank you for your replies Gunnar, Lao and kz15
>
> A special requirement is that it should be one complete regular expression
> that does all the work.
>
> The reason for this is that a component i use only accepts a single regular
> expression as a "mask" for text input, and i can't change that.
Then this is probably not the point to check the date for full
validity. Checking for the right format (say, the right numbers of
digits in the right places) can reasonably be done with a regex.
Checking for full compliance (leap years and all) is craziness and
shouldn't be done in a production program.
Anno
[TOFU snipped. Please don't top-post]
------------------------------
Date: 17 Apr 2003 08:32:53 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Stumped!
Message-Id: <u9r8818tp6.fsf@wcl-l.bham.ac.uk>
pooba53 <delautenschl@[nospam]wisc.edu> top-posts again.
E2RUDE... conversation aborted.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 17 Apr 2003 11:11:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Why is this expression so slow??
Message-Id: <b7m256$gq0$2@mamenchi.zrz.TU-Berlin.DE>
Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "S" == Sara <genericax@hotmail.com> writes:
>
> S> perl 5.8.0 on RH8 *. Running this expression on an array of about 30
> S> elements:
>
>
> S> map s/[\s\i\r\n]*$/\n/, @text;
[...runs forever]
> could be an actual bug with 5.8 but i can't test that.
>
> S> For now I'm going to move all of the code to the Solaris box running
> S> 5.6.1, where these lines run instantly..
>
> which is what i have.
Running Sara's code (with "\t" instead of "\i") under 5.8.0 doesn't
show any gross performance degradation. There's definitely "something
else" going on.
Anno
------------------------------
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 4857
***************************************