[23581] in Perl-Users-Digest
Perl-Users Digest, Issue: 5788 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 12 18:05:46 2003
Date: Wed, 12 Nov 2003 15:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 12 Nov 2003 Volume: 10 Number: 5788
Today's topics:
Re: "tree" view of directory (Tad McClellan)
Re: "tree" view of directory <krahnj@acm.org>
Re: "tree" view of directory <tore@aursand.no>
ANNOUNCE: Socket::MsgHdr 0.01 (Michael Pomraning)
ANNOUNCE: POSIX::RT::Semaphore 0.01 (Michael Pomraning)
Re: Bit counting benchmarks Was: count of 1s in a binar (Anno Siegel)
Re: Bit counting benchmarks Was: count of 1s in a binar <shuffman@ichips.intel.com>
Re: count of 1s in a binary number (Sara)
Re: count of 1s in a binary number <nospam-abuse@ilyaz.org>
Re: Creating and submitting POST form in Perl (J.P.)
Re: Creating and submitting POST form in Perl (J.P.)
Re: Creating and submitting POST form in Perl <usenet@morrow.me.uk>
Re: Creating and submitting POST form in Perl <flavell@ph.gla.ac.uk>
Re: Creating and submitting POST form in Perl (Tad McClellan)
Re: Fastest Perl Interpreter <tassilo.parseval@rwth-aachen.de>
Re: how to erase \r or \015 in win32? (David Efflandt)
Re: how to erase \r or \015 in win32? <flavell@ph.gla.ac.uk>
Re: my command (sorry newbe question) <lynchcy@eircom.net>
Re: my command (sorry newbe question) <usenet@morrow.me.uk>
Re: my command (sorry newbe question) <syscjm@gwu.edu>
Re: Net::SMTP on Windows 2000. I'm stuck! (Jonathan2s6)
Problem with IO::Socket::INET and pop (Joe)
REQUEST_URI unavailable <nospam@goawayspam.com>
servers (Jonathan2s6)
Shorthand for($scalar) loops and resetting pos($scalar) <clint@0lsen.net>
Re: Very newbie Q anout $,@ and % (Tad McClellan)
Re: Why Camel is Better than Perldoc <REMOVEsdnCAPS@comcast.net>
Re: Why Camel is Better than Perldoc <REMOVEsdnCAPS@comcast.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 12 Nov 2003 13:20:32 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: "tree" view of directory
Message-Id: <slrnbr5200.jgl.tadmc@magna.augustmail.com>
Jeff Thies <nospam@nospam.net> wrote:
> I'd like to have a tree like listing of a directories contents and it's
> subdirectories.
I snatched this one when I saw Tushar Samant post it here years ago:
find . -print | sed -e 's,[^/]*/\([^/]*\)$,`--\1,' -e 's,[^/]*/,| ,g'
> I'd like to do that with the modules from the standard perl
> distribution.
Oh.
Never mind. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 12 Nov 2003 20:10:35 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: "tree" view of directory
Message-Id: <3FB293B5.1E0F631E@acm.org>
Tad McClellan wrote:
>
> Jeff Thies <nospam@nospam.net> wrote:
>
> > I'd like to have a tree like listing of a directories contents and it's
> > subdirectories.
>
> I snatched this one when I saw Tushar Samant post it here years ago:
>
> find . -print | sed -e 's,[^/]*/\([^/]*\)$,`--\1,' -e 's,[^/]*/,| ,g'
>
> > I'd like to do that with the modules from the standard perl
> > distribution.
>
> Oh.
>
> Never mind. :-)
s/find/find2perl/; s/sed/s2p/;
:-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 12 Nov 2003 21:51:20 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: "tree" view of directory
Message-Id: <pan.2003.11.12.19.31.03.714849@aursand.no>
On Wed, 12 Nov 2003 16:26:02 +0000, Jeff Thies wrote:
> I'd like to have a tree like listing of a directories contents and it's
> subdirectories. I'd like to do that with the modules from the standard
> perl distribution.
> [...]
You could at least use File::Find (which comes with Perl) to do the job of
creating a list of the files/directories. File::Find is a mature module,
and thus it is safe to use - also across platforms.
I don't have a solution at hand for your problem, but I figure you have to
create a list of what you want;
use File::Find;
my @files = ();
find( \&wanted, '/' );
sub wanted {
# Do something with the file/directory, if necessary
push( @files, $File::Find::name );
}
...and then print the contents of @files. You know the 'level' of each
file/directory by finding out how many directory names there are in each
element of @files.
There even might be a File::Tree (or something) on CPAN which you could
look into.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Wed, 12 Nov 2003 16:48:59 GMT
From: mjp@pilcrow.madison.wi.us (Michael Pomraning)
Subject: ANNOUNCE: Socket::MsgHdr 0.01
Message-Id: <Ho9DvE.1yLu@zorch.sf-bay.org>
Available on CPAN, the Socket::MsgHdr modules provides advanced socket
messaging -- sendmsg(2), recvmsg(2) and ancillary data manipulation.
This module tries to make the interface familiar but palatable:
- sendmsg/recvmsg are plain functions or IO::Socket methods
- msghdr structures become Socket::MsgHdr objects
- cmsghdr un/packing and alignment are handled by an object method
What good is this? sendmsg and recvmsg have all the capabilities of
send/sendto and recv/recvfrom, plus ancillary data access. Depending
on the particulars of your system, ancillary data allows:
- Passing filehandles between unrelated processes
(a la I_SENDFD under streams)
- IPv6 IP option manipulation
- Enhanced SOCK_RAW, SOCK_DGRAM information
- Querying socket peer credentials
(a la getpeereuid())
- ... even more
------------------------------
Date: Wed, 12 Nov 2003 18:12:38 GMT
From: mjp@pilcrow.madison.wi.us (Michael Pomraning)
Subject: ANNOUNCE: POSIX::RT::Semaphore 0.01
Message-Id: <Ho9Dx8.KIx@zorch.sf-bay.org>
POSIX::RT::Semaphore is a Perl interface to POSIX.1b (Realtime)
semaphores, at least as supported by your system. ;-)
RT semaphores are objects implemented in XS, bringing the capabilities
of your system's semaphore.h up to Perl. Care has been taken to
ensure smoothness under a perl-5.8.x 'threads' environment.
RT sems offer a good selection of semaphore features: nonblocking and
time-limited behavior, named and unnamed variants, "blocked" count,
interprocess and intraprocess (threaded) synchronization.
Since RT sem implementations vary from library to library, the author
welcomes build/test/bug reports.
------------------------------
Date: 12 Nov 2003 21:13:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Bit counting benchmarks Was: count of 1s in a binary number
Message-Id: <bou7qb$mek$1@mamenchi.zrz.TU-Berlin.DE>
Sam Huffman <shuffman@ichips.intel.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
>
> > Okay, here are the promised benchmarks.
> >
> > Rate direct decrement ilya table
> > direct 18877/s -- -50% -65% -77%
> > decrement 37451/s 98% -- -30% -54%
> > ilya 53439/s 183% 43% -- -34%
> > table 80850/s 328% 116% 51% --
>
> An unrolled version of ilya is even better. I found this c code snippet
> somewhere (long since forgotten the source), and have used it extensively;
> converted to perl:
>
> sub unrolled
> {
> my $n = shift;
>
> $n = ($n & 0x55555555) + (($n & 0xaaaaaaaa) >> 1);
> $n = ($n & 0x33333333) + (($n & 0xcccccccc) >> 2);
> $n = ($n & 0x0f0f0f0f) + (($n & 0xf0f0f0f0) >> 4);
> $n = ($n & 0x00ff00ff) + (($n & 0xff00ff00) >> 8);
> $n = ($n & 0x0000ffff) + (($n & 0xffff0000) >> 16);
>
> $n;
> }
>
> On my machine, with 5.8.0, this beats the table by 16%:
24% on mine:
Rate direct decrement ilya table unrolled
direct 18836/s -- -49% -65% -76% -81%
decrement 37216/s 98% -- -30% -53% -62%
ilya 53235/s 183% 43% -- -33% -46%
table 78938/s 319% 112% 48% -- -19%
unrolled 97699/s 419% 163% 84% 24% --
I am pleased to see the clever algorithm beat the brute force approach
of lookup. And it's indeed a log( w) algorithm, where w is the word
size, unlike all others which are linear in w.
Speed is bought by portability here -- the fast algorithm needs maintenance
for a switch of word size (not only the unrolled one), while the others
work for any word size.
Anno
PS: If you're tired of answering this, just ignore me, but... any relation?
------------------------------
Date: 12 Nov 2003 13:41:31 -0800
From: Sam Huffman <shuffman@ichips.intel.com>
Subject: Re: Bit counting benchmarks Was: count of 1s in a binary number
Message-Id: <po83ccttgc4.fsf@pdxlx1644.pdx.intel.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> Sam Huffman <shuffman@ichips.intel.com> wrote in comp.lang.perl.misc:
> >
>
> PS: If you're tired of answering this, just ignore me, but... any relation?
No :)
Sam
------------------------------
Date: 12 Nov 2003 13:28:47 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: count of 1s in a binary number
Message-Id: <776e0325.0311121328.146c2315@posting.google.com>
Fred <fJogham@yahoo.com> wrote in message news:<3FAB3BBC.5060902@yahoo.com>...
> if there is not a function that takes a scalar or array and count a
> given charcter. I am trying to come up with a code
>
>
> my $bit1 = 011001010;
> my @bit2 = qw /01 00 11 01 00/;
> print size ($bit1) "\n";
> print size (@bit2) "\n";
>
> I need a function which works on both data types
>
> sub size {
> my $tmp = shift;
> my $i = 0;
> foreach my $j ( @tmp ) {
> if ( $j == 1 ) { $i++ };
> }
> return $i;
> }
>
> thanks
Hmm I'm not entirely sure I understand your program requirements, but
here is a little trial. The sub "ones" returns the number of 1's in
either a binary scalar, or an array of binary scalars. And as I like
all of my subs(), no LOOPS :)
#!/usr/bin/perl -wd
$_ = '101010111010101';
my @b = qw(01 10 11 01 01 00);
my $r = ones($_);
print "scalar: $r\n";;
$r = ones(\@b);
print "array: $r\n";;
exit 0;
sub ones
{local $_ = $_[0];
$_ = join '', @$_ if ref $_;
s/(.)/$1+/g;
s/\+$//;
return eval;
}
[tux@tux ~]$ ./ones.pl
Loading DB routines from perl5db.pl version 1.19
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(./ones.pl:3): $_ = '101010111010101';
DB<1> c
scalar: 9
array: 6
Debugged program terminated. Use q to quit or R to restart,
-Gx
------------------------------
Date: Wed, 12 Nov 2003 21:34:26 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: count of 1s in a binary number
Message-Id: <bou912$18o8$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de>], who wrote in article <botdgl$6eg$1@mamenchi.zrz.TU-Berlin.DE>:
> > sub count_bits ($) {
> > my $x = shift;
> > my $shift = 1;
> > for my $mask (0x55555555, 0x33333333, 0x0f0f0f0f, 0x00ff00ff, 0x0000ffff) {
> > $x = ($x & $mask) + (($x >> $shift) & $mask);
> > $shift *= 2;
> > }
> > $x;
> > }
> Yikes, what's that? Wait... it's considering $x as a series of $shift-bit
> ($shift = 1, 2, 4,..) numbers and makes room for overflow using the mask
> and doing every addition in two steps.
Thanks for wording it out. *This* way it is much clearer that when
the loop is unrolled, one can speed up it circa other 20%: the
overflow may happen only when $shift is 1, 2, 8. So one needs masking
on these steps only: some bits of the ($shift-bits) numbers would be
"dirty", so one needs 1 extra masking at the end.
> I hadn't seen this before, thanks for bringing it up.
I think I discussed it on one of Perl lists circa mid-90s. [Of
course, even then it was possible to find prior art; today, with
google, you get many hits on these numbers...]
Hope this helps,
Ilya
------------------------------
Date: 12 Nov 2003 13:21:01 -0800
From: john.p.zurilgen@saic.com (J.P.)
Subject: Re: Creating and submitting POST form in Perl
Message-Id: <9d142b04.0311121321.4b12519f@posting.google.com>
Mr. McClellan,
Maybe you should attempt to be a bit less high and mighty...and
actually help eliminate problems rather than adding to them.
As I said, I scoured the area (TO INCLUDE my hard drive)...and I have
NOT found an answer yet. Although I can do the auto-submission, I
still haven't created the request. I don't want to display a
page...just create a request with all my info and POST it forward.
I think that the Perl world could use a lot fewer "self-righteous"
people...and a few more truly helpful individuals.
Just remember: when you were born, you didn't know Perl. Other
newbies are trying to get to where you are at, skill-wise. Why don't
you help repay what others before you helped you to become.
Flame on!
J.P.
tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbr32j8.f91.tadmc@magna.augustmail.com>...
> J.P. <john.p.zurilgen@saic.com> wrote:
>
> > To anyone who might be able to help here,
>
>
> Here is some help:
>
> Check the Perl FAQ *before* posting to the Perl newsgroup.
>
>
> > I've been seeking a way to create a POST form in Perl and handling the
> > auto-submission. But, how can I do this?
>
>
> perldoc -q form
>
> How do I automate an HTML form submission?
>
>
> > I've
> > been going in circles now for 3 days, trying to scour the web and
> > books for answers.
>
>
> You will be disappointed to discover that the answer was already
> on your very own hard disk then...
>
>
> > Thank you VERY much in advance for any help!
>
>
> Follow netiquette and prosper.
>
> Ignore netiquette and waste 3 days plus the time of thousands of
> other people around the world.
------------------------------
Date: 12 Nov 2003 13:24:43 -0800
From: john.p.zurilgen@saic.com (J.P.)
Subject: Re: Creating and submitting POST form in Perl
Message-Id: <9d142b04.0311121324.1e17907@posting.google.com>
Thanks for the heads-up! I appreciate the point in the right
direction...
I must say...if people aren't allowed to ask questions on these
newsgroups, then what are they for? :)
Sincerely thank you, Mr. Gleixner!
J.P.
"J. Gleixner" <glex_nospam@qwest.invalid> wrote in message news:<2kbsb.231$Rn.36147@news.uswest.net>...
> J.P. wrote:
>
>
> > I've been seeking a way to create a POST form in Perl and handling the
> > auto-submission. But, how can I do this? I don't need to display my
> > form that Perl will create....I just need to create the request and
> > fire it off.
>
> LWP will help you out.
>
> perldoc lwpcook
------------------------------
Date: Wed, 12 Nov 2003 22:11:31 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Creating and submitting POST form in Perl
Message-Id: <boub6j$7sq$1@wisteria.csv.warwick.ac.uk>
john.p.zurilgen@saic.com (J.P.) wrote:
> Mr. McClellan,
>
> Maybe you should attempt to be a bit less high and mighty...and
> actually help eliminate problems rather than adding to them.
>
> As I said, I scoured the area (TO INCLUDE my hard drive)...and I have
> NOT found an answer yet. Although I can do the auto-submission, I
> still haven't created the request. I don't want to display a
> page...just create a request with all my info and POST it forward.
>
> I think that the Perl world could use a lot fewer "self-righteous"
> people...and a few more truly helpful individuals.
>
> Just remember: when you were born, you didn't know Perl. Other
> newbies are trying to get to where you are at, skill-wise. Why don't
> you help repay what others before you helped you to become.
>
> Flame on!
I think you will find that Tad gave you the answer you wanted.
I think you would also find, if you were to hang around here for a
little while, that he nearly always gives extremely helpful advice to
all and sundry.
If you are not a little more careful, this will soon cease to include
you.
*PLONK*
Ben
--
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
ben@morrow.me.uk <=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=> (Kate Rusby)
------------------------------
Date: Wed, 12 Nov 2003 22:31:44 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Creating and submitting POST form in Perl
Message-Id: <Pine.LNX.4.53.0311122229450.6274@ppepc56.ph.gla.ac.uk>
On Wed, 12 Nov 2003, J.P. deposited TOFU onto the eternal scroll:
> Mr. McClellan,
This here's a public forum. Tad has an email address for personal
matters. But he sure doesn't deserve the treatment he's getting from
you.
> Maybe you should attempt to be a bit less high and mighty...and
> actually help eliminate problems rather than adding to them.
*plonk*
------------------------------
Date: Wed, 12 Nov 2003 16:55:43 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Creating and submitting POST form in Perl
Message-Id: <slrnbr5ejf.jl6.tadmc@magna.augustmail.com>
J.P. <john.p.zurilgen@saic.com> wrote:
> Thanks for the heads-up!
That is the same heads-up that I gave you.
> Sincerely thank you, Mr. Gleixner!
But I got a somewhat different response...
> "J. Gleixner" <glex_nospam@qwest.invalid> wrote in message news:<2kbsb.231$Rn.36147@news.uswest.net>...
>> LWP will help you out.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Nov 2003 21:03:02 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Fastest Perl Interpreter
Message-Id: <bou766$aer$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Ben Morrow:
> Darin McBride <dmcbride@naboo.to.org.no.spam.for.me> wrote:
>> Michael J. Astrauskas wrote:
>> > Darin McBride wrote:
>> >> For example, Intel promises a percentage-boost simply by compiling with
>> >> their Proton or Electron compilers over using MSVC or gcc on the same
>> >> platform. If you compile perl 5.8.1 with the Electron compiler on
>> >> Linux/ia32, you'll probably be doing alright for your system.
>> >
>> > I'm definitely going to keep this in mind. Thank you.
>>
>> Just note that these compilers cost $$$, whereas MSVC only costs $, and
>> gcc, of course, has no cost. ;->
>
> Is there significant advantage to using Intel's free icc over gcc?
It's said to give faster binaries than gcc. I, however, was not able to
confirm this when comparing its result with a gcc > v3. But then again,
I don't have an Intel processor.
One thing however could be significant. Intel's icc enforces stricter
programming habits. My experience with gcc is that it makes you lax and
you could end up with code that wont compile on some legacy compilers
without some modifications. Particularly, it doesn't have all those gcc
extensions that can be quite a spoiler when you intend to be portable.
So it's become a habit of me to also test my stuff with the icc. It's a
good indication as to whether it will work with some of the stricter
compilers (like that of SUN or Microsoft).
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Wed, 12 Nov 2003 20:14:38 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: how to erase \r or \015 in win32?
Message-Id: <slrnbr555e.8v9.efflandt@typhoon.xnet.com>
On Wed, 12 Nov 2003 10:11:00 +0800, news.hinet.net <luke@program.com.tw> wrote:
> i want to erase ^M in then end of lines.
> but i can do this in win32.
>
> $_=~s/\r//g; #but \r still exist
>
> $e=\x0D;
> $_=~s/$e//g; #have the same result
The last would fail because \x0D is a bareword and not a subroutine, so $e
probably has no value (should be quoted "\x0D").
If you only strip carriage returns and then handle or save it as text, the
remaining linefeed may automatically be converted back to carriage return,
linefeed pair. You may have to handle it in binmode to avoid that (or
remove them in an OS that does not use carriage returns for newlines).
In Windows "\n" eq "\015\012"
In Unix "\n" eq "\012"
In Mac "\n" eq "\015" (not sure about OSX)
--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Wed, 12 Nov 2003 22:48:12 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: how to erase \r or \015 in win32?
Message-Id: <Pine.LNX.4.53.0311122234160.6274@ppepc56.ph.gla.ac.uk>
On Wed, 12 Nov 2003, David Efflandt wrote:
> If you only strip carriage returns and then handle or save it as text, the
> remaining linefeed may automatically be converted back to carriage return,
> linefeed pair.
If I may say so, that's a bit of a muddled presentation. There
shouldn't be any "may" about it: the behaviour in each situation is
clearly defined - one just has to know what it is.
I'd definitely recommend that the O.P read perldoc perlport with some
care, to get a fuller picture.
The issues are:
- which platform are we talking about?
- are we dealing with platform-native data, or could it be
platform-foreign?
- are we handling it in text mode or in binary mode?
(this last point gets more complex when we also have encoding
layers involved...)
If you're handling platform-native text data, and handling it in
text mode, then inside of your Perl program the newlines will be
"\n" (the associated \r being stripped off on input, and added on
output).
> You may have to handle it in binmode to avoid that (or
> remove them in an OS that does not use carriage returns for newlines).
>
> In Windows "\n" eq "\015\012"
See above! In text mode I/O, "\n" is "\012" internally.
> In Unix "\n" eq "\012"
Not if you're reading DOS-format data!
In fact the situation _could_ be just the opposite of what you said:
if the platform is Windows/DOS and you're working in text mode, then
with DOS-format data, the \015 will be removed on input; but if the
platform is Unix and the data is in DOS format, then on Unix you'll
get \015\012 _even_ when reading in text mode.
> In Mac "\n" eq "\015"
OK. (...and then there's EBCDIC-based platforms ;-)
all the best
------------------------------
Date: Wed, 12 Nov 2003 22:00:58 -0000
From: "Chris Lynch" <lynchcy@eircom.net>
Subject: Re: my command (sorry newbe question)
Message-Id: <z4ysb.180$nm6.428@news.indigo.ie>
You don't always need the "my" when you declare a variable. However it can
be a good idea if your script calls another script or module in case there
might be another variable with the same name.
"Torch" <rvw_torch@hotmail.com> wrote in message
news:d774347.0311110326.22e9d628@posting.google.com...
> I just started a little perl programming. I noticed a lot of "my"
> commands before declaring a variable. I was under the impression that
> the "my" command was only used to declare a variable locally (like for
> instance in a subroutine). I noticed from a code I got that in some
> cases "my" was used and in other cases not. Can somebody help me with
> understanding when to use "my" and when not to use "my"
------------------------------
Date: Wed, 12 Nov 2003 22:21:58 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: my command (sorry newbe question)
Message-Id: <boubq6$7sq$2@wisteria.csv.warwick.ac.uk>
[please don't top-post]
"Chris Lynch" <lynchcy@eircom.net> wrote:
> "Torch" <rvw_torch@hotmail.com> wrote in message
> news:d774347.0311110326.22e9d628@posting.google.com...
> > I just started a little perl programming. I noticed a lot of "my"
> > commands before declaring a variable. I was under the impression that
> > the "my" command was only used to declare a variable locally (like for
> > instance in a subroutine). I noticed from a code I got that in some
> > cases "my" was used and in other cases not. Can somebody help me with
> > understanding when to use "my" and when not to use "my"
>
> You don't always need the "my" when you declare a variable. However it can
> be a good idea if your script calls another script or module in case there
> might be another variable with the same name.
You do if you 'use strict', with the exception of the variables listed
in perlvar, and package variables which you declare with 'our'.
You ought to be using strict unless you know a good reason not to.
Ben
--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
ben@morrow.me.uk |----------------+---------------| The Levellers, 'Believers'
------------------------------
Date: Wed, 12 Nov 2003 17:59:56 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: my command (sorry newbe question)
Message-Id: <3FB2BB6C.2060702@gwu.edu>
Chris Lynch wrote:
> You don't always need the "my" when you declare a variable.
If you program with strict (and you should *always* program with
strict), then you will need *something*--my, our, global, whatever...
It should by "my" unless there's a reason for it to be something
else.
> However it can
> be a good idea if your script calls another script or module in case there
> might be another variable with the same name.
Making your variables local when possible is always a good idea.
Chris Mattern
------------------------------
Date: 12 Nov 2003 22:09:08 GMT
From: jonathan2s6@aol.com (Jonathan2s6)
Subject: Re: Net::SMTP on Windows 2000. I'm stuck!
Message-Id: <20031112170908.12252.00000093@mb-m25.aol.com>
Get your Server or Homepage now
Choose which one you prefer.
Redhat, Debian, FreeBSD, Mandrake, Windows, SUSE
http://www.comserver.net
------------------------------
Date: 12 Nov 2003 14:57:19 -0800
From: unixverse@yahoo.com (Joe)
Subject: Problem with IO::Socket::INET and pop
Message-Id: <fcc97b00.0311121457.1b29b336@posting.google.com>
Hello -
I wrote some Perl for a Web based e-mail client. The code worked fine
for quite a while until recently when I get my error message show up
all the time.
Here is a snipped of the code:
# Connect to the POP server using port 110
$SocketHandle = IO::Socket::INET->new (Proto=>"tcp",
PeerAddr=>$ServerName, PeerPort=>$Port);
if (!$SocketHandle)
{
# Customized Error Function
Error("cannot connect to port <B>$Port</B> on <B>$ServerName</B>",
"Back");
exit(0);
}
The web hosting company keeps telling me that they didn't change
anything and that they can connect fine via telnet ServerName 110.
Was this code correct to begin with? Maybe I used some functionality
that has been deprecated since? Is there a way to better debug and
find out why !$SocketHandle is returned?
Thanks,
Joe
------------------------------
Date: Wed, 12 Nov 2003 15:08:15 -0600
From: "Kubaton Lover" <nospam@goawayspam.com>
Subject: REQUEST_URI unavailable
Message-Id: <vr58a1fqahum64@corp.supernews.com>
Could someone tell me when the REQUEST_URI variable is availabe to Perl
scripts running on the web server? I have a Perl script that relies on that
variable and for reasons unknown to me, some users' browsers are not sending
that value. I have checked and they are using the same browser that I'm
using (IE6.0.28).
------------------------------
Date: 12 Nov 2003 22:10:37 GMT
From: jonathan2s6@aol.com (Jonathan2s6)
Subject: servers
Message-Id: <20031112171037.12252.00000094@mb-m25.aol.com>
Get your dedicated Server or Homepage now
Choose which one you prefer.
Redhat, Debian, FreeBSD, Mandrake, Windows, SUSE
http://www.comserver.net
------------------------------
Date: Wed, 12 Nov 2003 23:00:09 GMT
From: Clint Olsen <clint@0lsen.net>
Subject: Shorthand for($scalar) loops and resetting pos($scalar)
Message-Id: <slrnbr5erp.vd4.clint@poly.0lsen.net>
Hi:
I'm currently using 5.8.1, and I'm writing a lexer which operates on a
scalar that has the contents of the entire file. I'm using the usual
suspects (/gc and \G) in all of my patterns to remember where I was.
However, I've noticed a technique in Parse::Yapp which does the following:
LOOP: for ($scalar) {
/whitespace/ and next LOOP;
/pattern/ and this;
/patern1/ and that;
}
What exactly is the for() loop doing that's different than $_ = $scalar?
The documentation is pretty scant on this subject - conditions under which
pos() will be reset. Generally a for loop consists of an initialization, a
test, and an optional chunk to do at the end of the code BLOCK.
Thanks,
-Clint
------------------------------
Date: Wed, 12 Nov 2003 13:23:37 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Very newbie Q anout $,@ and %
Message-Id: <slrnbr525p.jgl.tadmc@magna.augustmail.com>
Jürgen Exner <jurgenex@hotmail.com> wrote:
> Torch wrote:
>> I know that
>> $ is used to declare variables
> To be more precise: scalar variable
>
>> @ is used to declare arrays
> To be more precise: array variable
>
>> % is used to declare ???????
> Hash variables.
>
> Actually, those characters don't declare variables but they indicate the
> type of a variable, in a declarations as well as in any application of the
> variable. They are an integral part of the variable name itself.
And the technical term for those characters is "sigil".
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 12 Nov 2003 15:58:03 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Why Camel is Better than Perldoc
Message-Id: <Xns9431ACB891AC9sdn.comcast@216.196.97.136>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
genericax@hotmail.com (Sara) wrote in
news:776e0325.0311111107.3b46dc8d@posting.google.com:
> grrrrr....
>
> tuxy> perldoc regex
> No documentation found for "regex".
> tuxy> perldoc perlreg
> No documentation found for "perlreg".
> tuxy> perldoc perldoc regular
> No documentation found for "regular".
> brksun10-feot> perldoc expression
> No documentation found for "expression".
> .
> .
> .
>
> ...pull out trusty Camel, find regex switch in 3 seconds..
>
> I mean c'mon guys nothing for "regex", the virtual epicentre of Perl?
I completely agree. perldoc needs an index. Badly.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP7KtEmPeouIeTNHoEQIYlQCgxmt4UdClfO9ee6aOnGx2T7zBzYcAoL1J
i8HRYrwxPP8r0woBTACrSuBC
=BTsx
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 12 Nov 2003 16:03:57 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Why Camel is Better than Perldoc
Message-Id: <Xns9431ADB8F466Csdn.comcast@216.196.97.136>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
merlyn@stonehenge.com (Randal L. Schwartz) wrote in
news:af8fb956bfd8a05ae40949e64a6a4522@news.teranews.com:
> When in doubt, "perldoc perl" gives a TOC of the rest of the pages,
> which includes:
>
> Tutorials
> perlreftut Perl references short introduction
> ...
> Reference Manual
> ...
> perlre Perl regular expressions, the rest of
> the story perlreref Perl regular expressions
> quick reference
>
Tables of contents are useful things indeed. But so are indexes.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP7KudGPeouIeTNHoEQJrTwCgjHHkAmyObnAlOBORUTjwuALtHs8An3v5
91ENBLRaNlB7h5yfXvHPBO21
=oSHt
-----END PGP SIGNATURE-----
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5788
***************************************