[30429] in Perl-Users-Digest
Perl-Users Digest, Issue: 1672 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 25 00:09:43 2008
Date: Tue, 24 Jun 2008 21:09:07 -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 Tue, 24 Jun 2008 Volume: 11 Number: 1672
Today's topics:
Re: Auto-login to Facebook <fakemail@email.com>
Re: FAQ 5.12 How can I open a filehandle to a string? <brian.d.foy@gmail.com>
Re: FAQ 5.12 How can I open a filehandle to a string? <brian.d.foy@gmail.com>
Re: Forcing list context for C<glob> (was: Problem expa <ced@blv-sam-01.ca.boeing.com>
Re: Forcing list context for C<glob> (was: Problem expa <ben@morrow.me.uk>
Re: Forcing list context for C<glob> (was: Problem expa xhoster@gmail.com
Re: Forcing list context for C<glob> (was: Problem expa <ben@morrow.me.uk>
Re: Forcing list context for C<glob> <whynot@pozharski.name>
Re: Forcing list context for C<glob> <whynot@pozharski.name>
Re: I hate CGI.pm <cwilbur@chromatico.net>
number to word in any language (was: change a single di <tzz@lifelogs.com>
Please Vote for AMIN!! <vote4amin@gmail.com>
Re: Remove a tab with backspace? (David Combs)
run application from perl nonblocking? <nielsen.sebastian@gmail.com>
Re: run application from perl nonblocking? <ben@morrow.me.uk>
Re: The Importance of Terminology's Quality <jwkenne@attglobal.net>
Re: What is GDBM_File and Fcntl ? Please comment this p <ben@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Jun 2008 22:11:00 -0400
From: Mila <fakemail@email.com>
Subject: Re: Auto-login to Facebook
Message-Id: <s6a3641kouih45abnc9jeoil8qk5oqqe0b@4ax.com>
On Thu, 22 May 2008 08:19:03 -0700 (PDT), FeelLikeANut@gmail.com
wrote:
>Hi. I'm trying to write a script to automatically update some
>information on Facebook. For now I'm just trying to get the login part
>to work. Here's what I have:
Doesn't facebook have API? Maybe you can use it to do whatever updates
you need.
------------------------------
Date: Tue, 24 Jun 2008 11:25:15 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 5.12 How can I open a filehandle to a string?
Message-Id: <240620081125150865%brian.d.foy@gmail.com>
In article <g3r1nv$c6s$1@reader2.panix.com>, David Combs
<dkcombs@panix.com> wrote:
> The suggested examples and uses all concern writing *to* a string.
>
> How about for reading *from* a string?
Yeah, I was just thinking about that since I had added some of that
stuff to our Intermediate Perl class. Now I just have to add it to the
FAQ :)
------------------------------
Date: Tue, 24 Jun 2008 10:03:14 -0700 (PDT)
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 5.12 How can I open a filehandle to a string?
Message-Id: <b489a98f-d63b-405e-b712-408708893ef6@34g2000hsh.googlegroups.com>
On May 29, 4:57=A0pm, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> > 5.12: How can I open a filehandle to a string?
> > =A0 =A0 Since Perl 5.8.0, you can pass a reference to a scalar instead =
of the
> > =A0 =A0 filename to create a file handle which you can used to read fro=
m or
> > =A0 =A0 write to a string:
>
> Yikes! Did I really create that monster of a sentence (not to mention
> the typo)? I guess it shows that German is my native language. How about
> this?
>
> | Since Perl 5.8.0 a file handle referring to a string can be created by
> | calling open with a reference to that string instead of the filename.
> | This file handle can then be used to read from or write to the string:
I've updated the answer with your new paragraph, which now has 200% of
the
sentences of the former entry. :)
------------------------------
Date: Tue, 24 Jun 2008 12:46:02 -0700 (PDT)
From: "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Forcing list context for C<glob> (was: Problem expanding filenames in loop)
Message-Id: <01d58857-3ebd-48f9-bb07-a9efcae579e4@a9g2000prl.googlegroups.com>
On Jun 24, 9:53 am, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth xhos...@gmail.com:
>
> > Ben Morrow <b...@morrow.me.uk> wrote:
>
> > > or, if you need a 'scalar',
>
> > > print scalar( () = glob(...) );
>
> > > I have no idea where this is documented, but if you assign to the empty
> > > list in scalar context it returns a count of the items in the assigned
> > > list.
>
> > Not just an empty list.
>
> > perl -le 'print scalar(my ($x,$z) = glob q(/*));'
> > 24
>
> Huh. I had it in my head that that returned a count of the LHS, not the
> RHS. Don't know where I got that from...
>
> > > This is weird and not at all the way any other list assignment
> > > works, but surprisingly useful.
>
> ...so, in fact, exactly like every other list assignment :).
>
Even with the list, it almost looks like Perl actually creates some
temp AV just to later grab its size perhaps...?
perl -MO=Concise -le 'print scalar( ($x,$z)=(1,2,3))'
...
aassign[t1] sKS ->c
...
--
Charles DeRykus
------------------------------
Date: Tue, 24 Jun 2008 20:57:23 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Forcing list context for C<glob> (was: Problem expanding filenames in loop)
Message-Id: <3608j5-2ka2.ln1@osiris.mauzo.dyndns.org>
Quoth "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com>:
> On Jun 24, 9:53 am, Ben Morrow <b...@morrow.me.uk> wrote:
> >
> > ...so, in fact, exactly like every other list assignment :).
>
> Even with the list, it almost looks like Perl actually creates some
> temp AV just to later grab its size perhaps...?
>
> perl -MO=Concise -le 'print scalar( ($x,$z)=(1,2,3))'
> ...
> aassign[t1] sKS ->c
No. aassign is just the name of the list assignment op. There's a lot of
confusion in older bits of perl between 'array' and 'list': I guess the
two concepts weren't properly separated to start with. 'wantarray', for
instance, ought to be called 'wantlist'.
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
Heraclitus
ben@morrow.me.uk
------------------------------
Date: 24 Jun 2008 15:09:51 GMT
From: xhoster@gmail.com
Subject: Re: Forcing list context for C<glob> (was: Problem expanding filenames in loop)
Message-Id: <20080624110952.439$ed@newsreader.com>
Ben Morrow <ben@morrow.me.uk> wrote:
>
> or, if you need a 'scalar',
>
> print scalar( () = glob(...) );
>
> I have no idea where this is documented, but if you assign to the empty
> list in scalar context it returns a count of the items in the assigned
> list.
Not just an empty list.
perl -le 'print scalar(my ($x,$z) = glob q(/*));'
24
> This is weird and not at all the way any other list assignment
> works, but surprisingly useful.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Tue, 24 Jun 2008 17:53:43 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Forcing list context for C<glob> (was: Problem expanding filenames in loop)
Message-Id: <ndl7j5-5ac.ln1@osiris.mauzo.dyndns.org>
Quoth xhoster@gmail.com:
> Ben Morrow <ben@morrow.me.uk> wrote:
> >
> > or, if you need a 'scalar',
> >
> > print scalar( () = glob(...) );
> >
> > I have no idea where this is documented, but if you assign to the empty
> > list in scalar context it returns a count of the items in the assigned
> > list.
>
> Not just an empty list.
>
> perl -le 'print scalar(my ($x,$z) = glob q(/*));'
> 24
Huh. I had it in my head that that returned a count of the LHS, not the
RHS. Don't know where I got that from...
> > This is weird and not at all the way any other list assignment
> > works, but surprisingly useful.
...so, in fact, exactly like every other list assignment :).
Thanks,
Ben
--
Many users now operate their own computers day in and day out on various
applications without ever writing a program. Indeed, many of these users
cannot write new programs for their machines...
-- F.P. Brooks, 'No Silver Bullet', 1987 [ben@morrow.me.uk]
------------------------------
Date: Tue, 24 Jun 2008 13:23:56 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Forcing list context for C<glob>
Message-Id: <siu6j5xuuk.ln2@carpet.zombinet>
Eric Pozharski <whynot@pozharski.name> wrote:
*SKIP*
> 10:23:00 31 [0:0]$ perl -e 'print (glob q(/*)) > 1; print "\n"'
Oops. That must be C<print((glob q(/*)) > 1)>. Then output is empty
too.
> /bin/boot/cdrom/cdrom0/dev/etc/floppy/home/initrd.img/initrd.img.old
> /lib/lost+found/media/mnt/opt/proc/root/sbin/sys/tmp/usr/var/vmlinuz
> /vmlinuz.old
*CUT*
--
Torvalds' goal for Linux is very simple: World Domination
------------------------------
Date: Tue, 24 Jun 2008 22:42:38 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Forcing list context for C<glob>
Message-Id: <eav7j5x8am.ln2@carpet.zombinet>
Ben Morrow <ben@morrow.me.uk> wrote:
> Quoth Eric Pozharski <whynot@pozharski.name>:
*SKIP*
>> As of Perl 5.8.8 (for Debian Etch) it makes no difference:
> You're testing the wrong thing... which is not surprising, since where
> Perl keeps its implicit iterators is never very clear.
That's the second time I see you suppose some magic behind interpreter.
I like it. I suppose too.
> Scalar glob keeps its iterator *in the op*: that is, each instance of
[ I'm sorry about that thread. It was based on my sole misunderstanding
what are (differences among) lists, arrays, assignments in scalar and
list context; and incomplete process of familarizing myself with
precedence and associativity. Now I feel much beter. ]
*SKIP*
>> 10:24:07 34 [0:0]$ perl -e 'print scalar(@{[ glob q(/*) ]}) > 1; print
>> "\n"'
> This works correctly, but again is deeply ugly.
> The idiom you are looking for is
> my $x = () = glob(...);
> or, if you need a 'scalar',
> print scalar( () = glob(...) );
That's what I missed (yes, I admit missing I<-l> and B<I<-w>>). To put
it clear:
22:16:07 143 [0:0]$ perl -le '$x = (1,2,4); print $x'
4
22:16:14 144 [0:0]$ perl -le '($x) = (1,2,4); print $x'
1
22:16:18 145 [0:0]$ perl -le '$x = () = (1,2,4); print $x'
3
The 1st is a B<comma operator>, I know. The 3rd slowly moves down to
backbone where it will stay forever. What surprises me most is the 2nd.
A long time ago, when I've just started the addiction to Perl, I was
told (OK, I've read), that intentional way to do that is
C<($x, undef) = (1, 2, 3)>; either way (C<($x) = (1, 2, 3)>) will set
I<$x> to the number of items in list. It's not so. Any more?
I've just checked, replacing the list with explicit array merges 1st and
3rd cases. And has no influence on the 2nd. Obviously, I've missed
some reading. What?
> I have no idea where this is documented, but if you assign to the empty
> list in scalar context it returns a count of the items in the assigned
> list. This is weird and not at all the way any other list assignment
> works, but surprisingly useful.
L<perlop/"Assignment operators">. In the last paragraph it's mentioned;
no explicit example though.
--
Torvalds' goal for Linux is very simple: World Domination
------------------------------
Date: Tue, 24 Jun 2008 11:56:19 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: I hate CGI.pm
Message-Id: <86prq63jz0.fsf@mithril.chromatico.net>
>>>>> "BB" == Ben Bullock <benkasminbullock@gmail.com> writes:
BB> What do other people think of it? Am I a lone CGI.pm hater, or
BB> do other people use some superior system instead of CGI.pm?
I think that using a widely available module to do something that's
fiddly and prone to subtle problems is almost always the right thing to
do. Parsing CGI parameters by hand is almost always the wrong thing to
do. I find that CGI.pm has a lot of extra baggage that I don't usually
need -- largely, the convenience methods for producing HTML, which are
just as hard to get right as actual HTML and one step removed from the
problem -- but I use it in preference to handrolling code.
BB> I tried to read the documentation for Catalyst, and it makes no
BB> sense to me - it looks like you have to buy a book and spend
BB> hours and hours to understand it.
Catalyst is a web application framework; to get anywhere meaningful with
it, you have to understand how it thinks. It's also built on the
TMTOWTDI principle, and so once you start involving plugins to do
things, you start running into many more ways to solve problems and thus
you need to understand more things to be able to make an intelligent
choice.
For large web applications, it makes sense to start with a framework.
For one-script pages, it makes far less sense.
BB> Since I don't usually even write web things, I don't want to
BB> spend a lot of time studying the systems - I just want a "better
BB> CGI module". Does it exist?
What do you need the module to do? What do you find painful about
CGI.pm?
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Tue, 24 Jun 2008 14:52:19 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: number to word in any language (was: change a single digit to corresponding English word)
Message-Id: <86lk0uk3v0.fsf_-_@lifelogs.com>
On Tue, 24 Jun 2008 13:26:54 +0000 (UTC) Ben Bullock <benkasminbullock@gmail.com> wrote:
BB> On Tue, 24 Jun 2008 08:09:18 -0500, Ted Zlatanov wrote:
>> I wonder if there's a locale-sensitive way to say numbers from inside
>> Perl. It must be available (part of glibc I think), since I know `date`
>> for example can print the day correctly depending on the locale.
BB> Dates are a different issue from numbers. I'm fairly sure glibc has
BB> nothing as fancy as this. But there are some modules which deal with
BB> numbers, like Lingua::JA::Numbers
Right, thanks.
BB> Generally, converting numbers into a string of text is rather a
BB> difficult problem requiring a lot of knowledge of the language you
BB> want to write the number in. It's not something which one would expect
BB> to find in a C library.
It's not terribly hard to do in the languages I know (some are covered
by Lingua::*::Numbers). Inflecting the numbers is hard, but you can do
a perfectly passable job if you assume a "one item, two items..."
sentence structure. I'd rather have an ugly solution than none. Ugly
solutions tend to get fixed. Anyhow, I checked the /usr/lib/locale
stuff and it doesn't seem to have any of this functionality so I guess
it has to happen at the Perl level.
>> I didn't see anything in CPAN, only
>> http://search.cpan.org/~rgarcia/perl-5.10.0/ext/I18N/Langinfo/Langinfo.pm
>>
>> The CPAN *Locale* modules were not very useful for this task.
>>
>> Lingua::Any::Numbers doesn't sniff out the locale automatically, and
>> doesn't seem to use the glibc facilities (if such exist).
BB> Lingua::Any::Numbers seems to be nothing but a wrapper for various
BB> other Perl modules, like the above-mentioned Lingua::JA::Numbers.
I understand, but my point was that it doesn't figure out what you want
based on the locale. For example:
% LANG=bg_BG.utf8 date
вт юни 24 14:41:09 CDT 2008
% LANG=C date
Tue Jun 24 14:41:12 CDT 2008
I don't know how to map any locale to any language in the
Lingua::*::Numbers hierarchy. In addition, the .utf8* specifier is a
problem (see 'sr_YU.utf8@cyrillic' for example). The Lingua::*::Numbers
modules are not setting the output encoding; it seems like that's up to
the application. So Lingua::Any::Numbers should have wrappers to
accomodate encodings and auto-detect locale. If anyone knows more on
this topic please let me know, before I go writing patches. I cc-ed
Burak, the Lingua::Any::Numbers maintainer on this and will report back
if he e-mails me.
Ted
------------------------------
Date: Tue, 24 Jun 2008 18:48:55 -0700 (PDT)
From: vote4amin <vote4amin@gmail.com>
Subject: Please Vote for AMIN!!
Message-Id: <3caa9bdd-5002-4341-8b51-78d89683d5a1@w1g2000prd.googlegroups.com>
Dear frens,
Need your help to spend a minute of your time to vote for my little
boy in Cutefam 2008 contest. Please click --->>>
http://www.thelilcaliph.com/CuteFam2008/voteWithCodes.html to vote.
The rule is only one vote per ip per day. So, you can only vote once
a
day until 28th June. Appreciate if you can forward this link to your
frens and family. Thanks a lot in advanced for your help.
------------------------------
Date: Wed, 25 Jun 2008 02:39:20 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Remove a tab with backspace?
Message-Id: <g3sb4o$iul$1@reader2.panix.com>
In article <483EE304.5090808@gmx.de>, Achim Peters <achimpeters@gmx.de> wrote:
>RedGrittyBrick schrieb:
...
...
>
>> Apparently Windows and Unix/Linux
>> differ in their handling of this slightly.
>
>The difference is visible already under Unix alone.
>
>$ perl -e 'print "12\b\n"'
>12
>$ perl -e 'print "12\b"'
>1$
>
Finally I notice that in this thread one print terminates in a newline,
while the other doesn't.
Independently of the platform, why the different effect,
in that with the newline, we see the 2, but not without
the newline?
Perhaps some weird interaction with a buffer getting flushed or not?
Or what?
David
>$ uname -a
>AIX lpar1 3 5 00C533BE4C00 powerpc unknown AIX
>
>$ perl -version
>
>This is perl, v5.8.2 built for aix-thread-multi
>(with 2 registered patches, see perl -V for more detail)
>
>Bye
> Achim
------------------------------
Date: Tue, 24 Jun 2008 12:35:35 -0700 (PDT)
From: sebastian nielsen <nielsen.sebastian@gmail.com>
Subject: run application from perl nonblocking?
Message-Id: <02e8f23f-2fb0-4926-bea6-fdca18a183f6@e53g2000hsa.googlegroups.com>
I want to run a command from a perl script in nonblocking mode.
So lets say we have this routine:
sub EndOfBody {
($self, $mailid) = @_;
close(MAILFILE);
#Here I want to run: "C:/parser.exe $mailid"
return(250 , "Mail has been delivered!");
}
At the comment, I want to run the command
C:/parser.exe $mailid
and then instant after launching the command, continue with returning
250 "Mail has been delivered!" while parser.exe is running. (and the
parser.exe should continue running even when the script with the
EndOfBody subroutine has exited)
Since when receiving mails with large attachment, I need to be able to
parse the mail in the background and extract all attachments to a
separate folder, without causing the client to the SMTP server to
timeout.
parser.exe may return something, but it isnt anything useful, so its
no need to take care of the return value from parser.exe
------------------------------
Date: Tue, 24 Jun 2008 21:01:13 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: run application from perl nonblocking?
Message-Id: <9d08j5-2ka2.ln1@osiris.mauzo.dyndns.org>
Quoth sebastian nielsen <nielsen.sebastian@gmail.com>:
> I want to run a command from a perl script in nonblocking mode.
> So lets say we have this routine:
>
> sub EndOfBody {
> ($self, $mailid) = @_;
> close(MAILFILE);
> #Here I want to run: "C:/parser.exe $mailid"
perldoc -q background
Ben
--
The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching.
Assyrian stone tablet, c.2800 BC ben@morrow.me.uk
------------------------------
Date: Tue, 24 Jun 2008 18:42:15 -0400
From: John W Kennedy <jwkenne@attglobal.net>
Subject: Re: The Importance of Terminology's Quality
Message-Id: <48617847$0$5021$607ed4bc@cv.net>
David Combs wrote:
> passing
> *unnamed* functions as args (could Algol 60 also do something like that,
> via something it maybe termed a "thunk")
No, the "thunks" were necessary at the machine-language level to
/implement/ ALGOL 60, but they could not be expressed /in/ ALGOL.
--
John W. Kennedy
"The first effect of not believing in God is to believe in anything...."
-- Emile Cammaerts, "The Laughing Prophet"
------------------------------
Date: Tue, 24 Jun 2008 16:10:15 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: What is GDBM_File and Fcntl ? Please comment this piece of code
Message-Id: <nbf7j5-8a5.ln1@osiris.mauzo.dyndns.org>
Quoth RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>:
>
> You can read about them by opening a command prompt and typing#
> perldoc Fcntl
> perldoc GDBM_File
Except that those (particular) docs are *entirely useless* unless you
already know what the modules in question do. GDBM_File is
particularly bad: it doesn't even specify the arguments to 'tie' (and
I think the OP's original code was wrong, though maybe in a way that
happened to work).
Ben
--
We do not stop playing because we grow old;
we grow old because we stop playing.
ben@morrow.me.uk
------------------------------
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 V11 Issue 1672
***************************************