[29749] in Perl-Users-Digest
Perl-Users Digest, Issue: 993 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 31 14:09:44 2007
Date: Wed, 31 Oct 2007 11:09:05 -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 Wed, 31 Oct 2007 Volume: 11 Number: 993
Today's topics:
!Help: can't get into perl -MCPAN -e shell <mmccaws@comcast.net>
Re: configurable variables in own file? <tzz@lifelogs.com>
Re: cpan module install woes - UTF-8 problem? <ben@morrow.me.uk>
Re: cpan module install woes - UTF-8 problem? <usenet-0710@piggo.com>
Re: cpan module install woes - UTF-8 problem? <usenet-0710@piggo.com>
Re: cpan module install woes - UTF-8 problem? <spamtrap@dot-app.org>
Re: cpan module install woes - UTF-8 problem? <spamtrap@dot-app.org>
Re: gotta throw what I have aT the rim <tzz@lifelogs.com>
Re: PID of exec hendedav@gmail.com
Re: PID of exec xhoster@gmail.com
Printing to a Windows printer. <LWATCDR@gmail.com>
Re: Printing to a Windows printer. <1usa@llenroc.ude.invalid>
Re: Printing to a Windows printer. w.c.humann@arcor.de
Re: Spreadsheet::Parse & Write Excel <justin.0711@purestblue.com>
WHY are args for sprintf in scalar context? w.c.humann@arcor.de
Re: WHY are args for sprintf in scalar context? <wahab-mail@gmx.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 31 Oct 2007 08:47:55 -0700
From: mmccaws2 <mmccaws@comcast.net>
Subject: !Help: can't get into perl -MCPAN -e shell
Message-Id: <1193845675.525407.222330@q3g2000prf.googlegroups.com>
I try to login in at command line. It gives me the output below. It
then kicks me out of the perl shell. What do I need to do to be able
to use it?
Mike
Here is the error message:
Can't load '/opt/perl/lib/5.8.3/IA64.ARCHREV_0-thread-multi/auto/IO/
IO.so' for module IO: Exec format error at /opt/perl/lib/5.8.3/
IA64.ARCHREV_0-thread-multi/XSLoader.pm line 68.
at /opt/perl/lib/5.8.3/IA64.ARCHREV_0-thread-multi/IO.pm line 11
Compilation failed in require at /opt/perl/lib/5.8.3/IA64.ARCHREV_0-
thread-multi/IO/Handle.pm line 260.
BEGIN failed--compilation aborted at /opt/perl/lib/5.8.3/
IA64.ARCHREV_0-thread-multi/IO/Handle.pm line 260.
Compilation failed in require at /opt/perl/lib/5.8.3/IA64.ARCHREV_0-
thread-multi/IO/Seekable.pm line 101.
BEGIN failed--compilation aborted at /opt/perl/lib/5.8.3/
IA64.ARCHREV_0-thread-multi/IO/Seekable.pm line 101.
Compilation failed in require at /opt/perl/lib/5.8.3/IA64.ARCHREV_0-
thread-multi/IO/File.pm line 117.
BEGIN failed--compilation aborted at /opt/perl/lib/5.8.3/
IA64.ARCHREV_0-thread-multi/IO/File.pm line 117.
Compilation failed in require at /opt/perl/lib/5.8.3/FileHandle.pm
line 9.
Compilation failed in require at /opt/perl/lib/5.8.3/CPAN.pm line 26.
BEGIN failed--compilation aborted at /opt/perl/lib/5.8.3/CPAN.pm line
26.
Compilation failed in require.
BEGIN failed--compilation aborted.
------------------------------
Date: Wed, 31 Oct 2007 08:44:47 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: configurable variables in own file?
Message-Id: <m2zlxzl7ow.fsf@lifelogs.com>
On Wed, 31 Oct 2007 01:32:57 -0000 ivowel@gmail.com wrote:
i> As to CPAN, I just don't want to worry about users ending up having
i> to do deep installs with many dependencies. They may also not have
i> root access. My view may be wrong. Maybe I should just go this
i> route.
I really doubt you'll find disagreement on this one thing: use CPAN as
much as possible. It makes everyone's life easier: you, your users, and
ours.
i> sub http2file {
i> my $httpname= $_[0]; # the http://www.domain.com/file.html
i> (defined($httpname)) or htmldie("You cannot call http2file without
i> an http name.\n");
i> ($httpname =~ /^http:\/\//) or htmldie("You cannot call http2file
i> with '$httpname'.\n");
i> $httpname=~ s/^http:\/\///; # eliminate the http
i> $httpname =~ /([^\/]+)\/(.*)/; # separate the domain name
i> and the filename
i> my $hostname= $1;
i> my $fname= $2 || "index.html"; # default; could be made
i> smarter
i> my $filename = "/var/www/$hostname/htdocs/$fname"; # rewrite the
i> filename
i> $filename=~ s/\?.*//; # kill everything after the
i> '?'
i> return $filename;
i> }
i> For standard cases, this should work fine. (Probably some bugs in the
i> code, too, but as I said, for standard cases, it should work.) It's
i> the only routine that my user needs to change---and yes, it may be
i> painful. The rest of the configuration are just variables, that I
i> could have laid out into a configuration file.
OK, so you want a mapping from a URL path to file. A simple way to do
this as a configuration setting is:
# use any format you like to set this
FILE_ROOT = /var/www/HOSTNAME/htdocs
Then the user can simply change this as needed, setting that directory.
Do you see how much simpler the above is for the users? Your http2file
function is then (untested code):
use URI;
my $url = shift @_;
my $from = URI->new($url, 'http');
my $to = $config->{FILE_ROOT};
my $path = $from->path();
if ($path eq '' || $path eq '/')
{
$path = '/index.html';
}
$file = sprintf('%s/%s', $to, $path);
# validate $file now
htmldie "$file was not readable or not a file" unless (-r $file && -f $file);
return $file;
I'd use the CPAN URI module to parse the URL and extract the path (the
only piece you need). It really makes the job easier. At least look at
the docs to see what it can do, and what the expected URL formats are.
It will catch query parameters and fragments, along with much more.
You can also add validation to make sure the host name is something
expected, but if you're aiming for simplicity the above may be the best
solution for you.
Try the code below if you're not sure about what the URI module does:
foreach my $url ('/path.html',
'http://lifelogs.com',
'http://lifelogs.com/',
'http://lifelogs.com/test.html',
'http://lifelogs.com/test.html?extraparameters=yes',
'http://lifelogs.com/test.html?extraparameters=yes#fragment')
{
my $from = URI->new($url, 'http');
my $query = $from->query() || '';
printf "[$url]:\n\thost is [%s], port is [%s], path is [%s], query is [%s]\n", $from->host(), $from->port(), $from->path(), $query;
}
Note carefully how many things it does correctly, especially the first
one, which will give you an undefined host name but a good path.
Ted
------------------------------
Date: Wed, 31 Oct 2007 07:01:33 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: cpan module install woes - UTF-8 problem?
Message-Id: <drllv4-q31.ln1@osiris.mauzo.dyndns.org>
Quoth Troy Piggins <usenet-0710@piggo.com>:
> Not sure if this is the correct group. Please let me know if there's a
> more applicable one.
>
> I'm trying to install amavisd-new, spamassassin, and clamav on my ubuntu
> 7.10 system. One of amavisd-new's prerequisites is BerkeleyDB and there's
> also an optional Mail::ClamAV that I want to install. All other modules
> installed fine.
>
> Not being that knowledgeable with perl, I usually install modules at the
> commandline by:
>
> $ sudo cpan BerkeleyDB
>
> type commands. Trouble is for those 2 modules mentioned above, and also
> some others required for spamassassin, I keep getting many errors[1].
>
> I have read that there may be some problems with perl modules if the
> environment is UTF-8.
This is not usually an issue if you are using 5.8.1 or above, and in any
case does not appear to be the problem here.
> [1] Some of the output for BDB below. I can provide full if necessary.
<snippety>
> /usr/bin/perl /usr/share/perl/5.8/ExtUtils/xsubpp -noprototypes -typemap
> /usr/share/perl/5.8/ExtUtils/typemap -typemap typemap BerkeleyDB.xs >
> BerkeleyDB.xsc && mv BerkeleyDB.xsc BerkeleyDB.c cc -c
> -I/usr/local/BerkeleyDB/include -D_REENTRANT -D_GNU_SOURCE
> -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe
> -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2
> -DVERSION=\"0.32\" -DXS_VERSION=\"0.32\" -fPIC "-I/usr/lib/perl/5.8/CORE"
> BerkeleyDB.c BerkeleyDB.xs:68:16: error: db.h: No such file or directory
Here is your problem: you don't have db.h, or, at least, not where perl
is looking for it. Have you installed the appropriate -dev db package?
Since you seem to be using Debian, it may be easier to install modules
through the package manager. This will handle external dependancies like
this for you.
Ben
------------------------------
Date: Wed, 31 Oct 2007 17:16:14 +1000
From: Troy Piggins <usenet-0710@piggo.com>
Subject: Re: cpan module install woes - UTF-8 problem?
Message-Id: <20071031171449@usenet.piggo.com>
* Sherman Pendley is quoted
* & my replies are inline below :
> Troy Piggins <usenet-0710@piggo.com> writes:
>
>> Sherman Pendley is quoted & my replies are inline below :
>>
>>> Yep. You're missing the Berkeley DB C library, and it's not as harmless
>>> as the warning would have you believe. The Perl module is just a wrapper
>>> for the C library, and without the C library it can't work.
>>
>> So..... how do we fix it :)
>
> How to install the C library & headers is dependent on your OS. I didn't get
> into that because I didn't know what OS you're using. :-)
Sorry. I think it was in my original post but we snipped it
somewhere along the way.
>> Is the missing library installed from cpan, or deb package?
>
> You need the libdb4.4-dev package.
Excellent! Thanks for that. I actually installed libdb4.6-dev
since it was the latest available. It seems to have worked.
--
Troy Piggins | http://piggo.com/~troy
RLU#415538 ,-O (o- O
O ) //\ O
`-O V_/_ OOO
------------------------------
Date: Wed, 31 Oct 2007 17:20:27 +1000
From: Troy Piggins <usenet-0710@piggo.com>
Subject: Re: cpan module install woes - UTF-8 problem?
Message-Id: <20071031171857@usenet.piggo.com>
* Ben Morrow is quoted
* & my replies are inline below :
>
> Quoth Troy Piggins <usenet-0710@piggo.com>:
>> Not sure if this is the correct group. Please let me know if there's a
>> more applicable one.
>>
>> I'm trying to install amavisd-new, spamassassin, and clamav on my ubuntu
>> 7.10 system. One of amavisd-new's prerequisites is BerkeleyDB and there's
>> also an optional Mail::ClamAV that I want to install. All other modules
>> installed fine.
>>
>> Not being that knowledgeable with perl, I usually install modules at the
>> commandline by:
>>
>> $ sudo cpan BerkeleyDB
>>
>> type commands. Trouble is for those 2 modules mentioned above, and also
>> some others required for spamassassin, I keep getting many errors[1].
>>
>> I have read that there may be some problems with perl modules if the
>> environment is UTF-8.
>
> This is not usually an issue if you are using 5.8.1 or above, and in any
> case does not appear to be the problem here.
>
>> [1] Some of the output for BDB below. I can provide full if necessary.
> <snippety>
>> /usr/bin/perl /usr/share/perl/5.8/ExtUtils/xsubpp -noprototypes -typemap
>> /usr/share/perl/5.8/ExtUtils/typemap -typemap typemap BerkeleyDB.xs >
>> BerkeleyDB.xsc && mv BerkeleyDB.xsc BerkeleyDB.c cc -c
>> -I/usr/local/BerkeleyDB/include -D_REENTRANT -D_GNU_SOURCE
>> -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe
>> -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2
>> -DVERSION=\"0.32\" -DXS_VERSION=\"0.32\" -fPIC "-I/usr/lib/perl/5.8/CORE"
>> BerkeleyDB.c BerkeleyDB.xs:68:16: error: db.h: No such file or directory
>
> Here is your problem: you don't have db.h, or, at least, not where perl
> is looking for it. Have you installed the appropriate -dev db package?
>
> Since you seem to be using Debian, it may be easier to install modules
> through the package manager. This will handle external dependancies like
> this for you.
Thanks mate. I've resolved it by installing the libdb4.6-dev
package. BerkeleyDB module installs fine now with cpan, but
still having trouble with Mail::ClamAV and some others. I'll
struggle on.
This group the appropriate place to ask these sort of q's?
--
Troy Piggins | http://piggo.com/~troy
RLU#415538 ,-O (o- O
O ) //\ O
`-O V_/_ OOO
------------------------------
Date: Wed, 31 Oct 2007 04:48:25 -0400
From: Sherman Pendley <spamtrap@dot-app.org>
Subject: Re: cpan module install woes - UTF-8 problem?
Message-Id: <m18x5jr7om.fsf@dot-app.org>
Troy Piggins <usenet-0710@piggo.com> writes:
> * Sherman Pendley is quoted
>>
>> You need the libdb4.4-dev package.
>
> Excellent! Thanks for that. I actually installed libdb4.6-dev
> since it was the latest available.
I looked in stable. If you're using unstable or testing, that probably
accounts for the different verison.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Wed, 31 Oct 2007 04:51:12 -0400
From: Sherman Pendley <spamtrap@dot-app.org>
Subject: Re: cpan module install woes - UTF-8 problem?
Message-Id: <m14pg7r7jz.fsf@dot-app.org>
Troy Piggins <usenet-0710@piggo.com> writes:
> This group the appropriate place to ask these sort of q's?
Don't worry - if you question were off-topic, you definitely would have
heard about it by now. :-)
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Wed, 31 Oct 2007 07:34:09 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: gotta throw what I have aT the rim
Message-Id: <m24pg7mpj2.fsf@lifelogs.com>
On Tue, 30 Oct 2007 21:40:15 -0600 "Wade Ward" <zaxfuuq@invalid.net> wrote:
WW> , how do I get perl.exe to be profitable if I double-click on one of these
WW> icons?
...
WW> I wrote 19 versions of this script toady and seek comment:
WW> ## contract22.pl
WW> ## binary contraction in perl
WW> ## contributors: joe smith
My comment: you should seriously re-evaluate your programming career.
Ted
------------------------------
Date: Wed, 31 Oct 2007 12:27:02 -0000
From: hendedav@gmail.com
Subject: Re: PID of exec
Message-Id: <1193833622.326291.311800@d55g2000hsg.googlegroups.com>
On Oct 29, 1:12 pm, hende...@gmail.com wrote:
> On Oct 29, 12:12 pm, xhos...@gmail.com wrote:
>
>
>
> > hende...@gmail.com wrote:
>
> > > I am testing under GNU/Linux (Debian 3.1 Sarge). And I think I have
> > > confirmed that a zombie gets created for each call to this script. I
> > > put a system command in the "if" and "elsif" sections that writes to a
> > > debug.txt file everytime one of them is accessed. I end up with 19
> > > lines in the text file and 19 zombies. While the "polling" to that
> > > script is taking place, I run ps several times and can see the zombie
> > > count growing.
>
> > I don't see how this can have anything to do with the code you showed
> > us. Maybe it is something about your web-server that is causing the
> > zombies.
>
> > > I tried adding the lines that you mentioned, but it
> > > still didn't help. I am not sure what to do at this point.
>
> > Create a do-nothing hello world script and see if that leaves zombies.
> > Break your existing code into two different scripts (one for the if block
> > one for the else block) and see what one, if any, leaves zombies.
>
> > 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.
>
> I created a test.cgi that only printed out a "hello world" string and
> I am still getting a very low number of them (1-2) occasionally (the
> client will continue to poll until a certain response is received)
> when I issue a ps command. Would there be a problem with this script
> getting called to frequently? This is obviously a much simpler script
> that the one I posted so it has time to completely finish before the
> next "poll". Any ideas?
>
> Xho I can still separate the script if you would like (if there isn't
> enough information already given).
>
> Thanks,
> Dave
Well, I still haven't figured out how to fix the zombie problem, but I
really appreciate all the help that everyone has contributed. I will
be monitoring this thread over the next couple of days, so if anyone
has any more ideas, I would like to hear them.
Thanks,
Dave
------------------------------
Date: 31 Oct 2007 15:30:16 GMT
From: xhoster@gmail.com
Subject: Re: PID of exec
Message-Id: <20071031113018.226$gv@newsreader.com>
hendedav@gmail.com wrote:
> On Oct 29, 12:12 pm, xhos...@gmail.com wrote:
> >
> > Create a do-nothing hello world script and see if that leaves zombies.
> > Break your existing code into two different scripts (one for the if
> > block one for the else block) and see what one, if any, leaves zombies.
> >
> > Xho
> >
sig snipped. Please don't quote sigs, unless you are commenting on the
sig.
>
> I created a test.cgi that only printed out a "hello world" string and
> I am still getting a very low number of them (1-2) occasionally (the
> client will continue to poll until a certain response is received)
> when I issue a ps command. Would there be a problem with this script
> getting called to frequently?
Even having 2 zombies at a time seems a little suspicious. Why isn't
the web server harvesting them expeditiously? But that is a matter
for your web-server, rather than Perl. Are you triggering the test
script at the same rate that the client is triggering the polling script?
Because while leaving 2 zombies is a bit suspicious but if they are
triggered at the same rate it doesn't explain 17 zombies over the same time
period.
> Xho I can still separate the script if you would like (if there isn't
> enough information already given).
If you are still having problems with zombies, it is the only next
step I can see doing.
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: Wed, 31 Oct 2007 15:17:25 -0000
From: David <LWATCDR@gmail.com>
Subject: Printing to a Windows printer.
Message-Id: <1193843845.422084.199920@19g2000hsx.googlegroups.com>
I am trying to improve a label printing program that I wrote in perl.
I want to use a Laser Printer instead of the current dot matrix and I
would like to include some Fonts and graphics in the output.
Portability isn't an issue right now and I really don't want to have
to install Ghostscript.
I have looked on the Activestate Website but couldn't find anything
that pointed to how to use a windows printer as anything but a char
device.
I have also gone to CPAN and found a modual that looks like it would
do EXACTLY what I would like to do.
http://search.cpan.org/~wasx/Win32-Printer-0.9.0/Printer.pm
But when I go to the home page that is supposed to have that module I
get a page of ads. It looks like it has been abandoned.
So any help would be great.
Thanks
------------------------------
Date: Wed, 31 Oct 2007 16:48:10 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Printing to a Windows printer.
Message-Id: <Xns99DA823D8630Dasu1cornelledu@127.0.0.1>
David <LWATCDR@gmail.com> wrote in news:1193843845.422084.199920@19g2000hsx.googlegroups.com:
> I am trying to improve a label printing program that I wrote in perl.
> I want to use a Laser Printer instead of the current dot matrix and I
> would like to include some Fonts and graphics in the output.
> Portability isn't an issue right now and I really don't want to have
> to install Ghostscript.
OK.
> I have also gone to CPAN and found a modual that looks like it would
> do EXACTLY what I would like to do.
> http://search.cpan.org/~wasx/Win32-Printer-0.9.0/Printer.pm
> But when I go to the home page that is supposed to have that module I
> get a page of ads. It looks like it has been abandoned.
What is your question?
I installed the module as described in
http://search.cpan.org/~wasx/Win32-Printer-0.9.0/Printer.pm#Source_installation
Then I ran the test program (after changing the paper size to LETTER)
in
http://search.cpan.org/~wasx/Win32-Printer-0.9.0/Printer.pm#SYNOPSIS
and I got a nice colorful print-out.
So, do you have a specific question?
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>
------------------------------
Date: Wed, 31 Oct 2007 10:36:10 -0700
From: w.c.humann@arcor.de
Subject: Re: Printing to a Windows printer.
Message-Id: <1193852170.907664.56450@v3g2000hsg.googlegroups.com>
On Oct 31, 5:48 pm, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
>
> So, do you have a specific question?
>
> Sinan
I agree that David has not phrased his problem too exactly, but it's
not really hard to figure out: The (dead) link he's talking about
points to a compiled ppd-package. By guiding him to the "source
installation"-section you silently assumne that everyone has VC++
installed -- which is not the case. ActiveState does not offer a
compiled package and packages compiled with gcc etc. often do not
cooperate well with ActiveState Perl.
Hint for David: go to http://cpan.uwinnipeg.ca/dist/Win32-Printer.
They list additional win32 repositories -- including one for
Win32::Printer
Wolfram
------------------------------
Date: Wed, 31 Oct 2007 09:33:30 -0000
From: Justin C <justin.0711@purestblue.com>
Subject: Re: Spreadsheet::Parse & Write Excel
Message-Id: <72c0.47284bea.12364@zem>
On 2007-10-30, Jim Gibson <jimsgibson@gmail.com> wrote:
>
> Spreadsheet::ParseExcel and Spreadsheet::WriteExcel are separate
> modules that have no relationship to each other and were written by
> different authors. In particular, they each have their own concepts of
> a "Format" object or class, and these are not shared. You cannot fetch
> the format of a cell in an existing spreadsheet and transfer it whole
> to a new spreadsheet.
That appears to be the crux of it.
> You are going to have to play around with
> extracting the various pieces of the existing cell format and transfer
> each piece to the new spreadsheet using the syntax of
> Spreadsheet::WriteExcel.
Looks like a fun time is going to be had by all then!!!
Thank you for your reply. It has helped me re-evaluate the problem.
Justin.
--
Justin C, by the sea.
------------------------------
Date: Wed, 31 Oct 2007 06:25:24 -0700
From: w.c.humann@arcor.de
Subject: WHY are args for sprintf in scalar context?
Message-Id: <1193837124.107768.267630@v3g2000hsg.googlegroups.com>
Just ran into this nasty trap:
> perl -we'@a=("%s %s\n", qw/foo bar/); printf @a'
foo bar
> perl -we'@a=("%s %s\n", qw/foo bar/); print sprintf @a'
3
And indeed, 'perldoc -f sprintf' says:
"Unlike printf, sprintf does not do what you probably mean when you
pass it an array as your first argument. The array is given scalar
context, and instead of using the 0th element of the array as the
format, Perl will use the count of elements in the array as the
format, which is almost never useful."
But *why* are args for printf in array context and for sprintf in
scalar context? Especially if it's "not what I probably mean" and
"almost never useful". It's not like Perl to make easy things
harder...
Wolfram
------------------------------
Date: Wed, 31 Oct 2007 17:11:52 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: WHY are args for sprintf in scalar context?
Message-Id: <fgab1g$nl4$1@mlucom4.urz.uni-halle.de>
w.c.humann@arcor.de wrote:
> But *why* are args for printf in array context and for sprintf in
> scalar context? Especially if it's "not what I probably mean" and
> "almost never useful". It's not like Perl to make easy things
> harder...
This seems to be old news ;-)
http://www.perl.com/pub/a/1999/11/sins.html#2
http://www.perl.com/doc/manual/html/pod/perltrap.html#Context_Traps_scalar_list_con
IIRC, this distinction (printf/sprintf) came in
after porting from Perl4 to Perl5 because printf
accepts an optional filehandle as first argument
and sprintf allows format construction by subroutine
return value there. One of Perls oddities, true.
...
@a = ("%s %s\n", qw/foo bar/);
print sprintf shift @a, @a;
...
Regards
M.
------------------------------
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 993
**************************************