[19189] in Perl-Users-Digest
Perl-Users Digest, Issue: 1384 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 26 11:05:39 2001
Date: Thu, 26 Jul 2001 08:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <996159910-v10-i1384@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 26 Jul 2001 Volume: 10 Number: 1384
Today's topics:
Re: dynamically resizing pictures for a web page <danield@life.uiuc.edu>
Re: Fork(): How to find out? ... (Villy Kruse)
Re: Fork(): How to find out? ... (Anno Siegel)
Re: gd-1.8.4 and GD1.33 with freetype2 support !! <mondo@serv1.jump.net>
HTTP Request question (baobaoba)
HTTP Request question (baobaoba)
Re: HTTP Request question <ilya@martynov.org>
Re: Informix IDS2000 and Zope/Python/Perl/PHP on Linux <tjenkins@nospiced.ham.devis.com>
Re: Informix IDS2000 and Zope/Python/Perl/PHP on Linux <matjaz.ostroversnik@zrs-tk.si>
Match/capture question <mark.riehl@agilecommunications.com>
Re: Match/capture question <tom.melly@ccl.com>
Re: Matching 6 Numbers To Each Other (Barry Allwood)
Re: Newbie Question: Memory Problem <mjcarman@home.com>
Re: Object Reuse with Net::FTP (Jeff Hill)
password protect unix file <a0197620@MailAndNews.com>
password protect unix file <a0197620@MailAndNews.com>
Re: Recommendation for a book covering MySQL and Perl (Peter Gulutzan)
Re: Regexp help - ??? <tom.melly@ccl.com>
Re: Regular expression question. (Anno Siegel)
Re: Regular expression question. <godzilla@stomp.stomp.tokyo>
Re: Regular expression question. <ilya@martynov.org>
Re: Regular expression question. <godzilla@stomp.stomp.tokyo>
Re: Regular expression question. <ilya@martynov.org>
Re: Regular expression question. <godzilla@stomp.stomp.tokyo>
Re: Regular expression question. (Randal L. Schwartz)
Re: Regular expression question. <ilya@martynov.org>
successive foreach loop (=?ISO-8859-1?Q?Olivier_Bo=EBl?=)
Re: successive foreach loop <tom.melly@ccl.com>
Re: viewing input from a form <Thomas@Baetzler.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Jul 2001 09:55:53 -0500
From: Daniel Davidson <danield@life.uiuc.edu>
Subject: Re: dynamically resizing pictures for a web page
Message-Id: <3B602F79.CB82E4C8@life.uiuc.edu>
Right now, I am guessing a max of 10 users at a time, hitting a server that gets very little traffic
right now. Hopefully the processing issue will not be a problem, and if it is, we will just have to
go the more disk space out. I will try you suggestion and see how it goes. I am also still open for
more suggestions though.
thanks,
Dan
Sebastian wrote:
> Daniel Davidson <danield@life.uiuc.edu> wrote in message news:<3B5F04F3.49405263@life.uiuc.edu>...
> > All right here is the problem. I need to be able to take a 4MP photo
> > and resize it so that people on slower connections dont have to leave
> > their computer running at night to view one of them. Sounds simple,
> > just run imagemagick and resize to something smaller (~800x600).
> > However at the same time, I have people on the higher end who want to
> > see the full size to do publications. And with the quantity of photos
> > we will be handeling, storing both is not an option (well, that is what
> > I was told anyway). The best solution would be to resize the image with
> > imagemagick, then let the server get the resized picture. The only way
> > I can think of how to do this is to have a temporary - resized image
> > that the browser uses to load the picture. However when I think of the
> > problems that I will run into by doing it this way, I start to go nuts.
> > Anyone know of a way to display directly from the servers memory or some
> > other better way?
> >
> > thanks,
> >
> > Dan
>
> Hmmm. Having never used imagemagick, please consider my thoughts
> suspect from the start. But why not script the resize to happen
> on-the-fly, and simply output the resized image to the browser as
> binary content? Done with a perl program that is seperate from your
> html-content scripts, and requested by the browser in an image tag
> like <img src='/cgi-bin/makelowres.pl?img=1234'>.
> This way, you only store it in memory until the program exits.
> Depending on usage though, we're talking about some heavy processing
> power and ram on the server in order to run this kind of thing at any
> speed.
------------------------------
Date: 26 Jul 2001 13:50:55 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Fork(): How to find out? ...
Message-Id: <slrn9m081u.ol7.vek@pharmnl.ohout.pharmapartners.nl>
On 26 Jul 2001 11:36:15 GMT,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>
>Your wait_for_child() doesn't catch all children because it isn't
>called again when a SIGCHLD arrives while it is still processing
>another. You must call wait() in a loop to take care of those.
>
>Change it like this:
>
> sub wait_for_child #REAPER
> {
> my ($child);
> while ( ($child = wait) != -1 ) {
> @children = grep $_ != $child, @children;
> }
> $SIG{CHLD} = \&wait_for_child;
> }
>
Suggest to use waitpid(-1, &WNOHANG), otherwise the wait_for_child
will hang until all children are terminated. See perldoc -f waitpid.
Villy
------------------------------
Date: 26 Jul 2001 14:45:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Fork(): How to find out? ...
Message-Id: <9jpaea$sqv$1@mamenchi.zrz.TU-Berlin.DE>
According to Villy Kruse <vek@pharmnl.ohout.pharmapartners.nl>:
> On 26 Jul 2001 11:36:15 GMT,
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>
>
> >
> >Your wait_for_child() doesn't catch all children because it isn't
> >called again when a SIGCHLD arrives while it is still processing
> >another. You must call wait() in a loop to take care of those.
> >
> >Change it like this:
> >
> > sub wait_for_child #REAPER
> > {
> > my ($child);
> > while ( ($child = wait) != -1 ) {
> > @children = grep $_ != $child, @children;
> > }
> > $SIG{CHLD} = \&wait_for_child;
> > }
> >
>
>
>
>
> Suggest to use waitpid(-1, &WNOHANG), otherwise the wait_for_child
> will hang until all children are terminated. See perldoc -f waitpid.
In general, I agree. "waitpid" is much more flexible and, despite
its name, can be used to wait for any pid. However, the way the
program was presented, the main process didn't to anything but
watch its kids, so a blocking wait seemed okay. Actually, in
these cases it isn't even necessary to put wait() in a handler. The
main process could do the wait loop just as well.
Anno
------------------------------
Date: Wed, 25 Jul 2001 21:22:50 +0000 (UTC)
From: Mondo <mondo@serv1.jump.net>
Subject: Re: gd-1.8.4 and GD1.33 with freetype2 support !!
Message-Id: <9jndba$c7v$1@news.jump.net>
ssa <seresa_null@yahoo.com> wrote:
> gd-1.8.3 patch with the patch_gd.pl from GD-1.33
> THE PROBLEM:
> checking for freetype.h... no
> configure: warning: libgd will be built without support for TrueType fonts.
> checking for TT_Init_FreeType in -lttf... yes
> There are 2 freetype.h :
> /usr/local/include/freetype2/freetype/freetype.h
> /usr/local/include/freetype/freetype.h
From the patch_gd.pl README:
You may use the --x-includes option to tell configure about any .h files
that may be installed in funny places, such as freetype.h
In other words, you want this:
./configure --enable-jpeg --enable-freetype \
--x-includes=/usr/local/include/freetyp2/freetype
rather than this:
./configure --enable-jpeg --enable-freetype
--
Mando
------------------------------
Date: 26 Jul 2001 07:10:18 -0700
From: baobaoba@yahoo.com (baobaoba)
Subject: HTTP Request question
Message-Id: <25212a12.0107260610.77879141@posting.google.com>
I need to retrieve a xml file from our partner. I need a
user ID and password to access that page. When using browser,
it will pop up a window for ID and password. If I type this URL,
"http://userid:passwd@www.somesite.com/xxx.xml", I will go
to that page without the pop up window. But when I use this
URL in my perl script:
...
$request = new HTTP::Request('GET', $xmlURL);
$response = $ua->request($request);
if ( ! $response->is_success() ) {
print "Unable to retrieve $xmlURL.\n";
}
...
I got the error message. Can anyone tell me what is wrong
with my script? Thanks a lot.
------------------------------
Date: 26 Jul 2001 07:19:12 -0700
From: baobaoba@yahoo.com (baobaoba)
Subject: HTTP Request question
Message-Id: <25212a12.0107260619.2f6f4961@posting.google.com>
I need to retrieve a xml file from our partner. I need a
user ID and password to access that page. When using browser,
it will pop up a window for ID and password. If I type this URL,
"http://userid:passwd@www.somesite.com/xxx.xml", I will go
to that page without the pop up window. But when I use this
URL in my perl script:
...
$request = new HTTP::Request('GET', $xmlURL);
$response = $ua->request($request);
if ( ! $response->is_success() ) {
print "Unable to retrieve $xmlURL.\n";
}
...
I got the error message. Can anyone tell me what is wrong
with my script? Thanks a lot.
------------------------------
Date: 26 Jul 2001 18:20:05 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: HTTP Request question
Message-Id: <874rrzixgq.fsf@abra.ru>
b> I need to retrieve a xml file from our partner. I need a
b> user ID and password to access that page. When using browser,
b> it will pop up a window for ID and password. If I type this URL,
b> "http://userid:passwd@www.somesite.com/xxx.xml", I will go
b> to that page without the pop up window. But when I use this
b> URL in my perl script:
b> ...
b> $request = new HTTP::Request('GET', $xmlURL);
b> $response = $ua->request($request);
b> if ( ! $response->is_success() ) {
b> print "Unable to retrieve $xmlURL.\n";
b> }
b> ...
b> I got the error message. Can anyone tell me what is wrong
b> with my script? Thanks a lot.
AFAIK LWP::UserAgent do not takes username and password from URL. You
should pass auth info with request object.
$request->authorization_basic($name, $password);
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Thu, 26 Jul 2001 13:45:01 GMT
From: Tom Jenkins <tjenkins@nospiced.ham.devis.com>
Subject: Re: Informix IDS2000 and Zope/Python/Perl/PHP on Linux
Message-Id: <3B601FC0.4030400@nospiced.ham.devis.com>
Thomas Volkmar Worm wrote:
> Hi all!
>
> I am consindering to use Informix Dynamic Server (Informix Internet
> Foundation 2000/Linux) together with Zope and the other 3 P's.
>
> I wonder, whether somebody has any experience with Linux and
>
> - IDS 2000 and Perl
> or
> - IDS 2000 and PHP
> or
> - IDS 2000 and Python
> or
> - IDS 2000 and Zope
>
> and can tell me about the experience he made with one or more of these
> combinations. I am interested to hear about
>
> - availibility of the needed drivers
> - their (practical) compatibility to (eg. perl DBI, python DB-API 2.0,
> etc.)
> - stability
> - and what else someone has experienced
>
> I already was an php.net, python.org, perl.org, zope.org - I guess I
> know whats available. It looks to me as if the support for IDS is not so
> strong, so I am really interested in real experience somebody had rather
> that what you can read in the READMEs. If you stopped using IDS together
> with P..., please tell me why and what db (other than mySQL, thats
> allready running here) are you using instead.
>
> If some Informix/IBM people are around: Are there any contributions
> planned or in progress for the 3 P's by Informix/IBM? Where can I find
> online information about it?
>
> If you respond to this posting, please send a CC to my email-address
> too.
>
> Thanks for your efforts in advance
>
> Regards
> Thomas Volkmar Worm
>
One thing to keep in mind with Zope... you can call perl also. This was
added (by ActiveState I believe) so that the more "esoteric" databases
that perl supports can be accessed in Zope. Just a thought.
Tom
------------------------------
Date: Thu, 26 Jul 2001 15:46:19 +0200
From: "Matjaz Ostroversnik" <matjaz.ostroversnik@zrs-tk.si>
Subject: Re: Informix IDS2000 and Zope/Python/Perl/PHP on Linux
Message-Id: <9jp6vh$7nv$1@planja.arnes.si>
Hi Thomas
We are using RH 6.2, IIF 2000, apache and PHP 4.0.4 pl1 for our HCV RNA
application.
It works fine for one year. We bounce the database twice in this time.
There are some problems with apache, php, ifx combination, beacuse from time
to time we can observe a rather big list of db sessions, but restarting of
apache
solved the problem.
We are even using php (command line mode) for communication with laboratory
engines.
We are using the same combination for some number of less important
applications and we do not have any complaints.
"Thomas Volkmar Worm" <worm@gdp-group.com> wrote in message
news:3B600F47.2F59C1FC@gdp-group.com...
> Hi all!
>
> I am consindering to use Informix Dynamic Server (Informix Internet
> Foundation 2000/Linux) together with Zope and the other 3 P's.
>
> I wonder, whether somebody has any experience with Linux and
>
> - IDS 2000 and Perl
> or
> - IDS 2000 and PHP
> or
> - IDS 2000 and Python
> or
> - IDS 2000 and Zope
>
> and can tell me about the experience he made with one or more of these
> combinations. I am interested to hear about
>
> - availibility of the needed drivers
> - their (practical) compatibility to (eg. perl DBI, python DB-API 2.0,
> etc.)
> - stability
> - and what else someone has experienced
>
> I already was an php.net, python.org, perl.org, zope.org - I guess I
> know whats available. It looks to me as if the support for IDS is not so
> strong, so I am really interested in real experience somebody had rather
> that what you can read in the READMEs. If you stopped using IDS together
> with P..., please tell me why and what db (other than mySQL, thats
> allready running here) are you using instead.
>
> If some Informix/IBM people are around: Are there any contributions
> planned or in progress for the 3 P's by Informix/IBM? Where can I find
> online information about it?
>
> If you respond to this posting, please send a CC to my email-address
> too.
>
> Thanks for your efforts in advance
>
> Regards
> Thomas Volkmar Worm
>
>
------------------------------
Date: Thu, 26 Jul 2001 14:44:10 GMT
From: "Mark Riehl" <mark.riehl@agilecommunications.com>
Subject: Match/capture question
Message-Id: <_0W77.3157$pH2.653112@typhoon1.gnilink.net>
All - I've got a data file that has the following format:
T0623DP00,...
T0624DS00,...
...
I'm interested only in the number portion w/o the leading 0. So, if this
was my input file, I'd like to extract 623 and 624.
These records are split :
@array = split (',', $_);
Either of these work and produce the same result:
if ($array[0] =~ /(\d{4})/) {
print "\$1 = $1\n"; <<<< prints 0623 and 0624
}
if ($array[0] =~ /(\d+)/) {
print "\$1 = $1\n"; <<<< prints 0623 and 0624
}
Question - How can skip the leading 0 in this match? Can I skip it, or can
I use the match and match on the last 3 digits in the string?
Thanks,
Mark
------------------------------
Date: Thu, 26 Jul 2001 15:52:31 +0100
From: "Tom Melly" <tom.melly@ccl.com>
Subject: Re: Match/capture question
Message-Id: <3b602eaf$0$3757$ed9e5944@reading.news.pipex.net>
"Mark Riehl" <mark.riehl@agilecommunications.com> wrote in message
news:_0W77.3157$pH2.653112@typhoon1.gnilink.net...
>
> if ($array[0] =~ /(\d+)/) {
> print "\$1 = $1\n"; <<<< prints 0623 and 0624
> }
>
> Question - How can skip the leading 0 in this match? Can I skip it, or can
> I use the match and match on the last 3 digits in the string?
>
What about:
> if ($array[0] =~ /0(\d+)/) {
or even:
> if ($array[0] =~ /\d(\d+)/) {
------------------------------
Date: 26 Jul 2001 14:37:24 GMT
From: barryallwood@aol.com (Barry Allwood)
Subject: Re: Matching 6 Numbers To Each Other
Message-Id: <20010726103724.15149.00000959@ng-bj1.aol.com>
Thanks Alot For The Help!
I accidentally overlooked the substr() command
Barry
------------------------------
Date: Thu, 26 Jul 2001 09:09:02 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Newbie Question: Memory Problem
Message-Id: <3B60247E.7F1AD00B@home.com>
Ilya Martynov wrote:
>
> JL> I would like to process a _VERY_ hug ASCII File (about 300MB).
> JL> When I set up the procedure in perl:
>
> JL> open(outfile,">o.txt");
> JL> open(infile,"<in.txt");
> JL> foreach $line (<infile>) {
> JL> <extract something from $line... and write it to o.txt>.
> JL> };
> JL> ...
>
> JL> Then perl tries to load the whole file into memory and runs
> JL> out of memory.
> JL> Is there no way to read the file line by line?
>
> Such cycle should read file line by line.
No. foreach opearates on lists, which means list context for the
filehandle, which means slurp!
Use while to read line by line:
while (my $line = <infile>) {
#...
}
-mjc
------------------------------
Date: 26 Jul 2001 07:06:16 -0700
From: jeffrey.hill1@tycoelectronics.com (Jeff Hill)
Subject: Re: Object Reuse with Net::FTP
Message-Id: <2cd423e6.0107260606.75b8d91a@posting.google.com>
Thomas Bätzler <Thomas@Baetzler.de> wrote in message news:<vusvltopp0q6g8973a2qal1shh5v0p5vd2@4ax.com>...
-Snip-
> This isn't particularly hard. Try the following code skeleton:
>
-Snip
>
> HTH,
Thomas, thank you for the code, it helped me out a great deal.
Jeff Hill
------------------------------
Date: Thu, 26 Jul 2001 09:37:31 -0400
From: Jag Man <a0197620@MailAndNews.com>
Subject: password protect unix file
Message-Id: <3B68D568@MailAndNews.com>
Is there a module to add password protection to a text file equalent to "vi
-x
filename", "Key: ", and data...
Thanks in Advance!
JM
------------------------------------------------------------
Get your FREE web-based e-mail and newsgroup access at:
http://MailAndNews.com
Create a new mailbox, or access your existing IMAP4 or
POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------
------------------------------
Date: Thu, 26 Jul 2001 09:37:36 -0400
From: Jag Man <a0197620@MailAndNews.com>
Subject: password protect unix file
Message-Id: <3B68D5C3@MailAndNews.com>
Is there a module to add password protection to a text file equalent to "vi
-x
filename", "Key: ", and data...
Thanks in Advance!
JM
------------------------------
Date: 26 Jul 2001 07:50:42 -0700
From: pgulutzan@yahoo.ca (Peter Gulutzan)
Subject: Re: Recommendation for a book covering MySQL and Perl
Message-Id: <bc8f8132.0107260650.6913fbf3@posting.google.com>
Paul Dubois (author of the New Riders MySQL book) has written
"MySQL and Perl for the web". The publisher says it will be out
in a month or so.
We keep a list of MySQL books, with links to reviews and
sample chapters, at
http://ourworld.compuserve.com/homepages/OCELOTSQL/mysql.htm
Peter Gulutzan
Ocelot Computer Services Inc.
------------------------------
Date: Thu, 26 Jul 2001 15:47:12 +0100
From: "Tom Melly" <tom.melly@ccl.com>
Subject: Re: Regexp help - ???
Message-Id: <3b602d71$0$3755$ed9e5944@reading.news.pipex.net>
"Tracy Gentry" <tracy_gentry@yahoo.com> wrote in message
news:9d356f64.0107260448.52d34b66@posting.google.com...
>
> ...|"(0{0,1}2/29/20[02468][48]{0,1})|"|...
>
> This line validates a subset of the valid leap years for this century.
> As coded, 02/29/200 and 02/29/2004 will match, but 02/29/20 won't and
> I want it to. Is there a way to denote a character as optional if no
> other characters appear after it, but required if more characters
> follow? Or maybe some sort of grouping?
Hmm, well there's a lot of ways to do it, but a quick fix would be:
...|"(0{0,1}2/29/20($|[02468][48]{0,1}))|"|...
... however this assumes that "$" would match the end of your input date and
that you don't mind grabbing it.
This is probably more thorough:
...|"(0{0,1}2/29/20((?=$|\D)|([02468][48]{0,1})))|"|...
The (?=foo) is a 0-width look-ahead.
------------------------------
Date: 26 Jul 2001 13:05:03 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regular expression question.
Message-Id: <9jp4hv$n79$2@mamenchi.zrz.TU-Berlin.DE>
According to Ronald Blaschke <TGVCDPVNTLMI@spammotel.com>:
> $str =~ s/(\w)\1+/\1/g;
^^
Never use \1 and friends on the replacement side of s///. It is
only guaranteed to work inside a regex (which the right half isn't).
Anno
------------------------------
Date: Thu, 26 Jul 2001 06:29:00 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regular expression question.
Message-Id: <3B601B1C.2F7407EF@stomp.stomp.tokyo>
Anno Siegel wrote:
> Ronald Blaschke wrote:
> > $str =~ s/(\w)\1+/\1/g;
> ^^
> Never use \1 and friends on the replacement side of s///. It is
> only guaranteed to work inside a regex (which the right half isn't).
Honestly and truly?
$godzilla = "godzilla rocks!";
srand(time() ^ ($$ + ($$ << 15)));
sub randcase
{ rand(40) < 20 ? "\u$1" : "\l$1" ; }
$godzilla =~ s/([a-z])/randcase(\1)/gie;
print $godzilla;
Godzilla!
--
@ø=(a .. z);@Ø=qw(6 14 3 25 8 11 11 0 17 14 2 10 18);
$§="\n";$ß="\b";undef$©;print$§x($Ø[4]/2);
for($¡=0;$¡<=$Ø[2];$¡++){foreach$¶(@Ø){
$ø[$¶]=~tr/A-Z/a-z/;if(($¡==1)||($¡==$Ø[2]))
{$ø[$¶]=~tr/a-z/A-Z/;}print$ø[$¶];if($¶==0)
{print" ";}if($¶==$Ø[12]){print" !";}&D;}
print$ßx($Ø[4]*2);}print$§x($Ø[10]*2);
sub D{select$©,$©,$©,.25;}exit;
------------------------------
Date: 26 Jul 2001 17:32:19 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Regular expression question.
Message-Id: <87d76nizoc.fsf@abra.ru>
G> Anno Siegel wrote:
>> Ronald Blaschke wrote:
>> > $str =~ s/(\w)\1+/\1/g;
>> ^^
>> Never use \1 and friends on the replacement side of s///. It is
>> only guaranteed to work inside a regex (which the right half isn't).
G> Honestly and truly?
Read 'perldoc perlre' section 'Warning on \1 vs $1'.
G> $godzilla = "godzilla rocks?";
G> srand(time() ^ ($$ + ($$ << 15)));
G> sub randcase
G> { rand(40) < 20 ? "\u$1" : "\l$1" ; }
G> $godzilla =~ s/([a-z])/randcase(\1)/gie;
G> print $godzilla;
G> [..skip..]
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Thu, 26 Jul 2001 06:46:04 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regular expression question.
Message-Id: <3B601F1C.61B0D1E8@stomp.stomp.tokyo>
Ilya Martynov wrote:
> G> Anno Siegel wrote:
> >> Ronald Blaschke wrote:
> >> > $str =~ s/(\w)\1+/\1/g;
> >> ^^
> >> Never use \1 and friends on the replacement side of s///. It is
> >> only guaranteed to work inside a regex (which the right half isn't).
> G> Honestly and truly?
> Read 'perldoc perlre' section 'Warning on \1 vs $1'.
I have, many times. Your point is?
My point is quite clear and sharp.
> G> $godzilla = "godzilla rocks?";
> G> srand(time() ^ ($$ + ($$ << 15)));
> G> sub randcase
> G> { rand(40) < 20 ? "\u$1" : "\l$1" ; }
> G> $godzilla =~ s/([a-z])/randcase(\1)/gie;
> G> print $godzilla;
Godzilla!
--
$Ø = "24S4E2S7E¿18S24E¿15S4E3C25E¿13S4E6C28E¿12S2E8C3E3C25E¿10S8E
4C1E11C20E¿8S3E1S1E2C6E18C11E3S3E¿11S2E4C8E4C1E10C11E4S1E¿9S18E1C
1E11C13E¿8S20E12C15E¿8S22E9C17E¿9S22E7C19E¿8S16E2C5E6C21E¿6S17E3C
5E5C16E3S4E¿5S17E3C5E4C1E2C16E4S2E¿4S17E3C4E5C1E11C8E4S1E¿3S17E4C
2E6C1E1C1E11C9E¿2S19E3C1E6C1E2C3E8C11E7S1E¿2S2E3S10E2C2E4C1E4C1E1
3C15E1S4E¿1S2E2S11E3C1E9C1E10C1E2C2E1C17E¿1S1E2S13E11C1E2C9E4C18E
¿2S11E1C3E10C1E5C5E5C18E¿1S10E4C2E9C3E13C21E¿10E5C1E9C6E9C24E¿9E5
C1E9C30E3S8E¿6E1S1E15C10E7C16E3S7E¿4E3S1E14C12E6C17E4S5E¿1S3E3S1E
13C15E5C17E4S4E¿2S3E2S1E12C5E1C12E4C1E2C7E1S6E3S4E¿3S2E2S1E12C4E1
C17E6C3E3S5E3S3E¿3S2E2S1E10C5E2C5E2C12E7C7E4S2E¿3S1E3S2E8C5E3C4E5
C12E8C3E5S1E¿7S2E7C5E5C3E7C2E3C7E8C2E4S1E¿6S4E5C5E7C2E8C1E5C6E3C1
E5C1E¿5S5E5C5E8C1E11C1E4C4E4C1E4C1E¿4S6E5C2E1C1E10C1E11C1E3C4E6C1
E2C1E¿3S2E1S5E3C3E1C1E23C1E1C4E9C1E1C¿3S1E1S6E3C2E2C1E23C2E1C2E12
C1E¿5S6E3C2E2C1E10C4E10C1E1C2E14C1E¿4S7E3C2E2C1E9C6E9C1E2C2E14C1E
¿4S8E2C2E2C2E8C6E9C1E3C1E14C2E¿4S5E2S1E3C1E2C2E9C4E10C1E17C4E¿4S4
E3S2E6C2E21C2E17C4E¿5S3E4S1E7C2E19C2E2C1E16C2E¿5S3E4S2E7C3E16C2E3
C2E15C1E¿6S2E5S1E8C4E11C4E5C2E12C2E¿7S2E4S2E9C15E8C3E8C3E¿8S2E4S2
E12C7E14C10E¿9S2E3S3E34C6E¿10S1E3S4E22C1E3C1E8C2E¿14S5E18C2E6C2E6
C2E¿13S7E15C3E7C2E5C2E¿13S8E13C3E9C3E3C1E¿12S10E11C3E11C2E3C1E¿11
S2E1S8E9C3E14C1E3C1E¿11S1E2S6E1S1E7C2E17C1E3C1E1C¿14S6E1S1E6C1E19
C1E3C2E¿13S6E2S1E5C1E24C1E1C1E¿13S6E2S1E5C1E9C1E14C1E2C1E¿13S5E3S
1E14C2E15C1E2C1E¿12S5E3S1E14C3E16C1E2C1E¿11S5E3S1E15C2E18C1E2C1E¿
10S5E3S1E5C1E10C1E10C2E7C1E3C1E¿10S4E3S1E5C1E23C2E7C1E3C1E¿9S4E3S
1E5C1E23C3E8C1E3C1E¿8S3E4S1E5C2E22C3E9C1E4C1E¿6S4E4S2E4C2E21C4E9C
1E2C1E3C1E¿5S3E6S1E5C1E20C3E12C1E2C2E3C1E¿2S4E7S2E25C2E13C2E2C2E3
C1E1C¿13S1E25C1E15C2E2C2E3C2E¿12S2E6C1E35C1E2C2E3C2E¿12S1E8C1E35C
1E2C1E3C2E¿11S2E9C1E13C1E21C1E1C1E3C2E¿11S1E11C3E9C1E23C2E2C3E¿11
S1E12C11E24C2E2C2E¿11S1E13C9E25C1E2C2E¿11S1E14C7E25C1E2C2E¿11S1E1
5C6E25C1E1C2E¿11S1E17C3E26C3E¿11S1E19C1E26C3E¿11S2E17C1E26C3E¿12S
1E17C1E26C3E¿12S2E15C1E26C3E¿13S1E15C1E25C3E¿13S2E13C1E25C3E¿14S1
E13C1E24C3E¿14S2E11C1E24C3E¿15S1E11C1E23C3E¿15S2E9C1E23C3E¿16S1E9
C1E22C3E¿16S2E7C1E22C3E¿17S2E6C1E21C3E¿17S2E5C1E21C3E¿18S2E4C1E20
C3E¿18S2E3C1E20C3E¿19S2E2C1E19C3E¿19S2E1C1E19C3E¿20S3E18C3E¿20S2E
18C3E¿21S1E17C3E¿20S2E16C3E¿20S2E15C3E¿20S2E4C1E9C3E1C¿20S3E4C2E7
C4E¿21S3E11C3E1C1E¿21S3E3C1E7C1E1C1E1C1E¿22S2E2C4E7C1E1C1E¿22S2E2
C3E8C1E1C1E¿22S3E2C2E8C1E1C1E¿23S2E2C2E9C1E1C1E¿23S2E2C2E10C1E1C1
E¿23S2E3C1E11C2E¿23S3E15C1E1C¿23S3E15C1E1C¿23S3E16C1E¿23S3E16C1E¿
23S3E16C2E¿24S2E16C2E¿24S3E15C2E¿24S3E15C2E¿24S3E15C2E¿24S3E15C2E
¿25S2E14C3E¿25S3E13C2E¿25S3E13C2E¿25S3E12C2E¿26S2E12C2E¿26S2E12C2
E¿26S2E11C2E¿26S3E10C2E¿26S3E10C2E¿27S2E9C2E¿27S3E8C2E¿27S3E8C2E¿
28S2E8C2E¿28S3E6C2E¿28S3E6C2E¿29S2E6C2E¿29S2E6C2E¿30S2E5C2E¿30S2E
5C2E¿30S2E5C1E¿30S2E5C1E¿30S2E6C1E¿29S1E1C1E7C1E¿28S1E3C1E6C1E¿27
S1E4C1E6C1E¿26S1E5C1E7C1E¿25S1E6C2E7C1E¿25S1E7C1E8C1E¿25S2E1C1E4C
1E9C1E¿25S1E1C1E1C1E3C1E10C1E¿25S2E1C1E1C1E2C1E8C1E1C1E¿26S2E1C1E
2C2E7C1E1C2E¿27S2E2C3E6C1E1C1E1C1E¿28S4E1S2E4C1E1C1E1C2E¿34S2E4C1
E1C2E¿35S2E4C2E¿36S2E2C2E¿37S4E";$Ø=~tr/\n//d;@©=split(/¿/,$Ø);
foreach$§(@©){$§=~s/(\d)([^\d])/$1:$2/g;$§=~s/([^\d])(\d)/$1 $2/g;
@®=split(/ /, $§);foreach$¶(@®){($¢,$¡)=split(/:/, $¶);if($¡eq"C")
{print":"x$¢;}if($¡eq"E"){print"8"x$¢;}if($¡eq"S"){print" "x$¢;}}
print"\n";}print"\n\n"," "x32,"Godzilla Rocks!";exit;
------------------------------
Date: 26 Jul 2001 18:12:00 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Regular expression question.
Message-Id: <878zhbixu7.fsf@abra.ru>
>> Read 'perldoc perlre' section 'Warning on \1 vs $1'.
G> I have, many times. Your point is?
Never use \1 in second part of s///. Just use $1.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Thu, 26 Jul 2001 07:30:44 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regular expression question.
Message-Id: <3B602994.C375631C@stomp.stomp.tokyo>
Ilya Martynov wrote:
> >> Read 'perldoc perlre' section 'Warning on \1 vs $1'.
> G> I have, many times. Your point is?
> Never use \1 in second part of s///. Just use $1.
What? Do you Perl 5 Cargo Cultists believe \1 is
the Big Bad Wolf?
Kinda figured you have no point.
My code employs both \1 and the evaluation modifier,
quite successfully, although this causes all of you
Perl 5 Cargo Cultists to jump up and down, tug at
your hair and scream,
"YOU CAN NEVER DO THAT!"
Sure!
This type of conformist thinking is what sorts
real Perl programmers, such as myself, from
mindless copy and paste babies.
True Perl programmers know what they can do and,
what they cannot do.
You need to whet your troll skills; they are quite dull.
Godzilla!
--
Warning on \1 vs $1
Some people get too used to writing things like:
$pattern =~ s/(\W)/\\\1/g;
This is grandfathered for the RHS of a substitute to avoid shocking the
sed addicts, but it's a dirty habit to get into. That's because in
PerlThink, the righthand side of a `s///' is a double-quoted string.
`\1' in the usual double-quoted string means a control-A. The customary
Unix meaning of `\1' is kludged in for `s///'. However, if you get into
the habit of doing that, you get yourself into trouble if you then add
an `/e' modifier.
PerlThink? NewSpeak? Look out Orson!
$godzilla = "godzilla rocks!";
srand(time() ^ ($$ + ($$ << 15)));
sub randcase
{ rand(40) < 20 ? "\u$1" : "\l$1" ; }
$godzilla =~ s/([a-z])/randcase(\1)/gie;
print $godzilla; exit;
------------------------------
Date: 26 Jul 2001 07:46:37 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Regular expression question.
Message-Id: <m1lmlbd9yq.fsf@halfdome.holdit.com>
>>>>> "Godzilla!" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
Godzilla!> My code employs both \1 and the evaluation modifier,
Godzilla!> quite successfully, although this causes all of you
Godzilla!> Perl 5 Cargo Cultists to jump up and down, tug at
Godzilla!> your hair and scream,
Godzilla!> "YOU CAN NEVER DO THAT!"
Godzilla!> Sure!
Godzilla!> This type of conformist thinking is what sorts
Godzilla!> real Perl programmers, such as myself, from
Godzilla!> mindless copy and paste babies.
Godzilla!> True Perl programmers know what they can do and,
Godzilla!> what they cannot do.
You can do what you want. We're just warning you that you're using
the emergency brakes to stop your car, instead of that nice big pedal
next to your accelerator. Sure, it'll work for most stops, but in a
panic, you might not be able to reach the handle in time. Then you'll
be in trouble for not having used the proper pedal.
Do what you want in the privacy of your own cubicle, Kira. But let
the manual dictate how Perl was intended to be used.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 26 Jul 2001 18:50:04 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Regular expression question.
Message-Id: <87u1zzhhib.fsf@abra.ru>
>> Never use \1 in second part of s///. Just use $1.
G> What? Do you Perl 5 Cargo Cultists believe \1 is
G> the Big Bad Wolf?
G> Kinda figured you have no point.
Because using \1 doesn't gains anything while it can be a source of
errors for unexperienced programmers.
G> My code employs both \1 and the evaluation modifier,
G> quite successfully, although this causes all of you
G> Perl 5 Cargo Cultists to jump up and down, tug at
G> your hair and scream,
G> "YOU CAN NEVER DO THAT!"
G> Sure!
G> This type of conformist thinking is what sorts
G> real Perl programmers, such as myself, from
G> mindless copy and paste babies.
G> True Perl programmers know what they can do and,
G> what they cannot do.
G> You need to whet your troll skills; they are quite dull.
I don't want to troll by no means. At least not on public maillists
and newsgroups. I thought to send you private email with some flame
but your 'From:' field doesn't contain real email address.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: 26 Jul 2001 06:23:48 -0700
From: oboel@dorrboel.com (=?ISO-8859-1?Q?Olivier_Bo=EBl?=)
Subject: successive foreach loop
Message-Id: <e8f69cf.0107260523.608ac220@posting.google.com>
Hello,
Can anyone tell me how to run a foreach loop twice? ie
foreach $element (@array) {
do something
}
foreach $element (@array) {
do somethingelse
}
It seems that the second loop is never executed. In other words, how
can I start from the first element again?
Thanks in advance,
Olivier
------------------------------
Date: Thu, 26 Jul 2001 15:15:09 +0100
From: "Tom Melly" <tom.melly@ccl.com>
Subject: Re: successive foreach loop
Message-Id: <3b6025ee$0$3759$ed9e5944@reading.news.pipex.net>
"Olivier Boël" <oboel@dorrboel.com> wrote in message
news:e8f69cf.0107260523.608ac220@posting.google.com...
<snip>
Your partial code will be fine - whatever problem you are experiencing lies
elsewhere.
Try this:
@list = qw(a b c d);
foreach $element(@list){
print "foo: $element\n";
}
foreach $element(@list){
print "bar: $element\n";
}
------------------------------
Date: Thu, 26 Jul 2001 15:07:11 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: viewing input from a form
Message-Id: <ld40mt41dvl5jt6nqdrrsnjaggfqkd825r@4ax.com>
On 26 Jul 2001, rdeenen@mollymail.com (rolf deenen) wrote:
>small question here. I'm fiddling around at the moment with cgi and
>forms en i have the following question: My forms use the POST method
>of sending data which is the fed into a certain script. But is it also
>possible to print this input to my console so I can seen what data
>enters the script?
If you're on a Unix system, you could create a parameter list file
that you append to each time your script is run. Then you could just
do a tail -f on that file on your console. Of course, you would have
to use file locking to make sure that only one instance of the cgi
program at a time.
But if you're just fiddling with CGI, why don't you print those CGI
params out on the result page, i.e:
--------8<----( cut here )----8<--------
#!/usr/bin/perl -wT
use strict;
use CGI qw(:standard);
my $q = new CGI;
my @keys = $q->param;
my @tablebody = $q->Tr( $q->th(['Parameter','Value']) );
foreach my $key ( sort @keys ){
push @tablebody, $q->Tr( $q->td( [ $key, $q->param( $key ) ] ) );
}
print $q->header(),
$q->start_html( -title => 'List of CGI Parameters' ),
$q->h1("List of CGI Parameters"),
$q->table( @tablebody );
$q->end_html();
__END__
--------8<----( cut here )----8<--------
HTH,
--
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.
------------------------------
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 1384
***************************************