[18214] in Perl-Users-Digest
Perl-Users Digest, Issue: 382 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 1 03:05:53 2001
Date: Thu, 1 Mar 2001 00:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983433913-v10-i382@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 1 Mar 2001 Volume: 10 Number: 382
Today's topics:
Re: Attachments (Rafael Garcia-Suarez)
Re: CGI not working with Personal Web Server <joeykid6@yahoo.com>
Re: dereferencing an array of references using join <joeykid6@yahoo.com>
Re: dereferencing an array of references using join <joeykid6@yahoo.com>
Re: fork() and ActiveState Perl - workarounds? (Win32 <billk@cts.com>
Re: Graphic file manipulation <obiwan@mahood.com>
Re: How the CLPM turns (Sam Holden)
Re: How the CLPM turns ()
Re: Opening STDERR for input (Damian James)
Re: Perl CGI.pm RESET problem <joeykid6@yahoo.com>
Re: Perl CGI.pm RESET problem <joeykid6@yahoo.com>
Re: print "</tr><tr>" vs. print $tr (Tad McClellan)
Re: Problem with Win32::EventLog <carvdawg@patriot.net>
Re: problem with {q}? <nospam.newton@gmx.li>
Re: problem with {q}? (Rafael Garcia-Suarez)
Re: regex help needed <nouser@emailunwelcome.com>
Re: regex help please (The Mosquito ScriptKiddiot)
Re: regex help please <bwalton@rochester.rr.com>
Re: regex help please (The Mosquito ScriptKiddiot)
Re: regex help please <jonni@ifm.liu.se>
Re: regex help please <jonni@ifm.liu.se>
Re: Secret planned perl feature revealed <cdh@ala.net>
Re: Slow down <kjetil.skotheim@usit.uio.no>
Re: Slow down <kjetil.skotheim@usit.uio.no>
Re: Slow down <brondsem@my-deja.com>
Re: Slow down <jbailey@cyberconnect.com>
Re: Slow down <peter.sundstrom-eds@eds.com>
Re: Slow down <wyzelli@yahoo.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 01 Mar 2001 07:54:07 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Attachments
Message-Id: <slrn99s00b.32t.rgarciasuarez@rafael.kazibao.net>
Todd Anderson wrote in comp.lang.perl.misc:
>
> I use the code below to send email with attachments. However when
> sending to more than 1 recipient, the code does not recognize the new
> "$to" and sends the second email to the first recipient. So the first
> recipient gets 2 emails. And then some times on the second email the
> attachment file appears to be empty and so it doesn't get attached. Any
> ideas?
> Thanks in advance for your help.
>
[...snip a lot of irrelevant code...]
>
> open (MAILPIPE,"|$sendmail $to") || order_error("Sorry! There's a big
> line at the post office. Try again in a minute");
Your code doesn't show where the $sendmail and $to variables are
initialized. Thus we don't know which tool you use to send mail and how
do you deal with the $to address. We can't help.
An advice here to help you to write more maintainable scripts :
don't use a lot of global variables, as you seem to do. Always 'use
strict' ; pass arguments to subroutines ; declare local variables with
my(). Thus it will be easier for you to track down what's in your
variables, and to debug your scripts.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Thu, 1 Mar 2001 01:07:01 -0500
From: "Joe Williams" <joeykid6@yahoo.com>
Subject: Re: CGI not working with Personal Web Server
Message-Id: <97kp1m$kr0$1@slb1.atl.mindspring.net>
If all you want to do is test perl cgi's at home, try Tinyweb can't remember
the address, but should find it in a search). Greatest test web server ever
invented. 10 seconds to download, 3 minutes to setup. Use it for all my
testing, never had a problem (although I'm not certain it supports nph).
Joe
Mark <mark_shutt@hotmail.com> wrote in message
news:t9ohkg99qaljd5@corp.supernews.com...
> Hi,
>
> I'm using Perl and MS PWS. When I submit a form to display a simple
> message, the Perl script executes by quickly pulling up a DOS prompt and
> the page just sits there. I have the registry correct with the ScriptMap I
> think. I've seen numerous examples that all say the same thing. Does
> anyone know why my perl scripts would execte as if I ran them from the DOS
> prompt or as if I double clicked the script from windows explorer? I have
> also since removed the "Open" action of Windows explorer because I thought
> that may have been affecting it, but that doesn't seem to be the case.
>
> Thanks,
> Mark
>
> --
> Posted via CNET Help.com
> http://www.help.com/
------------------------------
Date: Thu, 1 Mar 2001 01:19:36 -0500
From: "Joe Williams" <joeykid6@yahoo.com>
Subject: Re: dereferencing an array of references using join
Message-Id: <97kpkl$jhh$1@slb6.atl.mindspring.net>
Sorry, didn't mean to be arrogant. One of the responses I got told me to
keep useless stuff out of my code, which just struck me the wrong way since
I'd mentioned I was new to programming perl. No offense meant.
Joe
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:97ik65$1d7$1@mamenchi.zrz.TU-Berlin.DE...
> According to Joe Williams <joeykid6@yahoo.com>:
> > Thanks, Ren. For some reason, I thought I tested without the quotes and
got
> > an error. You win for the most concise code and the least impatient
> > response....
>
> Do you realise how arrogant that sounds?
>
> Anno
------------------------------
Date: Thu, 1 Mar 2001 01:32:12 -0500
From: "Joe Williams" <joeykid6@yahoo.com>
Subject: Re: dereferencing an array of references using join
Message-Id: <97kqgt$pa2$1@slb0.atl.mindspring.net>
You know what, Anno, the more I think about it, you're absolutely right.
That was a rotten thing to say. I've responded to lots of questions on
newsgroups before, and I know it takes time and energy. All the people who
responded to me were willing to give that time and energy, and my comment
ignoerd that. Also, as I read over the posting that originally annoyed me,
I realize that it wasn't condescending in the way I thought. I guess I was
just having a lousy day.
Thanks for the eye-opener.
Joe
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:97ik65$1d7$1@mamenchi.zrz.TU-Berlin.DE...
> According to Joe Williams <joeykid6@yahoo.com>:
> > Thanks, Ren. For some reason, I thought I tested without the quotes and
got
> > an error. You win for the most concise code and the least impatient
> > response....
>
> Do you realise how arrogant that sounds?
>
> Anno
------------------------------
Date: Thu, 01 Mar 2001 02:54:10 GMT
From: "Bill Kelly" <billk@cts.com>
Subject: Re: fork() and ActiveState Perl - workarounds? (Win32 programming question)
Message-Id: <mRin6.97618$GV2.22391755@typhoon.san.rr.com>
"Kenny McCormack" <gazelle@yin.interaccess.com> wrote:
>
> I am using ActiveState build 522 (Yes, I know it is a little old, but deal
> with it - if a later version will fix the problem, that's to the good)
>
> I am porting some Unix networking code (really, just the examples from the
> Camel book) and the standard Unix model for a TCPIP server is: Accept the
> connection, then fork() off a child to service it (using the open file
> inheritance semantics of Unix) - so that the parent can accept further
> connections.
>
> Well, as you know, fork() is unimplemented in ActiveState - what is the
> generally accepted work around for this? I assume if I used system() or
> "start" to spawn a child, that it wouldn't inherit the open socket.
>
> Also, what other Win32 ports of Perl are there? Other threads here mention
> a Cygwin port - I've used the Cygwin gcc compiler - and I know that it has
> fork(), but that it only works under NT (when I run my program that has fork
> under Win98, it GPFs)
>
> Anyway, suggestions?
Well, dunno if this helps - but for whatever it's worth - though
I'm not aware of a fork() solution for ActiveState Win32 Perl,
I do have a "round-robin socket multitasker" module that works
under windows. (Admittedly I've only tried it under NT, but I'd
expect it to work under 9x!) It's at:
http://www.foosenblat.org/ftp/perl/foosenblat/net/
It's called SocketTasker.pm. The tcpproxy.pl script in that
directory uses SocketTasker so should serve as a working example.
Hope this helps !
Bill
------------------------------
Date: Thu, 01 Mar 2001 02:46:20 -0500
From: Obi Wan <obiwan@mahood.com>
To: Neb <berube@odyssee.net>
Subject: Re: Graphic file manipulation
Message-Id: <3A9DFE4C.F819967F@mahood.com>
a) hack the PerlMagick module.
b) write your data to a temp file then unlink it -- what's your bias here?
Neb wrote:
> Hi,
>
> I have a script that reads from a database an image file content (.gif or
> .jpg) into a variable. What I want to do is to resize this image and send
> it back to the client browser (content-type: image/gif).
>
> I'm trying to use Image::Magick, but the problem is that the Read method
> *needs* a FILEHANDLE to the image file. But since the image data is in
> memory, there can't seem to be a way to create the image object. Note that
> I don't want to write the image data to a file.
>
> Is there a way to bypass this problem ? Or is there an other graphic
> manipulation lib that will allow to do this ?
>
> Thanks,
>
> Ben
------------------------------
Date: 1 Mar 2001 03:57:21 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How the CLPM turns
Message-Id: <slrn99ri51.bdj.sholden@pgrad.cs.usyd.edu.au>
On Wed, 28 Feb 2001 17:16:36 -0800,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>Randal L. Schwartz wrote:
>
>> > Godzilla! wrote:
>
>> Godzilla!> Back in 1991, when you and myself were teenagers
>
>> Speak for yourself Kira. By the end of 1991, I had turned 30, and had
>> been programming for over two decades.
>
>I never trust anyone over thirty.
>
>> And your PhD in English must be a bit rusty. That'd be "when you and
>> *I* were teenagers", since you aren't performing an action on
>> yourself. Even a simple member of the uneducated class such as me can
>> grok that.
>
>My Grammar Checker is set for Informal Rules when I post
>to USENET. I reckon yall done be one of them there city
>slicker fellas with right shiny shoes and proper werds!
>
>So, you gonna write a grammar module for me?
You'd never trust his response anyway...
--
Sam Holden
------------------------------
Date: Thu, 1 Mar 2001 07:05:42 +0000 (UTC)
From: bernard.el-hagin@gdndev25.dev.lido-tech ()
Subject: Re: How the CLPM turns
Message-Id: <slrn99rt1d.3vvrgvf.bernard.el-hagin@gdndev25.dev.lido-tech>
In article <t9qssmsflc4sb1@corp.supernews.com>, Chris Stith wrote:
[snip]
>It doesn't offend me, and I doubt it would if I was included. I do feel a
>little left out considering I'm pretty regular these days (just look at the
>stats), but I guess I haven't earned my stripes just yet. :-/
I didn't include many people either because they didn't have a very
clear style I could take advantage of or had a style similar to an
already existing one. For example, I had a very tough time coming up
with something for Anno. He's one of my favourite posters, but for the
life of me I couldn't find anything to latch onto in his posts. So,
regretfully, I had to leave him out. The same goes for Ilmari, Gwynn,
nobull (actually, nobull parodied himself quite nicely in a followup to
my original post :), brian d foy, Rafael, and some others.
>While I'm at it, I'd like to thank Martien, Uri, nobull, Randal,
>Anno, Abigail, and Ilmari for helping me grow as a Perl programmer.
The people you mentioned, along with Tad McClellan, Larry Rosler, brian
d foy, Mark-Jason Dominus, Bart Lateur, and a plethora of others on this
group are directly responsible for 90% of my Perl knowledge so anytime I
see someone criticise this newsgroup I just don't get it.
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: 1 Mar 2001 02:55:37 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Opening STDERR for input
Message-Id: <slrn99refl.kkg.damian@puma.qimr.edu.au>
Thus spake nobull@mail.com on 28 Feb 2001 23:28:03 +0000:
>Bernie Cosell <bernie@fantasyfarm.com> writes:
>
>> On Unix, STDERR is standardly open for both reading and writing [try it
>> from a shell script, for example]. I was somewhat surprised to discover
>> that in Perl, STDERR is open for output-only.
> ...
>> ...
>> and the print works fine but the <> always blows up. Is there some way to
>> program around this [preferably not hugely ugly]. THANKS!
>
>Reading from file descriptor 2 is in itself hugely ugly.
>
>open X,"<&2";
>
>(If you want the special STDERR filehandle to loose it's specialness
>then you can undef(*STDERR) but that is really seriously ugly).
>
I can't quite understand why you'd want to do this anyway. One the one hand
it doesn't make sense: whose STDERR are you talking about? The current
process'? There are a zillion other ways to pass data around inside the
program. On the other hand, if it comes from some other process, then why not
just redirect it to this program (in which case, you're reading STDIN)?
Or are you trying to parse errors in some wacky way? I'm sure there are
better ways to do it...
Cheers,
Damian
--
@;=0..23;@;{@;}=split//,<DATA>;while(1){for($;=@;;--$;;){next if($:=rand($;+
1))==0+$;;@;[$;,$:]=@;[$:,$;];print "\x"for 0..2*($|+23)}print map{$;{$_}}(@|
,@;);push@|,shift@;if$;[0]==@|;last if!@;;print"\b"x(@;+@|)}print"\n"__END__
Just another Perl Hacker
------------------------------
Date: Thu, 1 Mar 2001 01:02:44 -0500
From: "Joe Williams" <joeykid6@yahoo.com>
Subject: Re: Perl CGI.pm RESET problem
Message-Id: <97kopv$eiu$1@slb5.atl.mindspring.net>
I've attached a CGI.pm test template of mine at the bottom. It's written in
function syntax rather than obj-oriented. You might find it useful as you
sift through CGI.pm. You're welcome to change it as you need to (file loc.
for errors, etc.)
I'll do my best walking through your code, and suggest a few changes to give
you continuity with CGI.pm functions if that's ok (although you may not care
particularly).
Joe
BUCK NAKED1 <dennis100@webtv.net> wrote in message
news:23575-3A9D53F1-26@storefull-243.iap.bryant.webtv.net...
> Thanks, Joe. I tried both of your suggestions ( defaults() and override
> ). I think I'm making some progress; but now my revised script changes
> the textbox to the URL of the script when I hit RESET... instead of
> clearing it. Can you tell me what I'm doing wrong?
>
> [apologies for any newsreader wrapping or odd AO characters]
>
> #!/usr/local/bin/perl -wd
> use CGI qw(fatalsToBrowser);
As you'll see in the code tester below, you might try using CGI::Carp here
for error-chek
> use CGI qw(:standard);
you might try :all, it will give you access to html 3.2 functions like
table() and div()
>
> print header;
> print "<HTML><BODY bgcolor=99CCFF topmargin=0>
start_html takes care this (see below)
> <CENTER>
>
> $query = new CGI;
>
> print $query->start_multipart_form(-method=>$method,
> -action=>$action,
> -enctype=>$encoding);
>
> print $query->textfield(-name=>'url',
> -value=>"$ENV{HTTP_REFERER}",
> -override=>1,
using override=1 here tells CGI.pm to reset the field to -value=>, which,
since the script has already run once, I imagine is now set to the address
of the script.
> -size=>60,
> -maxlength=>300);
> print "<BR>";
>
> print $query->defaults(-name=>'url',
> -value=>'RESET',
> -default=>'url');
defaults() only takes one param, a display label. You can use the
non-verbose defaults('Reset'). The other attributes are ignored by the
browser. You are emptying the param list with this, but have overridden the
textfield up above, so http_referrer remains.
>
> print " ";
>
> print $query->submit(-name=>'submit',
> -value=>'SUBMIT');
>
> print "</CENTER></BODY></HTML>";
use end_html (see below)
>
> print $query->endform;
>
>
> Regards,
> Dennis
>
#Script: html_test.pl
use CGI qw(:all -noDebug);
#Error handler
BEGIN {
use CGI::Carp qw(fatalsToBrowser set_message carpout warningsToBrowser);
sub handle_errors {
my $msg = shift;
print h1('ERROR'),
p("$msg"),
p('For help, please send mail to the ',
a({-href=>'mailto:test@test.org'},'Webmaster'),
' and report the above error message',
' and the time that it occurred.'
);
}
set_message(\&handle_errors);
open (LOG, ">>../carplog/error_log") ||
die ("Couldn't find error log: $!");
carpout(\*LOG);
}
#Header, browser warnings, JavaScript vars, title, and body tag
print header;
warningsToBrowser(1);
$jscript=<<EOJS;
ENTER TEST JAVASCRIPT HERE
EOJS
;
$no_jscript = 'This page runs JavaScript. Please activate it '.
"in your browser's properties, or update your ".
'browser as needed.';
print start_html(-title=>'Test Code',
-bgcolor=>'#FCFAF8',
-vlink=>'#9999FF',
-link=>'#0033CC',
-text=>'#000000',
-alink=>'#0000FF',
-noScript=>$no_jscript,
-script=>$jscript
);
####INSERT TEST CODE HERE
####INSERT TEST CODE HERE
print end_html;
------------------------------
Date: Thu, 1 Mar 2001 01:14:46 -0500
From: "Joe Williams" <joeykid6@yahoo.com>
Subject: Re: Perl CGI.pm RESET problem
Message-Id: <97kpgp$iui$1@slb4.atl.mindspring.net>
I just realized in my haste to modify html_test.pl for public consumption, I
set up the JavaScript var a bit unsafely. Where it says:
$jscript=<<EOJS;
ENTER TEST JAVASCRIPT HERE
EOJS
;
It should probably say (for good measure):
$jscript=<<EOJS;
/*ENTER TEST JAVASCRIPT HERE*/
EOJS
;
Joe Williams <joeykid6@yahoo.com> wrote in message
news:97kopv$eiu$1@slb5.atl.mindspring.net...
> I've attached a CGI.pm test template of mine at the bottom. It's written
in
> function syntax rather than obj-oriented. You might find it useful as you
> sift through CGI.pm. You're welcome to change it as you need to (file
loc.
> for errors, etc.)
>
> I'll do my best walking through your code, and suggest a few changes to
give
> you continuity with CGI.pm functions if that's ok (although you may not
care
> particularly).
>
> Joe
>
> BUCK NAKED1 <dennis100@webtv.net> wrote in message
> news:23575-3A9D53F1-26@storefull-243.iap.bryant.webtv.net...
> > Thanks, Joe. I tried both of your suggestions ( defaults() and override
> > ). I think I'm making some progress; but now my revised script changes
> > the textbox to the URL of the script when I hit RESET... instead of
> > clearing it. Can you tell me what I'm doing wrong?
> >
> > [apologies for any newsreader wrapping or odd AO characters]
> >
> > #!/usr/local/bin/perl -wd
> > use CGI qw(fatalsToBrowser);
> As you'll see in the code tester below, you might try using CGI::Carp here
> for error-chek
>
> > use CGI qw(:standard);
> you might try :all, it will give you access to html 3.2 functions like
> table() and div()
>
> >
> > print header;
> > print "<HTML><BODY bgcolor=99CCFF topmargin=0>
> start_html takes care this (see below)
>
> > <CENTER>
> >
> > $query = new CGI;
> >
> > print $query->start_multipart_form(-method=>$method,
> > -action=>$action,
> > -enctype=>$encoding);
> >
> > print $query->textfield(-name=>'url',
> > -value=>"$ENV{HTTP_REFERER}",
> > -override=>1,
> using override=1 here tells CGI.pm to reset the field to -value=>, which,
> since the script has already run once, I imagine is now set to the address
> of the script.
>
> > -size=>60,
> > -maxlength=>300);
> > print "<BR>";
> >
> > print $query->defaults(-name=>'url',
> > -value=>'RESET',
> > -default=>'url');
> defaults() only takes one param, a display label. You can use the
> non-verbose defaults('Reset'). The other attributes are ignored by the
> browser. You are emptying the param list with this, but have overridden
the
> textfield up above, so http_referrer remains.
>
> >
> > print " ";
> >
> > print $query->submit(-name=>'submit',
> > -value=>'SUBMIT');
> >
> > print "</CENTER></BODY></HTML>";
> use end_html (see below)
>
> >
> > print $query->endform;
> >
> >
> > Regards,
> > Dennis
> >
>
> #Script: html_test.pl
> use CGI qw(:all -noDebug);
>
> #Error handler
> BEGIN {
> use CGI::Carp qw(fatalsToBrowser set_message carpout warningsToBrowser);
> sub handle_errors {
> my $msg = shift;
> print h1('ERROR'),
> p("$msg"),
> p('For help, please send mail to the ',
> a({-href=>'mailto:test@test.org'},'Webmaster'),
> ' and report the above error message',
> ' and the time that it occurred.'
> );
> }
> set_message(\&handle_errors);
> open (LOG, ">>../carplog/error_log") ||
> die ("Couldn't find error log: $!");
> carpout(\*LOG);
> }
>
> #Header, browser warnings, JavaScript vars, title, and body tag
> print header;
> warningsToBrowser(1);
>
> $jscript=<<EOJS;
>
> ENTER TEST JAVASCRIPT HERE
>
> EOJS
> ;
>
> $no_jscript = 'This page runs JavaScript. Please activate it '.
> "in your browser's properties, or update your ".
> 'browser as needed.';
>
> print start_html(-title=>'Test Code',
> -bgcolor=>'#FCFAF8',
> -vlink=>'#9999FF',
> -link=>'#0033CC',
> -text=>'#000000',
> -alink=>'#0000FF',
> -noScript=>$no_jscript,
> -script=>$jscript
> );
>
> ####INSERT TEST CODE HERE
>
>
>
> ####INSERT TEST CODE HERE
>
> print end_html;
>
>
------------------------------
Date: Wed, 28 Feb 2001 19:47:21 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: print "</tr><tr>" vs. print $tr
Message-Id: <slrn99r70p.kbn.tadmc@tadmc26.august.net>
Bernie Cosell <bernie@fantasyfarm.com> wrote:
>Stan McCann <stan_no_spam_for_me@alamo.nmsu.edu> wrote:
>} so I have gone to using something more like for easy
>} reading and clarity in my code:
>}
>} print "<tr>";
>} print "<td>cell 1</td>";
>} print "<td>cell 2</td>";
>} print "</tr>";
>
>Actually, I end up looking at the HTML output a fair bit, also, and so I've
>gone to:
> print "<tr>\n" ;
> print " <td>cell 1</td>\n" ;
> print " <td>cell 2</td>\n" ;
> print "</tr>\n";
You should both goto using here-docs :-)
print <<ENDROW; # now it looks even more like the real output will look
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
ENDROW
>Generally, I try to write the most robust, clear, clean, easy-to-apprehend
>code that I can, get the program debugged and rock-solid, and THEN and
>_only_then_, if [and that's a _big_ if!] the program has performance
>problems I'll profile/analyze it and fix *just* what needs fixing.
Amen brother!
(given that you have done careful thinking about the basic
algorithm before any coding.
)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 28 Feb 2001 22:43:25 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: Problem with Win32::EventLog
Message-Id: <3A9DC55D.981E779E@patriot.net>
Is the remote system in your domain? Do you have admin access to the
remote system?
Have you tried retrieving the error message, perhaps with
Win32::GetLastError()?
WichersWeb wrote:
> I've got he following problem.
> When I try to connect the local computer with
>
> new Win32::EventLog("System", "\\\\WS28") || die "dan niet";
>
> everything goes fine.
> But when I really try to connect a remote computer it doesn't work.
>
> any ideas?
------------------------------
Date: Thu, 01 Mar 2001 08:13:33 +0100
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: problem with {q}?
Message-Id: <8htr9t00tbtor0o3m7ib2c91f52j00slep@4ax.com>
On Wed, 28 Feb 2001 15:35:30 -0500, Bernie Cosell <bernie@fantasyfarm.com>
wrote:
> Michael Carman <mjcarman@home.com> wrote:
>
> } Bernie Cosell wrote:
> } >
> } > } { print @_ unless $opts{q} ; }
> } >
> } > I don't exactly understand why [...] I get
> } > >>> Ambiguous use of {q} resolved to {"q"}
> } >
> } > What was 'q' ambiguous with?
> }
> } The alternative single quote syntax, e.g.
> }
> } my $string = q(Some string with '' in it);
>
> DRAT!! I completely forgot about that guy... sigh... It is all crystal
> clear.. DUH... so I guess I shouldn't change the hash key to qq
> either..:o)
Nor m, nor s, nor y.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Thu, 01 Mar 2001 07:40:54 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: problem with {q}?
Message-Id: <slrn99rv7h.32t.rgarciasuarez@rafael.kazibao.net>
Darren Dunham wrote in comp.lang.perl.misc:
> Bernie Cosell <bernie@fantasyfarm.com> wrote:
>
> >>>> Ambiguous use of {q} resolved to {"q"}
>
> > What was 'q' ambiguous with? I just looked through my program and I
> > for-sure don't have a symbol named 'q'.. why would just that one hash-key
> > be ambiguous but the others not? In case it is some package messing with
> > me, the program includes only:
>
> It is ambiguous because there is a function called 'q'.
>
> It assumed (and told you) that you wanted %hash{"q"} rather than
> %hash{q()}.
Maybe it's time to correct a small misunderstanding here : q() is not a
function, it's an operator. Perl doesn't parse it as a function :
$ perl -le 'sub foo{};foo(#);print"OK"'
syntax error at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
$ perl -le 'q(#);print"OK"'
OK
(Moreover, it's described in perlop, not in perlfunc).
Note also that you can use other delimiters with q() : q//, q!!, q##,
q{}, q**, etc. etc.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
Much programming is best done with techniques that do not fall within a
narrow definition of "object-oriented." -- Bjarne Stroustrup
------------------------------
Date: Wed, 28 Feb 2001 22:03:02 -0500
From: Jay Tilton <nouser@emailunwelcome.com>
Subject: Re: regex help needed
Message-Id: <43dr9tg8rcuj4k2263f6lsflp797tr1tmh@4ax.com>
Cryofan <donotreply@interbulletin.bogus> wrote:
>Well, I have already looked at m & s; they don't seem to help. The others you list look helpful in general, but I don't see how they could solve my problem.
Guess the clue was too subtle. Changing that regex to...
$array1[$num_words-1] =~ s/>.*$/$blank/s;
^
...will fix the problem. That one character change is the "/s"
modifier I mentioned. Its effect is to let a '.' match a newline,
which it normally doesn't. Without it, s/>.*$// was stripping
everything after a '>' on only the last line of the string.
The other functions mentioned are just suggestions on built-ins that
would do a lot of the work you're stepping through manually.
Instead of...
> $array2[$num_links]=$somestring;
> $num_links++;
use...
push @array2, $somestring;
Throw out all that jazz with assigning/reading an array element then
incrementing/decrementing an index. Your real friends are push, pop,
shift, unshift, and $#.
Instead of...
> if($array1[$num_words-1] =~/^http\:\/\/biz\.yahoo\.com\/rb\/.*/)
> {
> $array1[$num_words-1] =~ s/>.*$/$blank/;
> $somestring= $array1[$num_words-1];
> $array2[$num_links]=$somestring;
> $num_links++;
> }
use...
@array2=grep s#(\Qhttp://biz.yahoo.com/rb/\E.*?)>.*#$1#s, @array1;
Going one step further makes even grepping too much work.
Instead of...
> $blank="";
> @array1= split(/href=/,$content);
> $num_links=0;
> $num_words = @array1;
> while($num_words > 0)
> {
> if($array1[$num_words-1] =~/^http\:\/\/biz\.yahoo\.com\/rb\/.*/)
> {
> $array1[$num_words-1] =~ s/>.*$/$blank/;
> $somestring= $array1[$num_words-1];
> $array2[$num_links]=$somestring;
> $num_links++;
> }
> $num_words--;
> }#end while $num_words > 0
use...
@array2 = $content =~ m#(\Qhttp://biz.yahoo.com/rb/\E.*?\.html?)#g;
# Assuming the href's desired are all .html or .htm ^^^^^^^
With the right regex incantations, Perl can do a lot of your
programming for you.
------------------------------
Date: 01 Mar 2001 02:50:40 GMT
From: anotherway83@aol.com (The Mosquito ScriptKiddiot)
Subject: Re: regex help please
Message-Id: <20010228215040.14342.00000895@ng-cg1.aol.com>
>In that case, you'll still have similar but much bigger problems to
>solve.
>I once wrote something similar. Having some LISP background for AI, I
>first converted the infix to prefix (I find prefix notation easier to
>manipulate on a symbolic level, than infix), applied the derivation
>rules to that, and then... simplify.
>Ouch. Even with relative small
>problems, it's easy to run out of memory. Multi-megabytes. The problem
>was something in the neighbourhood of 6th derivative of tan(x).
yep...that must have been difficult as hell
but i'm nowhere near that level of programming yet...long way to go in perl..
this derivative program will only solve for expressions that :
1:do not have any variables/functions as exponents.
for instance, 2 ^ x will not be solved
and 2 ^ tan x will also not be solved
2:it won't do derivatives of functions like tan, sin or cos, or anything more
complicated, like sinh...
that means it will only do derivatives like
(2x^3-4/x+5.67^4*(x+3)) and so on
as for the memory part and stuff, i don't even know how to find out how much
memory my program uses, or even how fast it will be when its finished
heck, before i can put it up, i'll have to learn CGI and then find a decent
host
all that will take at least a few weeks...
thanks
peace
The Mosquito ScriptKiddiot
Championing the Cause of Mosquitoes in Technology
------------------------------
Date: Thu, 01 Mar 2001 03:17:06 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: regex help please
Message-Id: <3A9DBF8E.F4C3F719@rochester.rr.com>
Bart Lateur wrote:
>
> The Mosquito ScriptKiddiot wrote:
>
> >this is a pet-project of my own, i wanna put it up on my
> >own website...this problem needs to be solved, because it will be used in a
> >larger program that solves derivatives in calculus
>
> In that case, you'll still have similar but much bigger problems to
> solve.
>
> I once wrote something similar. Having some LISP background for AI, I
> first converted the infix to prefix (I find prefix notation easier to
> manipulate on a symbolic level, than infix), applied the derivation
> rules to that, and then... simplify. Ouch. Even with relative small
> problems, it's easy to run out of memory. Multi-megabytes. The problem
> was something in the neighbourhood of 6th derivative of tan(x).
You mean 32 * sec^2(x) * tan^5(x) + 416 * sec^4(x) * tan^3(x) + 272 *
sec^6(x) * tan(x) ? That's not difficult.
>
> --
> Bart.
--
Bob Walton
------------------------------
Date: 01 Mar 2001 05:40:34 GMT
From: anotherway83@aol.com (The Mosquito ScriptKiddiot)
Subject: Re: regex help please
Message-Id: <20010301004034.02169.00000282@ng-md1.aol.com>
>You mean 32 * sec^2(x) * tan^5(x) + 416 * sec^4(x) * tan^3(x) + 272 *
>sec^6(x) * tan(x) ? That's not difficult.
maybe, maybe not, i haven't given it too much thought yet, but my initial
thought was that it was too difficult
in any case, doing a simpler derivative program first should definitely help,
because alot of the ideas used in the simpler program will also be used in any
other derivative program thats more complicated
plus, its not like im going for a web-version of MuPad...or Derive...or
Mathematica..hahaha
peace
The Mosquito ScriptKiddiot
Championing the Cause of Mosquitoes in Technology
------------------------------
Date: Thu, 1 Mar 2001 08:53:23 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: regex help please
Message-Id: <97kv2b$5nh$1@newsy.ifm.liu.se>
> >
> > > $ perl -e '$_ = "( ( ( ( ( ( x - ( 2 + ( 2x + 3 ( 4x + 5 ) - 8.345 )
^ -
> > > 4 * ( 5 - x / 2 ) + 4 ) - 6 ) ) ) ) ) )"; i while
> > > s/^\s*\(\s*(\(.+\))\s*\)\s*$/$1/g; print "$_\n";'
> > > ( x - ( 2 + ( 2x + 3 ( 4x + 5 ) - 8.345 ) ^ - 4 * ( 5 - x / 2 ) +
4 ) -
> > > 6 )
> >
> > This doen't work for ((x-1))((y-3)). Mine example does :)
> > /jN
>
>
> 1 while s/\(\s*(\(\s*[^)(].+?[^)(]\s*\))\s*\)/$1/g;
>
> John
It still doesn't work for things like ((x))((y)). It will give with your
example: (x))((y) (Which isn't valid I guess)
The real challenge is to write a _single_ regexp which works like mine
example. That is which does theese conversions:
((x))((y)) => (x)(y)
((x)(y)) => ((x)(y))
(( (x) ((y)) )) => ((x)(y))
((x)(y ((z)) )) => ((x)(y(z)))
Can you do it? ;-)
/jN
--
_____________________ _____________________
| Jonas Nilsson | | |
|Linkoping University | | Telephone |
| IFM | | --------- |
| Dept. of Chemistry | | work: +46-13-285690 |
| 581 83 Linkoping | | fax: +46-13-281399 |
| Sweden | | home: +46-13-130294 |
|_____________________| |_____________________|
------------------------------
Date: Thu, 1 Mar 2001 08:55:36 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: regex help please
Message-Id: <97kv6g$60r$1@newsy.ifm.liu.se>
> holy cow, that works awesumly well
>
> thank u, thank u thank u...
>
> thanks also to all those who replied
>
> this has solved my problem:)
These are the kind of challenges which is funny to work with. I'm glad to
help... ;o) /jN
--
_____________________ _____________________
| Jonas Nilsson | | |
|Linkoping University | | Telephone |
| IFM | | --------- |
| Dept. of Chemistry | | work: +46-13-285690 |
| 581 83 Linkoping | | fax: +46-13-281399 |
| Sweden | | home: +46-13-130294 |
|_____________________| |_____________________|
------------------------------
Date: Thu, 01 Mar 2001 00:44:04 -0600
From: cdh <cdh@ala.net>
Subject: Re: Secret planned perl feature revealed
Message-Id: <3A9DEFB4.92861F0A@ala.net>
Lou Moran wrote:
> #!/usr/bin/perl -w
> #use strict;
>
> my $insaneramblings = 1;
^^
Quite glad you chose you own up to that;)
> print "\nWhy did you post this here?\n\n"
I could ask the same of you, you obviously didn't get it.
To answer your question though, I posted it because it is
perl related. It exposes a minor bug in perl that's a little
on the humourous side.
> unless $insaneramblings eq "0";
Are they ever?
Don't take the things I said personally though, I'm just having
a little fun with you even if you weren't with me. Lighten up.
Cheers,
Chris Hickman
------------------------------
Date: Thu, 01 Mar 2001 03:26:22 GMT
From: Kjetil Skotheim <kjetil.skotheim@usit.uio.no>
Subject: Re: Slow down
Message-Id: <3A9DC235.83336B0C@usit.uio.no>
I guess you are running your program on Win9x/NT by double-clicking the .pl
file?
Try adding the following to make it pause a bit before endring:
END{sleep(10)}
Or maybe even better:
END{<STDIN>} #waits for you to press Return
Or you might open an MS-DOS-window (or better: a Cygwin-bash-shell-window)
and run "perl yourprogram.pl" after cd'ing into the rigth directory.
Adam wrote:
> Most perl programs I run just blink on and right nback off. I'd sometimes
> like to see the output of a program. How can I make perl wait before it
> shuts the screen down? (active perl windows 98)
> Also, I don't fully understand how the output from a program gets
> displayed on a web page, With SSI or without. Can someone please clarify?
> Adam T.
> sks@sierra.net
>
> --
> Posted via CNET Help.com
> http://www.help.com/
------------------------------
Date: Thu, 01 Mar 2001 03:27:17 GMT
From: Kjetil Skotheim <kjetil.skotheim@usit.uio.no>
Subject: Re: Slow down
Message-Id: <3A9DC26C.61FBDD40@usit.uio.no>
I guess you are running your program on Win9x/NT by double-clicking the .pl
file?
Try adding the following to make it pause a bit before endring:
END{sleep(10)}
Or maybe even better:
END{<STDIN>} #waits for you to press Return
Or you might open an MS-DOS-window (or better: a Cygwin-bash-shell-window)
and run "perl yourprogram.pl" after cd'ing into the rigth directory.
Adam wrote:
> Most perl programs I run just blink on and right nback off. I'd sometimes
> like to see the output of a program. How can I make perl wait before it
> shuts the screen down? (active perl windows 98)
> Also, I don't fully understand how the output from a program gets
> displayed on a web page, With SSI or without. Can someone please clarify?
> Adam T.
> sks@sierra.net
>
> --
> Posted via CNET Help.com
> http://www.help.com/
------------------------------
Date: Thu, 01 Mar 2001 03:41:44 GMT
From: "Dave Brondsema" <brondsem@my-deja.com>
Subject: Re: Slow down
Message-Id: <Yxjn6.13111$W05.2997569@news1.rdc1.mi.home.com>
"adam" <sks@sierra.net> wrote in message
news:t9r2g9iapeu897@corp.supernews.com...
> Most perl programs I run just blink on and right nback off. I'd sometimes
> like to see the output of a program. How can I make perl wait before it
> shuts the screen down? (active perl windows 98)
> Also, I don't fully understand how the output from a program gets
> displayed on a web page, With SSI or without. Can someone please
clarify?
> Adam T.
> sks@sierra.net
>
>
Kjetil was right on concerning your first question.
For your second:
If I type type the address of a perl program into my browser, like
http://some.thing.com/test.pl
the test.pl program is run on the server computer. It basically runs just
like it does when you run it on your home computer. The difference is that
instead of the output of the program being displayed in a dos window, the
output is sent across the internet back to my browser. My browser recieves
the output as an html file, it doesn't know if perl created the html file or
if test.pl was actually a regular html file.
For this whole process to work, a web server needs to be running. If you
want to test your programs on your computer, you need to install a web
server (such as Msft's personal web server or AnalogX's,
http://www.analogx.com, SimpleServer) in addition to perl.
Otherwise, find a free host that supports perl.
As far as SSI, I haven't used it before, but I'm guessing that it does its
stuff after perl creates the html file and before the html is delivered to
the user's browser.
Hope that helps,
Dave Brondsema
------------------------------
Date: Wed, 28 Feb 2001 21:46:17 -0600
From: "Scuttlebutt" <jbailey@cyberconnect.com>
Subject: Re: Slow down
Message-Id: <97kgsj$9q1$1@news.chatlink.com>
Open a DOS window and CHDIR to /Perl/bin, then run your program (which
should be in bin). The output from your program is up to you. The default
(STDOUT) would be the DOS window. You can also create an HTML page using
"Print <HTML>....." statements or Lincoln Stein's CGI.pm module. You need
to have an active web server of course, to serve these pages dynamically to
others.
"adam" <sks@sierra.net> wrote in message
news:t9r2g9iapeu897@corp.supernews.com...
> Most perl programs I run just blink on and right nback off. I'd sometimes
> like to see the output of a program. How can I make perl wait before it
> shuts the screen down? (active perl windows 98)
> Also, I don't fully understand how the output from a program gets
> displayed on a web page, With SSI or without. Can someone please
clarify?
> Adam T.
> sks@sierra.net
>
>
> --
> Posted via CNET Help.com
> http://www.help.com/
------------------------------
Date: Thu, 1 Mar 2001 15:11:02 +1300
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: Slow down
Message-Id: <97kb3p$u95$1@hermes.nz.eds.com>
"adam" <sks@sierra.net> wrote in message
news:t9r2g9iapeu897@corp.supernews.com...
> Most perl programs I run just blink on and right nback off. I'd sometimes
> like to see the output of a program. How can I make perl wait before it
> shuts the screen down? (active perl windows 98)
> Also, I don't fully understand how the output from a program gets
> displayed on a web page, With SSI or without. Can someone please
clarify?
> Adam T.
> sks@sierra.net
Start->Programs->ActiveState ActivePerl->Documentation
Look at Readme in the Getting Started.
Also look at "Web programming" under the ActivePerl FAQ.
Documentation is a truely wonderous thing.
------------------------------
Date: Thu, 1 Mar 2001 13:47:15 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Slow down
Message-Id: <nUjn6.23$2H1.3477@vic.nntp.telstra.net>
"Dave Brondsema" <brondsem@my-deja.com> wrote in message
news:Yxjn6.13111$W05.2997569@news1.rdc1.mi.home.com...
>
>
> As far as SSI, I haven't used it before, but I'm guessing that it does
its
> stuff after perl creates the html file and before the html is
delivered to
> the user's browser.
Actually, with SSI, the server reads tags within the html, and performs
actions accordingly. In order to do that, it needs to know that the
file being served is one it needs to parse for those commands. That is
why documents containig SSI commands are usually called *.shtml (server
parsed html).
I have not ever been able (possibly for want of trying) to include SSI
commands in a cgi script, but I don't think I would really want to
anyway. Anythin the SSI can do, the cgi can do (usually better), and
the added overhead is not usually worth it.
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 382
**************************************