[25035] in Perl-Users-Digest
Perl-Users Digest, Issue: 7285 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 22 03:12:01 2004
Date: Fri, 22 Oct 2004 00:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 22 Oct 2004 Volume: 10 Number: 7285
Today's topics:
ping net pop3 <nospam@nospam.com>
Re: ping net pop3 <usa1@llenroc.ude.invalid>
Re: ping net pop3 <nospam@nospam.com>
Re: ping net pop3 <spamtrap@dot-app.org>
Re: ping net pop3 <1usa@llenroc.ude.invalid>
Re: ping net pop3 <nospam@nospam.com>
Re: ping net pop3 <nospam@nospam.com>
Re: printing to web browser <nospam@nospam.com>
Re: printing to web browser <jgibson@mail.arc.nasa.gov>
Re: printing to web browser <nospam@nospam.com>
Re: printing to web browser <sbryce@scottbryce.com>
Re: printing to web browser <noreply@gunnar.cc>
Re: printing to web browser <tintin@invalid.invalid>
Re: printing to web browser <autismuk@autismuk.freeserve.co.uk>
Re: regex to clean path <parv_@yahooWhereElse.com>
Re: regex to clean path <parv_@yahooWhereElse.com>
Re: regex to clean path <parv_@yahooWhereElse.com>
Re: regex to clean path <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 21 Oct 2004 22:22:26 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: ping net pop3
Message-Id: <1098411758.429196@nntp.acecape.com>
from net::pop3
ping ( USER )
Returns a list of two elements
so if i do
$tot_list = $pop->ping($user);
how do i read $tot_list elements?
preceding with a % prints me out the address of tot_list (am guessing)
$tot_list[0] gives me internal error 500
am new to perll, as you can tell
------------------------------
Date: 22 Oct 2004 04:22:54 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: ping net pop3
Message-Id: <cla1uu$g2c$1@news01.cit.cornell.edu>
In article <1098411758.429196@nntp.acecape.com>,
daniel kaplan <nospam@nospam.com> wrote:
> from net::pop3
>
> ping ( USER )
> Returns a list of two elements
>
> so if i do
>
> $tot_list = $pop->ping($user);
>
> how do i read $tot_list elements?
Did you have a Perl question?
Read
perldoc Net::POP3
for information on how to use the module and the POP3 specification to
understand how POP3 works.
> preceding with a % prints me out the address of tot_list (am guessing)
You can't just make stuff up and expect it to do something useful. You
need to spend time and energy to understand how protocols work and then
write real code that others can help you with based on that
understanding.
> $tot_list[0] gives me internal error 500
You should focus on writing scripts that work from the command line
before venturing into the CGI world.
perldoc -q 500
> am new to perll, as you can tell
Then it is time for you to get a good book (see http://learn.perl.org/)
and peruse the documentation already available to you. In addition to
the command line program perldoc, ActivePerl comes with documentation in
HTML format. You can find a link to that documentation in the Windows
start menu.
Last but not least, please go ahead and read the posting guidelines
for this group and the Perl FAQ list before posting again.
Sinan.
------------------------------
Date: Fri, 22 Oct 2004 00:36:25 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: ping net pop3
Message-Id: <1098419796.185265@nntp.acecape.com>
well forgive me, i thought asking a "how to read from a list variable" was a
PERL question
isn't it?
i was just mentioning the module i was using
------------------------------
Date: Fri, 22 Oct 2004 00:59:19 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: ping net pop3
Message-Id: <R8SdnfltDIc6DuXcRVn-jQ@adelphia.com>
daniel kaplan wrote:
> from net::pop3
>
> ping ( USER )
> Returns a list of two elements
>
> so if i do
>
> $tot_list = $pop->ping($user);
The ping() method returns a *list*, not a single scalar. You have to
either assign it to a pair of scalars:
my ($foo, $bar) = $pop->ping($user);
Or, assign it to an array:
my @tot_list = $pop->ping($user);
> $tot_list[0]
That's the correct syntax for accessing the first element in @tot_list.
The problem is, you didn't have an array @tot_list - you had a scalar
$tot_list.
> gives me internal error 500
No, the *web server* gives you a "500 Server Error". Check the web
server log for the Perl error, or 'use CGI::Carp qw(fatalsToBrowser);'
to have it sent to your browser rather than logged.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 22 Oct 2004 05:15:01 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: ping net pop3
Message-Id: <Xns958ACB849AB3asu1cornelledu@132.236.56.8>
"daniel kaplan" <nospam@nospam.com> wrote in
news:1098419796.185265@nntp.acecape.com:
> well forgive me,
You need to quote what you are responding to ... Otherwise it looks like
you are talking to yourself.
> i thought asking a "how to read from a list variable"
> was a PERL question
First, you have been told several times so far that the name of the
language is Perl, not PERL.
Second, here is the question you asked:
> "daniel kaplan" <nospam@nospam.com> wrote in
> news:1098411758.429196@nntp.acecape.com:
>
>> from net::pop3
>>
>> ping ( USER )
>> Returns a list of two elements
>>
>>
>> so if i do
>>
>> $tot_list = $pop->ping($user);
>>
>>
>> how do i read $tot_list elements?
I made a guess based on context. It was a guess because your writing was
not clear. I guessed wrong because I am not a mind reader.
You have just assigned the first element of the returned list to
$tot_list (that is a misleading variable name because, according to the
Net::POP3 docs, the first element of the list is the number of _new_
messages) and discarded the second element of the list. Why did you do
that?
my ($new, $total) = $pop->ping($user);
or
my @v = $pop->ping($user);
or
my $t = [ $pop->ping($user) ];
I do not know what is appropriate to your situation.
Now, please go ahead and
1) Get a book: http://learn.perl.org/
2) Read the posting guidelines
3) Read the Perl FAQ list
before you post again.
--
A. Sinan Unur
1usa@llenroc.ude.invalid
(remove '.invalid' and reverse each component for email address)
------------------------------
Date: Fri, 22 Oct 2004 01:14:58 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: ping net pop3
Message-Id: <1098422109.851172@nntp.acecape.com>
many thanks!
as i said in another post...am an old time C programmer....my brain is so
wired for THAT language, learning the new one is just...tiring!
------------------------------
Date: Fri, 22 Oct 2004 01:39:24 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: ping net pop3
Message-Id: <1098423575.840122@nntp.acecape.com>
A. Sinan Unur,
honestly, you must be one of the rudest people i have ever encountered on a
newsgroup. maybe the times have changed and all that, but whenever i looked
for question i could answer (C related, obviosuly not Perl)....i would just
answer the question to just help someone out. that's it. i didn't care if
it was a homework cheater, or a guy on deadline at 2am, who's brain was just
in some stuck mode. in fact, i've never met a programmer who didn't ask
questions that were stupid (to everyone else), but we help each other out,
without judging. and for the record, i would be willing to say, that you've
had to ask questions in your moments where everyone else went, "is he
kidding?"
as i said in one of my posts, am an old time C programmer, and just old.
brain is so wired to C, that i practicly have to write down what datatype in
Perl is equal to C. cause am just that way. and of course i have books,
just sometimes you, for whatever reason, get stuck.
sorry to make this so public, but really, if you think i am just asking
stupid questions, or am not worth the time, then please, just don't bother
with my posts...
------------------------------
Date: Thu, 21 Oct 2004 18:19:38 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: printing to web browser
Message-Id: <1098397186.321958@nntp.acecape.com>
> print "Content-type: text/plain\n\n";
you mean start my $out with the above?
------------------------------
Date: Thu, 21 Oct 2004 15:24:05 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: printing to web browser
Message-Id: <211020041524059555%jgibson@mail.arc.nasa.gov>
In article <1098395030.248283@nntp.acecape.com>, daniel kaplan
<nospam@nospam.com> wrote:
> still new to PERL, anyway write now i do all OUTPUTTING to the web browser
> with:
Experienced Perl programmers don't use all CAPS.
>
> print $q->header();
> print $out;
>
> but what i would really likee to do is print everything out in TEXT only
> format...for debuggin purposes....
>
> is there a way to do this, so the browser does NOT print using HTML
> formating, and just prints everything in plain text?
Print stuff between <pre> and </pre> tags. You can also use the
$q->pre() function of CGI, which, since it is not documented in perldoc
CGI, is probably an auto-generated tag function.
------------------------------
Date: Thu, 21 Oct 2004 19:09:01 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: printing to web browser
Message-Id: <1098400150.171490@nntp.acecape.com>
see am using Net::Pop3 to read emails...and i have to disect the text, so
need to see it all to make the program...and when i print it out in the
browser, the HTML kicks in, and i don't see all the "actual text"
please help
------------------------------
Date: Thu, 21 Oct 2004 17:55:07 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: printing to web browser
Message-Id: <10ngj2pifpnb2ab@corp.supernews.com>
daniel kaplan wrote:
> see am using Net::Pop3 to read emails...and i have to disect the text, so
> need to see it all to make the program...and when i print it out in the
> browser, the HTML kicks in, and i don't see all the "actual text"
Then send the output to a file as well as the browser. Or use
View|Source to see what the browser is getting.
------------------------------
Date: Fri, 22 Oct 2004 02:53:56 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: printing to web browser
Message-Id: <2tr42qF21bmt1U1@uni-berlin.de>
daniel kaplan wrote:
>> print "Content-type: text/plain\n\n";
>
> you mean start my $out with the above?
I mean that you can replace
print $q->header();
with that.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 22 Oct 2004 19:00:38 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: printing to web browser
Message-Id: <2trlu1F23iurjU1@uni-berlin.de>
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2tr42qF21bmt1U1@uni-berlin.de...
> daniel kaplan wrote:
>>> print "Content-type: text/plain\n\n";
>>
>> you mean start my $out with the above?
>
> I mean that you can replace
>
> print $q->header();
>
> with that.
Seeing as he's using the CGI module, he might as well use:
print $q->header('text/plain');
------------------------------
Date: Fri, 22 Oct 2004 07:12:10 +0100
From: Paul Robson <autismuk@autismuk.freeserve.co.uk>
Subject: Re: printing to web browser
Message-Id: <pan.2004.10.22.06.12.10.338668@autismuk.freeserve.co.uk>
On Thu, 21 Oct 2004 15:24:05 -0700, Jim Gibson wrote:
> In article <1098395030.248283@nntp.acecape.com>, daniel kaplan
> <nospam@nospam.com> wrote:
>
>> still new to PERL, anyway write now i do all OUTPUTTING to the web browser
>> with:
>
> Experienced Perl programmers don't use all CAPS.
Does <stdin> work then ?
------------------------------
Date: Thu, 21 Oct 2004 23:08:10 -0500
From: parv <parv_@yahooWhereElse.com>
Subject: Re: regex to clean path
Message-Id: <slrncnh222.e4.parv_@localhost.holy.cow>
in message <m37jpjkf6c.fsf@linux.local>,
wrote Uri Guttman ...
>>>>>> "p" == parv <parv_@yahooWhereElse.com> writes:
>
> >> the overall impression is that you have the tendency to abuse
> >> printf() and referencing-dereferencing
>
> p> I do not agree about printf() at all, but do agree in some limited
> p> ways about references.
>
> printf is so rarely needed in perl. you can usually use
> interpolation, sprintf, or formats ... i would prefer sprintf as
> then you can easily control where the output goes rather than
> always going to a single handle. think about the cases where you
> want output to be returned instead of printed, or sent to two
> places like stdout and a log, etc.
Agree w/ you on use of s?printf() functions. I use sprintf() where
i need a formatted string which is not to be printed immediately as
you have listed. I personally found formats to be quite cumbersome
to work with.
Inside the print(), i want to keep the quoted text to minimum; i use
it to to print list of variables which does not involving any kind
of formatting or print just quoted text.
- parv
--
As nice it is to receive personal mail, too much sweetness causes
tooth decay. Unless you have burning desire to contact me, do not do
away w/ WhereElse in the address for private communication.
------------------------------
Date: Fri, 22 Oct 2004 00:12:41 -0500
From: parv <parv_@yahooWhereElse.com>
Subject: Re: regex to clean path
Message-Id: <slrncnh5r1.e4.parv_@localhost.holy.cow>
in message <snbgn0hm6goa7b21184e0eshq2p5l6frle@4ax.com>,
wrote Michele Dondi ...
> On Mon, 18 Oct 2004 16:45:22 -0500, parv <parv_@yahooWhereElse.com>
> wrote:
...
>> # Make path string from given list of array references or
>> # strings
> ^^^^^^^^^^^^^^^^
> Why, if they're all coming from @ARGV by means of split()ting?
Well, @ARGV is just one source of paths *in OP's case* & in the
program posted.
>> my %uniq;
>> { my $i = 0;
>> map $uniq{$_} = !exists $uniq{$_} ? $i++ : $uniq{$_}
>> , @{ split_path( [ @paths ]) };
>> }
>
> All I can say is that it is a reasonably working but definitely
> clumsy workaround for not having chosen the "correct" algorithm in
> the first place. Again, give a peek into Tad's post (and possibly
> mine, and possibly the faq!)
Above algorithm is similar to the faq entry[0] that you refer to;
this one uses map() instead of grep().
Care to explain how above algorithm is not "correct"? Clumsy, i
agree (in comparison to [0]).
[0] It seems to be the example b in answer to question "How can I
remove duplicate elements from a list or array?" in perlfaq4.
Somebody tell me this: Is there a guarantee that grep() will always
give the filtered output in the order in which input was received?
>> sub delimit_path
>> { my ($paths) = @_;
>> return \join ':' , @{$paths};
>> }
>
> Why?!?
To delimit the path list w/ the possibility of alternate delimiter.
(What is with "?!?" anyway? Expression of high annoyance?)
>> delete $hash->{$_} unless -d $_ || -x $_;
>
> This will keep non-readable directories as well as executable
> files. You want
>
> delete $hash->{$_} unless -d $_ && -x $_;
Right you are.
> instead. But then C<$_> is not necessary and can be omitted
Thanks for the reminder about '_'; i can't remember it when it needs
to be remembered.
And, thanks, generally, for your comments.
- parv
--
As nice it is to receive personal mail, too much sweetness causes
tooth decay. Unless you have burning desire to contact me, do not do
away w/ WhereElse in the address for private communication.
------------------------------
Date: Fri, 22 Oct 2004 00:19:52 -0500
From: parv <parv_@yahooWhereElse.com>
Subject: Re: regex to clean path
Message-Id: <slrncnh68g.15m.parv_@localhost.holy.cow>
in message <slrncnh222.e4.parv_@localhost.holy.cow>,
wrote parv ...
> in message <m37jpjkf6c.fsf@linux.local>,
> wrote Uri Guttman ...
>
>>>>>>> "p" == parv <parv_@yahooWhereElse.com> writes:
>>
>> >> the overall impression is that you have the tendency to abuse
>> >> printf() and referencing-dereferencing
>>
>> p> I do not agree about printf() at all, but do agree in some limited
>> p> ways about references.
>>
>> printf is so rarely needed in perl. you can usually use
>> interpolation, sprintf, or formats
> Agree w/ you on use of s?printf() functions
...
> Inside the print(), i want to keep the quoted text to minimum
Forgot to add that using printf() allows to list all the variables
in one place, instead of being interspersed w/ print()[0], thus
variables are much easily locatable & changeable.
[0] Does not apply if the string is already contained in single
variable as Uri G had ponited out earlier in his reply.
- parv
--
As nice it is to receive personal mail, too much sweetness causes
tooth decay. Unless you have burning desire to contact me, do not do
away w/ WhereElse in the address for private communication.
------------------------------
Date: Fri, 22 Oct 2004 08:59:46 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: regex to clean path
Message-Id: <0hbhn05lh52gktj6nl03p8tq8035ovth98@4ax.com>
I was forgetting...
On Mon, 18 Oct 2004 16:45:22 -0500, parv <parv_@yahooWhereElse.com>
wrote:
> map $uniq{$_} = undef , @{ split_path( [@paths] ) };
> keep_usable(\%uniq);
It is *reasonably* recommended not to use map() for its side effects
in void context. See e.g. 'perldoc perlstyle'.
$uniq{$_} = undef for @{ split_path( [@paths] ) };
would have been just the same and inutitively more clear. Also, take
into account the possibility of a slice:
@uniq{ @{ split_path( [@paths] ) } } = ();
of course this would have been more clear had you avoided all those
references:
@uniq{ split_path @paths } = ();
> map $uniq{$_} = !exists $uniq{$_} ? $i++ : $uniq{$_}
> , @{ split_path( [ @paths ]) };
> }
> keep_usable(\%uniq);
It is recommended not to use map() for its side effects in void
context! (Repetita iuvant)
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7285
***************************************