[18440] in Perl-Users-Digest
Perl-Users Digest, Issue: 608 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 3 00:12:27 2001
Date: Mon, 2 Apr 2001 21:10:48 -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: <986271047-v10-i608@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 2 Apr 2001 Volume: 10 Number: 608
Today's topics:
Re: Funny behavior? (Gwyn Judd)
Re: Funny behavior? <bcoon@sequenom.com>
Re: Funny behavior? <bmb@ginger.libs.uga.edu>
Re: GD::Graph again (Martien Verbruggen)
Re: GD::Graph again <nobody@nowhere.com>
Re: Getting Character Codes (Tad McClellan)
Help with $variable parsing. <server1@server.net>
Re: Help with CGI scripts <webmaster@webdragon.unmunge.net>
Re: Help with CGI scripts <keesh@users.pleaseremovethisbit.sourceforge.net>
Re: Help with CGI scripts (Garry Williams)
Re: Hmmm... Which PERL Book Is Best Suited For This??? <jacko_england@hotmail.com>
Re: Hmmm... Which PERL Book Is Best Suited For This??? <uri@sysarch.com>
Re: Hmmm... Which PERL Book Is Best Suited For This??? <webmaster@webdragon.unmunge.net>
How do I combine these <huem@MailAndNews.com>
Re: How do I combine these <wyzelli@yahoo.com>
Re: how do you pass 2 hash to a sub (Dowe Keller)
Re: How to post to a newsgroup from a script? <goldbb2@earthlink.net>
Re: How to split or sub on multiple spaces <admin@gatordev.net>
How to use Net::SMTP through a firewall (proxy)? <djmarcus@ex-pressnet.com>
Re: Image Reloading Problem <iltzu@sci.invalid>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 31 Mar 2001 08:38:07 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Funny behavior?
Message-Id: <slrn9cb9n8.ju7.tjla@thislove.dyndns.org>
I was shocked! How could Uri Guttman <uri@sysarch.com>
say such a terrible thing:
>type of thingy is a here doc? it is a piece of data. in fact it is just
>another form of a quoted string. so where is all the forms of perl data
Well, if it is just another type of quoted string, why isn't it in
perlop under the section on "Quote and Quote-like Operators?" That was
where I thought to look for it.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"Why are you doing this?"
'Did I make you laugh?'
"Yes."
'Then my job here is done.'
-- Ivanova and Marcus, "Messages From Earth"
------------------------------
Date: Mon, 02 Apr 2001 10:07:03 -0700
From: Bryan Coon <bcoon@sequenom.com>
Subject: Re: Funny behavior?
Message-Id: <3AC8B1B6.667A71B0@sequenom.com>
As the original poster of this thread, first I want to thank Chris for
his helpful advice. He answered my question perfectly, and I appreciate
him taking his time to help out, as I see he does with so many people
here.
Just a note as to the whole 'you are supposed to check the faq' topic...
The problem with perl for me (as a programmer in another language) is
simply where to find information. Not because there is so little of it
of course, but because there is a flood of it. Between the perl docs for
each module, the core perl docs, the usenet groups, mailing lists, and
the perl faq (those are just the ones I know of) it is sometimes a
challenge to sort and sift to find the information you are looking for.
And it is even more difficult if you are not even sure WHAT you are
looking for!
It is probably fair to say that 95% or more of what people ask here is in
some documentation somewhere. So in that respect, most people should
RTFM, or check the faq, etc. But for some (including myself) of us who
are embedded in the learning curve of perl, there are of course a
gazillion things we dont know. For example, I had no idea that 'perldoc
-q '<<'' was the answer to my question. Perhaps it was obvious to
everyone else out there, but not me.
So in this case how am I 'supposed to check the faq'? Chris's response
was very helpful, and I appreciate that. But telling me that I am
supposed to check the faq, when in essense the questiion is how to find
this in the faq is not helpful. Clearly, if I had known how to find it
in the faq, I would not have posted it.
But this is par for the course. I expect to see a 'RTFM' or 'you are
supposed to check the FAQ' on my posts. I am not a perl guru (yet).
I may miss information that is painfully obvious to everyone else, even
after searching for hours. I will try to learn as much as I can from any
other sources before resorting to usenet. But if I can't find something,
usenet is where I have to go.
Thanks,
Bryan
> On Sat, 31 Mar 2001 02:28:32 -0000, Chris Stith
> <mischief@velma.motion.net> wrote:
>
> >Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
> >> On Fri, 30 Mar 2001 06:50:16 -0500, tadmc@augustmail.com (Tad
> >> McClellan) wrote:
> >
> >>>Operator error is not the same as a broken tool.
> >>>
> >>> perldoc -q '\bhere'
> >
> >> No documentation for perl FAQ keyword `'\bhere'' found
> >
> >> However, I find that
> >
> >> perldoc -q "\bhere"
> >
> >> produces the desired result.
> >
> >This is a Microsoft issue, not a Perl or perldoc issue.
>
> <snip>
>
> I've been over this a bit with Tad and Chris over the weekend through
> e-mail and I thank them both for their time. Let me repeat my apology
> to Chris for not making it clearer that my 'unhelpful' implication was
> intended to refer only to the 'read the FAQ' reference and not to
> Chris' other advice, which was indeed helpful.
>
> I was intending to copy some of my response to the group, but looking
> through the other posts, there doesn't seem to be much point at this
> stage. It's interesting that there appears to be a consensus that, in
> the case of here docs, the relevant Perl documentation should be
> easier to find. Perhaps it would be easier if they were called
> something else - where does the term come from, anyway?
>
> Since I now know that my news server keeps messages long enough for
> them to survive the weekend, I won't go the e-mail route again. Next
> time I'll just wait for Monday.
>
> Phil
> --
> @x=split//,'Just another Perl decoder,';split//,'*'x@x;%i=split/=/,
> 'AA=a=aa= =1=,';for$i(0..$#x){$_[$i]=chr($=+5);while($_[$i]ne$x[$i])
> {$_[$i]=$i{$_[$i]}if$i{++$_[$i]};print@_,"\r";while(rand!=rand){}}}
> Ignore coming events if you wish to send me e-mail
------------------------------
Date: Mon, 2 Apr 2001 15:21:16 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Funny behavior?
Message-Id: <Pine.A41.4.21.0104021509230.19084-100000@ginger.libs.uga.edu>
On Mon, 2 Apr 2001, Bryan Coon wrote:
> Just a note as to the whole 'you are supposed to check the faq' topic...
> The problem with perl for me (as a programmer in another language) is
> simply where to find information. Not because there is so little of it
> of course, but because there is a flood of it.
I find this apropos:
The following two statements are usually both true:
There's not enough documentation.
There's too much documentation.
[Larry Wall in `close(STDOUT) breaks unrelated FileHandle'
<199709020026.RAA08431@wall.org>]
Regards,
Brad
PS: Please don't post jeopardy style.
------------------------------
Date: Tue, 03 Apr 2001 02:37:26 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: GD::Graph again
Message-Id: <slrn9cidr6.jrg.mgjv@verbruggen.comdyn.com.au>
On Mon, 02 Apr 2001 15:29:39 -0700,
Bryan Coon <bcoon@sequenom.com> wrote:
> I am trying to accomplish this goal:
> 1. Draw something on an image using GD (successful)
> 2. Use same image to plot a graph on (also successful)
> 3. Have the graph have a certain format (not successful)
>
> Ideally, I would like to plot a kind of density graph (I was using bars
> because I thought it would be the most visible). I have 40 increments,
> each increment has a value. I am trying to plot these 40 increments on
> the y axis, and plot each corresponding value horizontally. A cartoon:
>
> 1 xxxx
> 2 xx
> 3 xxxxxxxxx
> 4 xx
> 5 xxxxx
but rotated 90 degrees, right? GD::graph doesn't do horizontal charts
at the moment.
> I would like to have no labels, just visualization of which row has a
> greater value, in this format.
>
> Here is a chunk of my code, where the first dataset is the number of
> increments, the second is the values:
>
> #!/usr/bin/perl -w
>
> use CGI qw(:standard);
I don't see any CGI stuff in here :)
> use GD;
> use GD::Graph::mixed;
If you're going to use bars, you should probably use GD::Graph::bars.
In this case it works, since mixed requires bars itself,but in the
general case it doesn't work.
> my @data = ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 2, 5, 2, 0, 1, 0, 6,
> 1, 4]);
> my $graph = new GD::Graph::bars(500, 500);
> $graph->set( y_max_value=>40,
> x_max_value=>50,
> y_tick_number=>40,
> y_label_skip=>2,
> cumulate=>1);
To get rid of the y axis labels, and the ticks:
y_number_format => "",
y_tick_number => 0,
If you also want to get rid of the bounding box you could set the
foreground colour to the background color, which by default is white:
fgclr => 'white';
Note that this doesn't necessarily give a pretty result.
> my $gd = $graph->plot(\@data);
> $im->copy($gd, 0, 0, 0, 0, 500, 500);
>
> open(OUT, "> /home/dev/out.png");
you should check for success here.
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed,
Commercial Dynamics Pty. Ltd. | destroy all evidence that you tried.
NSW, Australia |
------------------------------
Date: Mon, 02 Apr 2001 19:57:33 -0700
From: Nobody <nobody@nowhere.com>
Subject: Re: GD::Graph again
Message-Id: <3AC93C1D.85419980@nowhere.com>
Thanks for the info Martien, very helpful!
I will certainly give this a shot. Sorry for the use CGI thing :) I just
yanked it out and pasted it in. This is my hack script, I had already tried
to do a bunch of things.
But do you know any way to do these graphical histograms short of having to
draw the lines manually with GD? I would love to have a nice histogram plot
that is simple and horizontal. Maybe Ill have to write the module myself :)
Thanks,
Bryan
Martien Verbruggen wrote:
> On Mon, 02 Apr 2001 15:29:39 -0700,
> Bryan Coon <bcoon@sequenom.com> wrote:
> > I am trying to accomplish this goal:
> > 1. Draw something on an image using GD (successful)
> > 2. Use same image to plot a graph on (also successful)
> > 3. Have the graph have a certain format (not successful)
> >
> > Ideally, I would like to plot a kind of density graph (I was using bars
> > because I thought it would be the most visible). I have 40 increments,
> > each increment has a value. I am trying to plot these 40 increments on
> > the y axis, and plot each corresponding value horizontally. A cartoon:
> >
> > 1 xxxx
> > 2 xx
> > 3 xxxxxxxxx
> > 4 xx
> > 5 xxxxx
>
> but rotated 90 degrees, right? GD::graph doesn't do horizontal charts
> at the moment.
>
> > I would like to have no labels, just visualization of which row has a
> > greater value, in this format.
> >
> > Here is a chunk of my code, where the first dataset is the number of
> > increments, the second is the values:
> >
> > #!/usr/bin/perl -w
> >
> > use CGI qw(:standard);
>
> I don't see any CGI stuff in here :)
>
> > use GD;
> > use GD::Graph::mixed;
>
> If you're going to use bars, you should probably use GD::Graph::bars.
> In this case it works, since mixed requires bars itself,but in the
> general case it doesn't work.
>
> > my @data = ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 2, 5, 2, 0, 1, 0, 6,
> > 1, 4]);
> > my $graph = new GD::Graph::bars(500, 500);
> > $graph->set( y_max_value=>40,
> > x_max_value=>50,
> > y_tick_number=>40,
> > y_label_skip=>2,
> > cumulate=>1);
>
> To get rid of the y axis labels, and the ticks:
>
> y_number_format => "",
> y_tick_number => 0,
>
> If you also want to get rid of the bounding box you could set the
> foreground colour to the background color, which by default is white:
>
> fgclr => 'white';
>
> Note that this doesn't necessarily give a pretty result.
>
> > my $gd = $graph->plot(\@data);
> > $im->copy($gd, 0, 0, 0, 0, 500, 500);
> >
> > open(OUT, "> /home/dev/out.png");
>
> you should check for success here.
>
> Martien
> --
> Martien Verbruggen |
> Interactive Media Division | If at first you don't succeed,
> Commercial Dynamics Pty. Ltd. | destroy all evidence that you tried.
> NSW, Australia |
------------------------------
Date: Sat, 31 Mar 2001 08:08:31 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Getting Character Codes
Message-Id: <slrn9cblme.pdm.tadmc@tadmc26.august.net>
peter.reid2000@ntlworld.com <peter.reid2000@ntlworld.com> wrote:
>Is there anyway in Perl to get the character code (Asc) of a letter
perldoc -f ord
and it works on _all_ characters, not just letters :-)
>and also
>return a letter from the character code (Chr)???
perldoc -f chr
>I would be most grateful if
>anyone could e-mail me with an answer.
But then nobody else will get the benefit of the answer.
Ask it here, get the answer here (maybe).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 31 Mar 2001 15:15:19 GMT
From: "Server1" <server1@server.net>
Subject: Help with $variable parsing.
Message-Id: <bwmx6.2903$z4.1149861@typhoon.tampabay.rr.com>
Greeting all,
I am currently working on a project that will read in perl source code
and I need help. what I need the script to do is:
1) open a perl/cgi script for reading access.
2) search source for variables leading with "$".
3) display the variable name. (NOT the value.) e.g.: If found, the variable
$variable would display "$variable" without quotes.
below is a portion of my code.
#__START_OF_CODE___________________________________#
open(FILE, "<some_source_file") || die "Couldn't open source file: $!\n";
@source = <FILE>;
foreach $findvariable(@source){
chomp($findvariable);
if ($findvariable =~ /\$/) {
print "I've spotted the variable: $findvariable\n";
}
}
#__END_OF_CODE_____________________________________#
thanx in advance
Tony.
------------------------------
Date: 2 Apr 2001 19:13:31 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Help with CGI scripts
Message-Id: <9aaj0r$q95$0@216.155.32.18>
In article <9aaeea$ag4$1@news8.svr.pol.co.uk>,
"Ciaran McCreesh" <keesh@users.pleaseremovethisbit.sourceforge.net>
wrote:
| > first, you'll need telnet access.. then find out where your ISP keeps
| > their web error logs.
| >
| > Example 1: sh-2.00$ cat /var/weblog/magpage_error_log |grep 'sgodin'
| > |grep 'Feb 14' |less
|
| I'm using SSH rather than Telnet (cos my server's posh), we've been told
heeheehee :-)
| to stay away from the logs because all the grepping is eating up CPU
And here I thought CPU's were getting more and more powerful these
days.. (:
| time... I find it's quicker to just ./ the script...
yeah, I suppose you could do that, but that won't help you (easily) if
the CGI is multi-stage, i.e. the errors only occur after you've input
the variables, submitted, previewed the results, submitted again, and
are anticipating the finished output in the third stage... (like one I'm
currently working on that takes input, creates a HTML-format readme file
from a template, and then e-mails the result to the user for including
with a submission.
| > Example 2: sh-2.00$ tail -f /var/weblog/magpage_error_log
| >
| > and then go to the script generating the errors (and make it generate
| > them) and watch for them to appear in the shell window. :)
|
| That's neat, hadn't thought of that...
Yeah it's a nice trick :) very useful.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Mon, 02 Apr 2001 18:56:01 +0100
From: "Ciaran McCreesh" <keesh@users.pleaseremovethisbit.sourceforge.net>
Subject: Re: Help with CGI scripts
Message-Id: <9aaeea$ag4$1@news8.svr.pol.co.uk>
In article <9a9taa$mjv$4@216.155.32.18>, "Scott R. Godin"
<webmaster@webdragon.unmunge.net> wrote:
> In article <9a7ahp$gkp$1@newsg3.svr.pol.co.uk>,
> "Ciaran McCreesh" <keesh@users.pleaseremovethisbit.sourceforge.net>
> wrote:
> | That's only if you have access to the error logs, and they're verbose
> | enough to be of help, and you aren't sharing a server with several
> | thousand other people... Sure, if it's your own server it's dead easy
> but
> | if you're using someone else's it isn't always...
>
> there's a couple of ways to do this depending on _how_ you want to deal
> with it:
>
> first, you'll need telnet access.. then find out where your ISP keeps
> their web error logs.
>
> Example 1: sh-2.00$ cat /var/weblog/magpage_error_log |grep 'sgodin'
> |grep 'Feb 14'
> |less
I'm using SSH rather than Telnet (cos my server's posh), we've been told
to stay away from the logs because all the grepping is aeting up CPU
time... I find it's quicker to just ./ the script...
> Example 2: sh-2.00$ tail -f /var/weblog/magpage_error_log
>
> and then go to the script generating the errors (and make it generate
> them) and watch for them to appear in the shell window. :)
That's neat, hadn't thought of that...
Thanks,
Ciaran
------------------------------
Date: Sun, 01 Apr 2001 00:21:52 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Help with CGI scripts
Message-Id: <slrn9cct50.rl0.garry@zfw.zvolve.net>
On Fri, 30 Mar 2001 20:07:52 +0100, Ciaran McCreesh
<keesh@users.pleaseremovethisbit.sourceforge.net> wrote:
> In article <3AC4C2D9.601E52E0@avellano.datsi.fi.upm.es>, "Jose Luis
> Lombana Aramendia" <jlombana@avellano.datsi.fi.upm.es> wrote:
>> require "headers.pl";
>>
>> after #!/usr/local/bin/perl, I get
>>
>> 500 Server Error
>
> 1) Check the file exists and is in path
> 2) Check permissions
> 3) Check file returns true
> 4) Check the code
> 5) Run the script from command line and look for more debug info
How about skipping all that guessing and read the server's error log
to find out? Why is that so hard?
--
Garry Williams
------------------------------
Date: Sun, 01 Apr 2001 04:20:33 GMT
From: "Jacko" <jacko_england@hotmail.com>
Subject: Re: Hmmm... Which PERL Book Is Best Suited For This???
Message-Id: <l0yx6.1568$EX1.851119@news2.cableinet.net>
This is a multi-part message in MIME format.
------=_NextPart_000_007B_01C0BA6B.6AF9D9C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
The camel book (Larry Wall's Programming Perl, O'Reilly & Associates) =
is a must-have. It's got the indexing you want (the best indexing I've =
seen, IMHO) plus it's written by Larry Himself. It's an absolute =
necessity for anybody who has ever thought about potentially maybe =
sometime possibly viewing/editing/creating perl code. I open my copy =
every day, usually several times a day, and I already know perl quite =
well.=20
I beg to differ, the Camel book stinks as do most O'Reilly books -- =
they are only any good if you have some expertise already. For newbies, =
I wholeheartedly recommend "Perl, the Complete Reference" from Osborne. =
Much more enlightening.
------=_NextPart_000_007B_01C0BA6B.6AF9D9C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3018.900" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV> </DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
<P>The camel book (Larry Wall's <U>Programming Perl</U>, O'Reilly =
&=20
Associates) is a must-have. It's got the indexing you want (the best =
indexing=20
I've seen, IMHO) plus it's written by Larry Himself. It's an absolute=20
necessity for anybody who has ever thought about potentially maybe =
sometime=20
possibly viewing/editing/creating perl code. I open my copy every day, =
usually=20
several times a day, and I already know perl quite well.=20
<P>
<P>I beg to differ, the Camel book stinks as do most O'Reilly books -- =
they=20
are only any good if you have some expertise already. For newbies, I=20
wholeheartedly recommend "Perl, the Complete Reference" from Osborne. =
Much=20
more enlightening.</P></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_007B_01C0BA6B.6AF9D9C0--
------------------------------
Date: Sun, 01 Apr 2001 06:16:49 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Hmmm... Which PERL Book Is Best Suited For This???
Message-Id: <x71yrdw3e6.fsf@home.sysarch.com>
>>>>> "J" == Jacko <jacko_england@hotmail.com> writes:
J> I beg to differ, the Camel book stinks as do most O'Reilly books
J> -- = they are only any good if you have some expertise already. For
J> newbies, = I wholeheartedly recommend "Perl, the Complete
J> Reference" from Osborne. = Much more enlightening.
J> ------=_NextPart_000_007B_01C0BA6B.6AF9D9C0
J> Content-Type: text/html;
someone who posts in mime and html loses points on any book rating. now
o'reilly has good and bad books but claiming they all stink also loses
you points. and any perl book that calls itself the complete reference
is already lying in the title. only the online perl docs (over 1100
pages) are the complete reference.
so your opinion is already doewngraded three times. now let someone who
is not a newbie review that book and see how many mistakes and bad code
it has. there are over 100 perl books out there and maybe 10-20 are
considered decent or better by the perl community. wonder what the odds
of that one making the cut?
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 1 Apr 2001 05:01:30 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Hmmm... Which PERL Book Is Best Suited For This???
Message-Id: <9a6cna$rjs$0@216.155.32.172>
In article <3AC5262B.28741C7F@ntlworld.com>,
"wayne.keenan" <wayne.keenan@ntlworld.com> wrote:
| there are 7 books u NEED, 1 & 2 on the list is Programming Perl and the 2nd
| is Object Orientated Perl by Damien Conway,
| without out them, life is a cheese ball.
pshew.
OO Perl I just received for my Birthday (asked mom. heh. she thought I
was sorta nuts but whatever :)
Let me say that as a complete newbie to OO syntax I basically skimmed
through the entire book attempting to absorb as much of the terminology
as possible albiet retaining only a smattering of the concepts within.
This book is not for the faint of heart or a perl newbie. Wait til you
get at least 9 months of hacking around in Perl under your belt and have
re-written your created scripts at least three or four times to use the
more sophisticated constructs and perl-isms that you learn in the
interim. (A CGI I just re-wrote from scratch is now MUCH more solid,
maintainable, and robust than the original version and is now one that I
can be thoroughly proud of. I'm literally ashamed to have shown earlier
versions of the code to anyone heh :)
I got curious about OO Perl, and decided to expand my head a little with
it, and I have to say it is *extremely* well-written and designed. I
wish more "learn something" books followed this 'template' of
explanation.
I'm sure that once I've managed to put a few of these concepts into
practice, it will all fall together nicely, but I am equally certain
I'll be re-reading this for quite some time attempting to grok in
fullness :)
pace yourself, before you move into this one, unless you've already
wrapped your various lobes around OO terminology, syntax, and code from
other languages. *chuckle*
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Mon, 2 Apr 2001 22:34:53 -0400
From: hue micheal <huem@MailAndNews.com>
Subject: How do I combine these
Message-Id: <3ACD2477@MailAndNews.com>
How do I combine this into one statement ?
$_ =~ s/[\t\s]+//g; # Remove spaces, tabs
$_ =~ s/#.*$//; # Remove commenst on the same line, such as this
line
Can I combine this into one grep ?
if(grep(/^[#\n]/,$_) || grep(/^[\s\t]+#/,$_) || grep(/^[\s\t]+\n/,$_))
Thanks
Huem
------------------------------------------------------------
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: Tue, 3 Apr 2001 12:29:36 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: How do I combine these
Message-Id: <iPay6.8$mp2.4393@vic.nntp.telstra.net>
"hue micheal" <huem@MailAndNews.com> wrote in message
news:3ACD2477@MailAndNews.com...
> How do I combine this into one statement ?
> $_ =~ s/[\t\s]+//g; # Remove spaces, tabs
> $_ =~ s/#.*$//; # Remove commenst on the same line, such as this
> line
>
> Can I combine this into one grep ?
Well, you can combine it into one regex if you want.
s/(#.*$)|\s+//g;
In your first, the square brackets are redundant as \t and \s ARE charcter
classes. Also \t is a subset of \s so that simplifies to \s+.
I take your second regex which replaces any # followed by all to end of line
with nothing, and or the two.
Also s/// operates on $_ by default so the bind to $_ is unnecessary.
However, this could be very inefficient, because of the multiple comparison
operations. It would probably be be more efficient to strip the comments
first, then remove spaces (because by removing the comment, you have less
spaces to remove).
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
$d='$_$a$s$b$w';$e='$_$a$s$b';sub d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
sub
e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e);
$c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";
------------------------------
Date: 2 Apr 2001 19:15:34 -0800
From: dowe@krikkit.localdomain (Dowe Keller)
Subject: Re: how do you pass 2 hash to a sub
Message-Id: <3ac94056@news.sierratel.com>
Pass a couple references instead.
--
dowe@sierratel.com http://www.sierratel.com/dowe
WARNING - the content of this message may be erroneous, misspelled and
perhaps even flammable. It also contains small parts that could cause
asphyxiation. NOT RECOMMENDED FOR CHILDREN UNDER 3 YEARS OF AGE
------------------------------
Date: Sun, 01 Apr 2001 03:25:03 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How to post to a newsgroup from a script?
Message-Id: <3AC6A058.7F89899E@earthlink.net>
Chris Thompson wrote:
>
[snip]
>
> Eric, thanks for your help, nice to know I'm not barking up completely
> the wrong tree!
>
> The error message I am receiving is as follows:
>
> Software error:
> Can't call method "group" on an undefined value at
> host/w/a/v/p/o/r/waverley.portland.co.uk/cgi-bin/
> post_to_newsgroups.cgi line 68.
>
> My own (novice's) interpretation of this is that somehow the $nntp
> variable isn't getting initialised properly in the "my $nntp = new
> Net::NNTP('news.demon.co.uk');" line of the script, though I am not
> sure how to get this working. The news server specified is not the one
> where the script is hosted, does this matter? I've included the
> relevant parts of the script below, if this is any help.
It might. Some news servers do not accept posts from outside their own
domains, or may require authentification with username and password.
> Any advice greatly appreciated.
>
> Chris
>
> #!/usr/local/bin/perl -w
>
> use CGI;
> use CGI::Carp qw{fatalsToBrowser};
> use strict;
> use Net::NNTP;
>
> my $co = new CGI;
> my $nntp = new Net::NNTP('news.demon.co.uk');
>
It would be a good idea to test that $nntp is not null, and if so, die
with a message saying so. After that, test if $nntp->postok() is true,
and die otherwise.
> print $co->header;
This isn't really the best place for it, move it down to when you
actually start printing html.
> my @newsgroups_to_send_to = split(" ", $co->param('newsgroups'));
> # gets the newsgroups to send to
>
> # construct content of posting
> my @posting = qq`
> Position: Web Developer
> Web developer required to join prestigious Internet consultancy.
> ----------
> `;
Just a suggestion, use a here document. Also posting needs to contain
all of the proper information for a posting, including headers, and
should be a scalar, not an array.
E.g.:
my $body = <<MSGBODY;
Position: Web Developer
Web developer required to join prestigious Internet consultancy.
----------
MSGBODY
my $posting = <<POSTING;
From: $author
Subject: $subject
Newsgroups: $newsgroups
$body
POSTING
$newsgroups should be a single scalar, containing a comma seperated list
of all thr groups you want to post to. If you post the same thing to
more than one group, you should ALWAYS send it as one single message,
with a list of things in the newsgroups field, and NOT EVER as one
posting to each group.
> # loop through all of the newsgroups to send to and send details to
> # each one using the net::nntp module
> my $newsgroup_to_send_to;
> foreach $newsgroup_to_send_to (@newsgroups_to_send_to) {
Well, it's not majorly important, but if you were looping through things
like this, you would usually want to combine the two lines into one:
foreach my $newsgroup_to_send_to (@newsgroups_to_send_to) {
> # select newsgroup
> $nntp->group($newsgroup_to_send_to);
This selects the newsgroup to read from. It has no effect on what group
you are sending to.
>
> # post message
> $nntp->post(@posting);
Sadly, @posting does not contain a properly formatted nntp message.
It is missing the from, subject and newsgroups headers.
> };
>
> # display success message
> print qq`
> <HTML>
> <HEAD>
> <TITLE>Post Vacancy Details to Newsgroups</TITLE>
> </HEAD>
> <BODY>
>
> <H1>Post Vacancy Details to Newsgroups</H1>
>
> The vacancy has been succesfully posted to the selected newsgroups.<P>
>
> </BODY>
> </HTML>
> `;
This would be better as a here document. Replace it with:
print $co->header;
print $co->start_html('Post Vacancy Details to Newsgroups');
print <<HTMLDOC, $co->end_html();
<H1>Post Vacancy Details to Newsgroups</H1>
The vacancy has been succesfully posted to the selected newsgroups.<P>
HTMLDOC
Or, considering how simple this is, with something like:
print <<HTTP_AND_HTML;
Content-type: text/plain
<HTML><HEAD>
<TITLE>Post Vacancy Details to Newsgroups</TITLE>
</HEAD><BODY>
<H1>Post Vacancy Details to Newsgroups</H1>
The vacancy has been succesfully posted to the selected newsgroups.<P>
HTTP_AND_HTML
Things to note: CGI keeps track of whether the http header has been
printed based on whether or not you've used the header() sub. So if you
print your own http header, then die()ing after this line will cause the
CGI::Carp module to print a second header (because it thinks you haven't
actually printed a header, and wants to print its own).
--
Sometimes the journey *is* its own reward--but not when you're trying to
get to the bathroom in time.
------------------------------
Date: Tue, 03 Apr 2001 01:31:10 GMT
From: Scott <admin@gatordev.net>
Subject: Re: How to split or sub on multiple spaces
Message-Id: <3AC8D194.44906A0B@gatordev.net>
Logan Shaw wrote:
> You can make the whole thing (including the loop) into a one-liner:
>
> %alittlestuff = map((split)[0,2], <>);
>
> Perl is specially optimized to make awk-like things easy, and this is a
> very awk-like task.
>
> - Logan
> --
> whose? my your his her our their _its_
> who's? I'm you're he's she's we're they're _it's_
wow, I'll try this. Not being really familiar with sed and awk, this one line of
code opens up a new world. I have to learn some of this sort of stuff, I'm sure
I can optimize a lot my code. I can read through lines with a single line of
code. Thanks.
Scott
------------------------------
Date: Mon, 2 Apr 2001 15:34:59 -0400
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: How to use Net::SMTP through a firewall (proxy)?
Message-Id: <tchl2ptcj9r264@corp.supernews.com>
Hi
I am trying to send mail via Net::SMTP.
The attempt fails because it cannot open the server. The server parameter is
correct.
I am fairly certain it is due to the firewall (I've had to use a proxy
setting for LWP-based scripts).
My questions:
- How can I send mail through a firewall?
- Is there a general config parameter somewhere that I could use to
centrally set the proxy server info? (I am hoping that a common setting
could affect SMTP, LWP and other networking apps)
My config: Windows 2000 pro w/SP1.
-TIA
David
------------------------------
Date: 31 Mar 2001 18:09:02 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Image Reloading Problem
Message-Id: <986061884.6996@itz.pp.sci.fi>
In article <3AC52EAC.D31A98ED@sequenom.com>, Bryan Coon wrote:
>Does anyone know a trick to make sure an image reloads fresh everytime
>from netscape? I am generating dynamic images, and it is a problem that
>if the file has the same name, netscape checks its cache first before
>loading the image. Even if you specify check against document every
>time in preferences.
Are you sending the images straight to the browser from a CGI script?
If so, sending an Expires header with a time in the past should tell the
browser that the image is volatile, and should be reloaded every time.
For a more detailed explanation, read the HTTP 1.1 spec.
[Followups set to comp.infosystems.www.authoring.cgi.]
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.
------------------------------
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 608
**************************************