[29372] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 616 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 3 21:10:27 2007

Date: Tue, 3 Jul 2007 18:09:09 -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, 3 Jul 2007     Volume: 11 Number: 616

Today's topics:
    Re: Asynchronous forking(?) processes on Windows <ced@blv-sam-01.ca.boeing.com>
    Re: dollar sign literals <jurgenex@hotmail.com>
    Re: dollar sign literals <dummy@example.com>
    Re: dollar sign literals <bik.mido@tiscalinet.it>
    Re: improvement suggestion for File::Find: pre-parsed e <tzz@lifelogs.com>
    Re: improvement suggestion for File::Find: pre-parsed e <tzz@lifelogs.com>
        IO::Socket::Multicast in limbo? <rgbingham@gmail.com>
    Re: Portable general timestamp format, not 2038-limited <cbfalconer@yahoo.com>
    Re: Portable general timestamp format, not 2038-limited <rvtol+news@isolution.nl>
    Re: Reading time from an excel sheet. <ddunham@redwood.taos.com>
        Removing system files <kaldrenon@gmail.com>
        small mistake: http://perl.plover.com/FAQs/Namespaces.h <szrRE@szromanMO.comVE>
    Re: small mistake: http://perl.plover.com/FAQs/Namespac <bik.mido@tiscalinet.it>
    Re: small mistake: http://perl.plover.com/FAQs/Namespac <szrRE@szromanMO.comVE>
    Re: The Modernization of Emacs: terminology buffer and  <puonegf+hfrarg@tznvy.pbz>
    Re: unlurking <bik.mido@tiscalinet.it>
    Re: unlurking <invalid@invalid.nyet>
    Re: unlurking <tadmc@seesig.invalid>
    Re: using wildcards with -e <tadmc@seesig.invalid>
    Re: using wildcards with -e <savagebeaste@yahoo.com>
    Re: using wildcards with -e <tadmc@seesig.invalid>
    Re: using wildcards with -e <savagebeaste@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 03 Jul 2007 14:11:52 -0700
From:  "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Asynchronous forking(?) processes on Windows
Message-Id: <1183497112.927677.215430@x35g2000prf.googlegroups.com>

On Jul 2, 11:01 am, Tim <tbra...@perforce.com> wrote:
> > > for( $ichild = $nchildren; $ichild > 0; $ichild-- )
> > > {
> > >         pipe RFH, WFH;
>
> > >         if( $pid =fork) {
> > >             print "Forked pid $pid.\n";
> > >             open $rfhs{ $pid }, "<&RFH";
>
> > I think it would be better just to use lexicals, then use a simple
> > assignment rather than a dup.
>
> ...
> The foreach statement did indeed fix my problem.

A possible bit of clarification may help:

The 'wait' is blocking which means the
subsequent 'read' wasn't reached because
the child was stalled until the parent's
read drained the pipe. Xho's solution
reverses the call order of wait and read
so the deadlock was eliminated even if
there was more than a buffer's worth of
write's.

(There's an asynchronous wait available
with POSIX and WNOHANG on Unix. Don't
know if works on Win32 but I suspect not. )


--
Charles DeRykus



------------------------------

Date: Tue, 03 Jul 2007 20:46:26 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: dollar sign literals
Message-Id: <CAyii.16271$MR5.2258@trndny02>

Jason Williams wrote:
> Hi all, somewhat new to perl and unix scripting, here.
[...]
>  perl -pi -e "s/(.*)dc0003\.maintain\.partitions(.*dev.*)/
> \1$calling_program_dev\2/g" $FILE
>
> Only this does not work, because perl wants to replace the
> $calling_program_dev with a ksh variable.

Actually no. Perl doesn't know and doesn't care about ksh variables. It is 
the ksh shell that does this expansion, the $calling_programm_dev never 
reaches the perl interpreter.

So you will need to check the documentation of ksh how to prevent expansion 
of variables in ksh.

As far as Perl is concerned the
    s/(.*)dc0003\.maintain\.partitions(.*dev.*)/\1$calling_program_dev\2/g
is Perl code, so perl will evaluate it and expand any _Perl_ variable it 
will find, too.
So you want a literal dollar sign, then you need to ensure, that perl will 
see a \$calling_program_dev.

jue 




------------------------------

Date: Tue, 03 Jul 2007 21:26:08 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: dollar sign literals
Message-Id: <Q9zii.25978$xk5.6993@edtnps82>

Jason Williams wrote:
> Hi all, somewhat new to perl and unix scripting, here.
> 
> I am trying to run a unix ksh script to exec a perl command on each
> file in a dir. Problem is, I need to include a dollar sign literal in
> the right side of a substitution, like so:
> -------------------------------
> #!/bin/ksh
> PATH=$PATH:/dbmgtu01/app/oracle/orbitz/1.0.0/bin:.
> for FILE in dc0003*
> do
>   echo $FILE
>   cp $FILE $FILE.bk
>   perl -pi -e "s/(.*)dc0003\.maintain\.partitions(.*dev.*)/
> \1$calling_program_dev\2/g" $FILE
> done
> ------------------------------
> 
> Only this does not work, because perl wants to replace the
> $calling_program_dev with a ksh variable.

Did you try it with single quotes instead of double quotes?  Also the use of 
\1 and \2 should only be used inside a regular expression.


perl -pi -e 
's/(.*)dc0003\.maintain\.partitions(.*dev.*)/$1$calling_program_dev$2/g' $FILE



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


------------------------------

Date: Wed, 04 Jul 2007 00:31:31 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: dollar sign literals
Message-Id: <cfjl83hgta62vbdpupdcmdkk5unpgciojf@4ax.com>

On Tue, 03 Jul 2007 12:59:36 -0700, Jason Williams
<Jason.Williams.0617@gmail.com> wrote:

>  perl -pi -e "s/(.*)dc0003\.maintain\.partitions(.*dev.*)/
>\1$calling_program_dev\2/g" $FILE
>done
>------------------------------
>
>Only this does not work, because perl wants to replace the
>$calling_program_dev with a ksh variable.

No, it's ksh than wants to replace the $calling_program_dev with its
own $calling_program_dev variable. Just use ksh's quoting mechanism to
prevent this, which I guess probably can amount to just
\$calling_program_dev.


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: Tue, 03 Jul 2007 16:53:40 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: improvement suggestion for File::Find: pre-parsed extensions
Message-Id: <m2k5thb44r.fsf@lifelogs.com>

On Tue, 03 Jul 2007 12:17:06 -0700 Paul Lalli <mritty@gmail.com> wrote: 

PL> On Jul 3, 2:00 pm, Ted Zlatanov <t...@lifelogs.com> wrote:
>> On Tue, 03 Jul 2007 10:26:55 -0700 Paul Lalli <mri...@gmail.com> wrote:
>> 
PL> On Jul 3, 11:57 am, Ted Zlatanov <t...@lifelogs.com> wrote:
>> 
>> >> I think it would be really useful if in addition to $File::Find::name
>> >> and $_ there were also $File::Find::namenoext, $_namenoext ($_ without
>> >> the extension), and $File::Find::ext (the extension itself).
>> 
PL> File::Basename makes those values trivially easy to obtain.
>> 
>> No, you still have to a) use the module, and b) call the functions.
>> That's not trivial compared to "the value is in $ext".

PL> We'll have to agree to disagree as to the definition of "trivial".

Obviously anything that requires another module is not trivial, unless
you've done it for so long you don't notice the annoyance.

>> and the extra memory usage is negligible.  I don't think we should
>> sacrifice convenience for an unnecessary optimization.

PL> And I don't think we should unnecessarily bloat a module to duplicate
PL> functionality already available elsewhere.

Explain where's the bloat.  And why do you assume the functionality is
duplicated?  Access to a variable doesn't equate duplication of effort.
The patch I had in mind would just use File::Basename internally.  The
whole behaviour could be optional if you and others feel strongly, but
it's hardly duplication.

Ted


------------------------------

Date: Tue, 03 Jul 2007 16:59:26 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: improvement suggestion for File::Find: pre-parsed extensions
Message-Id: <m2d4z9b3v5.fsf@lifelogs.com>

On Tue, 03 Jul 2007 21:28:48 +0200 Michele Dondi <bik.mido@tiscalinet.it> wrote: 

MD> For me File::Basename is so near to my hand and the kind info you
MD> mention rare enough to be a need of mine that I don't see that as a
MD> compellingly desirable feature. Perhaps a F::F on steroids with either
MD> additional stuff passed to the wanted() sub or an object $_ with
MD> suitable methods *or both* would be welcome. For suitable methods I
MD> mean $_->name, $_->ext, $_->basename, $_->stat (so that you don't have
MD> to do that again, etc.) Of course this would be max fun in Perl 6 with
MD> its unary dot:

MD>   find { .basename.say if .ext ~~ 'txt' }, $dir;

Yes, that should really be an object.  But that would be a major API
change compared to providing some extra info for the current file.  I'm
sure Perl 6 will have something similar or better.

Ted


------------------------------

Date: Tue, 03 Jul 2007 21:48:10 -0000
From:  RayB <rgbingham@gmail.com>
Subject: IO::Socket::Multicast in limbo?
Message-Id: <1183499290.155017.244100@a26g2000pre.googlegroups.com>

I've a device that's sending out a packet to 225.1.1.1 connected to a
Fedora Core 3 box, running with a local subnet address 192.168.1.0
connected to eth1. I installed ethereal on the linux server and can
verify that the packet coming in through eth1 are indeed source
192.168.1.100 (the address the device uses (in this case .100) is
based upon dhcp server running on the linux box, so I know the
interface is working.)  and destination 225.1.1.1

Other info about the packet incoming: udp srcport:1024 dstport: 1118

Pertty simple. Linux Server eth1: <---> hub <---> device (or two)

I thought I could use the IO::Socket::Multicast module to receive the
initial packet, but it just sits and hangs at the recv call. I've
tried writing a simple UDP server receiver as well, but it behaves the
same way. I admit I'm pretty new at the jargon here and have tried to
change the ports etc, but it always behaves the same. I apologize if
this is an OS configuration issue, but does anyone have any ideas why
I might not be able to see these packets?

(Here's the multicast script I'm using... I got it from a book that
I'm reading, which is decent, but not specific enough for me to know
if there's something else I should be doing, regarding the setup of my
system.)

#!/usr/bin/perl
$|=1;
use IO::Socket;
use IO::Socket::Multicast;
my $port = 1118;
my $addr = '225.1.1.1';
my $sock = IO::Socket::Multicast->new('LocalPort' => $port) or die
"Can't create socket:$!";

print $sock->mcast_if;  //value is set to "any" by default

$sock->mcast_if("eth1");
$sock->mcast_add($addr) or die "mcast_add: $!";

while (1) {
  my ($msg, $peer);
  die "recv error: $!" unless $peer = recv($sock, $msg, 1024, 0); //it
hangs here...
  my ($port, $peeraddr) = sockaddr_in($peer);
  print inet_ntoa($peeraddr) . ":" . inet_ntoa($portaddr) . ": $msg
\n";
}

I have a feeling the solution is a simple issue, so I figure I'll post
this here. If there's a better newsgroup for this post, I'd be pleased
to go there.

--Ray
beanleafpress.com



------------------------------

Date: Tue, 03 Jul 2007 19:15:20 -0400
From: CBFalconer <cbfalconer@yahoo.com>
Subject: Re: Portable general timestamp format, not 2038-limited
Message-Id: <468AD888.6A023A0E@yahoo.com>

"Peter J. Holzer" wrote:
> Richard Heathfield <rjh@see.sig.invalid> wrote:
>
 ... snip ...
>
>> In that case, the obvious choice is Greenwich Mean Time.  :-)
> 
> Hardly. That hasn't been in use for over 35 years (according to
> Wikipedia).

I am glad to see you depend on absolutely reliable sources.

-- 
 <http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
 <http://www.securityfocus.com/columnists/423>
 <http://www.aaxnet.com/editor/edit043.html>
                        cbfalconer at maineline dot net


-- 
Posted via a free Usenet account from http://www.teranews.com



------------------------------

Date: Wed, 4 Jul 2007 02:14:14 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Portable general timestamp format, not 2038-limited
Message-Id: <f6evs0.18k.1@news.isolution.nl>

Peter J. Holzer schreef:

> Since a day with a leap second has 86401 seconds (or 86399, but that
> hasn't happened yet)

Many systems allow a seconds value of 0..61, so minutes (actually
months) with two leap seconds are foreseen.

A leap second may be introduced at the end of any month, the preferred
dates are at the end of June and the end of December.

At the estimated rate of decrease, the earth would lose about 1/2 day
after 4,000 years, and about two leap seconds a
month would be needed to keep UTC in step with Earth time, UT1.

(source:
<URL:http://www.allanstime.com/Publications/DWA/Science_Timekeeping/TheS
cienceOfTimekeeping.pdf>)

-- 
Affijn, Ruud

"Gewoon is een tijger."



------------------------------

Date: Tue, 03 Jul 2007 23:23:32 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Reading time from an excel sheet.
Message-Id: <UTAii.1342$eY.40@newssvr13.news.prodigy.net>

rajendra <rajendra.prasad@in.bosch.com> wrote:
> Hello All,

> There is an excel sheet which has list of events given in time. I'm trying
> to read this time using win32 module
> When I do so, I get the time in General format (0.36525874).
> But I want to read in hh-mm-ss. How can I achieve this?.

You could do the math yourself.  Excel store time/date events in days
since Jan 0, 1900.  So if you're just dealing with times (not dates),
just multiply by 86400 (seconds in a day) to get it in seconds since
midnight.

$ perl -le 'print .36525872 * 24 * 60 * 60'
31558.353408

Then you can use gmtime to convert to a time.

$ perl -MPOSIX -le 'print strftime ("%H:%M:%S", gmtime(.36525872*24*60*60))'
08:45:58

I'll bet some of the time modules will work in "excel time", but I
haven't investigated to know which ones.

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


------------------------------

Date: Wed, 04 Jul 2007 00:30:47 -0000
From:  Kaldrenon <kaldrenon@gmail.com>
Subject: Removing system files
Message-Id: <1183509047.677601.138640@57g2000hsv.googlegroups.com>

Hi all.

A while ago I installed Vista on one of my hard drives (I'm running XP
Home on the other) but quickly decided that I wasn't going to make the
switch. Now I want to get rid of the Vista system files, but since
there are things on the drive that I want to keep (more than I can
easily transfer to a different hard drive), what I'm trying to do is
to write a Perl script that uses File::Find to wipe the directories
that contain system files, leaving the remaining dirs untouched. I
wrote something that worked, or so I thought, but then I realized that
it left a large number of system files and the like in place. They're
the files which say "Access Denied" if I try to del them from cmd.exe
or Windows Explorer.

Is there an easy way to override file permissions in Perl? chmod or
something like it?

Here's what I already have (it's small enough to be its own SSCCE):

use File::Find;
$| = 1;
$\ = "\n";
@folders = ("F:/Windows","F:/Program Files","F:/Program Data","F:/
Users");
find(\&break_it, @folders);

sub break_it
{
    unlink($_) if -f;
    rmdir($_) if -d;
    print $_, " deleted.";
}

P.S. I realize that this would be a horrendously unsafe idea if I
weren't convinced that I don't want these files any more.

Thanks,
Andrew



------------------------------

Date: Tue, 3 Jul 2007 14:27:06 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: small mistake: http://perl.plover.com/FAQs/Namespaces.html
Message-Id: <f6eevc062f@news2.newsguy.com>

I was reading through this FAQ to brush up on some things when I noticed 
a small typo:

     Added 2000-01-05: Perl 5.6.0 introduced a new our(...) declaration.
     Its syntax is the same as for my(), and it is a replacement for use
     vars.

     Without getting into the details, our() is just like use vars; its
     only effect is to declare variables so that they are exempt from 
the
     strict 'vars' checking. It has two possible advantages over use
     vars, however: Its syntax is less weird, and its effect is lexical.
     That is, the exception that it creates to the strict checking
     continues only to the end of the current block:

        use strict 'vars';
        {
          our($x);
          $x = 1;   # Use of clobal variable $x here is OK
                             ^^^^^^

Unless I'm mistaken, that should be 'global'

I know this isn't a big deal, just thought I would post here so the 
maintainers can fix it. Thanks for the great docs, once again :)

-- 
szr 




------------------------------

Date: Wed, 04 Jul 2007 00:33:22 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: small mistake: http://perl.plover.com/FAQs/Namespaces.html
Message-Id: <7kjl835puek0rnlgk57k5n9kg3jsc9cbha@4ax.com>

On Tue, 3 Jul 2007 14:27:06 -0700, "szr" <szrRE@szromanMO.comVE>
wrote:

>          $x = 1;   # Use of clobal variable $x here is OK
>                             ^^^^^^
>
>Unless I'm mistaken, that should be 'global'
>
>I know this isn't a big deal, just thought I would post here so the 
>maintainers can fix it. Thanks for the great docs, once again :)

I don't think MJD ever gives a peek here. Try to reach him directly
instead.


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: Tue, 3 Jul 2007 16:58:45 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: small mistake: http://perl.plover.com/FAQs/Namespaces.html
Message-Id: <f6enrn0g1j@news2.newsguy.com>

Michele Dondi wrote:
> On Tue, 3 Jul 2007 14:27:06 -0700, "szr" <szrRE@szromanMO.comVE>
> wrote:
> >
> >          $x = 1;   # Use of clobal variable $x here is OK
> >                             ^^^^^^
> >
> > Unless I'm mistaken, that should be 'global'
> >
> > I know this isn't a big deal, just thought I would post here so the
> > maintainers can fix it. Thanks for the great docs, once again :)
>
> I don't think MJD ever gives a peek here. Try to reach him directly
> instead.

Thank you, I have now sent a notification.

-- 
szr 




------------------------------

Date: Tue, 03 Jul 2007 14:10:14 -0600
From: Chris Barts <puonegf+hfrarg@tznvy.pbz>
Subject: Re: The Modernization of Emacs: terminology buffer and keybinding
Message-Id: <f6eaf9$q2d$1@aioe.org>

blmblm@myrealbox.com <blmblm@myrealbox.com> wrote on Monday 25 June 2007
15:43 in comp.emacs <5ear80F36ga72U3@mid.individual.net>:

> 
> Eclipse has something that generates "import" statements with
> a few keystrokes, and for me that's almost in the "killer app
> [feature]" class.  

This is a sign of a weak programming language, in my eyes: If you need
keystroke macros to enter boilerplate, you REALLY need a language that
allows you to package commonly-used idioms into macros. (See Common Lisp,
Scheme, Emacs Lisp, and, indeed, even Dylan. Python and Ruby almost solve
the same problem by providing a richer set of primitives, but they aren't
extensible.)

> (Why do I strongly suspect that with the 
> right plug-ins emacs can do this too?  :-)   That would send
> me searching for the Web site where vim macros are collected.)
> 

Inserting literal text in Emacs using keystroke macros is trivial. Inserting
more changeable boilerplate is a job for Emacs Lisp.

-- 
My address happens to be com (dot) gmail (at) usenet (plus) chbarts,
wardsback and translated.
It's in my header if you need a spoiler.



------------------------------

Date: Wed, 04 Jul 2007 00:26:45 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: unlurking
Message-Id: <34jl83psdd77dvuf1m83s6j9ef0kj8jlj9@4ax.com>

On Tue, 3 Jul 2007 16:03:36 -0400, "Wade Ward" <invalid@invalid.nyet>
wrote:

>> It depends on (i) what your notion is, which you don't explain and
>> (ii) what you suspect Perlities(?) to think it is, which you also
>> don't explain.
>My background is algebra, of which group theory is a bulwark.  They're 
>different ideas entirely.

In fact the complete classification of newsgroups is considerably
simpler than that of finite simple groups, for example. But yours
still stands out as a misplaced piece of humour IMHO.

>OP has _Programming Perl_ and _Perl in a nutshell_ in hand.  Do these count 
>as standard references?

The former, certainly. The latter, I don't know.


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: Tue, 3 Jul 2007 19:13:54 -0400
From: "Wade Ward" <invalid@invalid.nyet>
Subject: Re: unlurking
Message-Id: <YO2dnawjysvsRRfbnZ2dnUVZ_gqdnZ2d@comcast.com>


"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message 
news:34jl83psdd77dvuf1m83s6j9ef0kj8jlj9@4ax.com...
> On Tue, 3 Jul 2007 16:03:36 -0400, "Wade Ward" <invalid@invalid.nyet>
> wrote:
>
>>> It depends on (i) what your notion is, which you don't explain and
>>> (ii) what you suspect Perlities(?) to think it is, which you also
>>> don't explain.
>>My background is algebra, of which group theory is a bulwark.  They're
>>different ideas entirely.
>
> In fact the complete classification of newsgroups is considerably
> simpler than that of finite simple groups, for example. But yours
> still stands out as a misplaced piece of humour IMHO.
If it is humor, I hope it is topical here.  The classification puts the heat 
on computer scientists to catch up.

>>OP has _Programming Perl_ and _Perl in a nutshell_ in hand.  Do these 
>>count
>>as standard references?
>
> The former, certainly. The latter, I don't know.
The topic of the thread really was "unlurking," and, with reference in hand, 
I'll start over.  If you have an aversion to silly-sounding questions, I 
suggest that such a person killfile me now, as opposed to when I'm poring a 
perl reference and don't want to be told that I'm an idiot.
-- 
WW




------------------------------

Date: Tue, 3 Jul 2007 19:41:57 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: unlurking
Message-Id: <slrnf8lr6l.id5.tadmc@tadmc30.sbcglobal.net>

Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On Tue, 3 Jul 2007 16:03:36 -0400, "Wade Ward" <invalid@invalid.nyet>
> wrote:

>>OP has _Programming Perl_ and _Perl in a nutshell_ in hand.  Do these count 
>>as standard references?
>
> The former, certainly. The latter, I don't know.


They do not count as the "standard references" mentioned upthread.

What "group" means in a Usenet context is independant of
any programming language.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Tue, 03 Jul 2007 23:04:40 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: using wildcards with -e
Message-Id: <slrnf8llco.h52.tadmc@tadmc30.sbcglobal.net>

Clenna Lumina <savagebeaste@yahoo.com> wrote:

> Although most of the built in functions (sort, grep, map, ...) that 
> return lists behave as you expect in scalar context too.


You expected that sort() in a scalar context behaves
in an undefined manner?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Tue, 3 Jul 2007 17:15:15 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: using wildcards with -e
Message-Id: <5f074lF3admfkU1@mid.individual.net>

Tad McClellan wrote:
> Clenna Lumina <savagebeaste@yahoo.com> wrote:
>
>> Although most of the built in functions (sort, grep, map, ...) that
>> return lists behave as you expect in scalar context too.
>
>
> You expected that sort() in a scalar context behaves
> in an undefined manner?

Hmmm, I stand corrected. I ran some quick command-line tests, showing 
that 'map' and 'grep' return the item count but sort does not. It just 
seems to return undef:

   $ perl -le 'my @list = qw/1 2 4 8 16 32/; print(defined(scalar sort 
@list) ? "Y" : "N");'
   N

Why is this?

   $ perldoc -f sort
       sort SUBNAME LIST
       sort BLOCK LIST
       sort LIST
               Sorts the LIST and returns the sorted list value.
               [...]

It seems that it is supposed to be returning a list (assuming "list 
value", means that it's returning a list, which is the case in list 
context.) Having read through the whole article I can't seem to find a 
reason why it would returning undef. What use cold this possible have? 
Wouldn't it have been more logical to return the same was as 'map' and 
'grep' in scalar context?

-- 
CL 




------------------------------

Date: Tue, 3 Jul 2007 19:39:34 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: using wildcards with -e
Message-Id: <slrnf8lr26.id5.tadmc@tadmc30.sbcglobal.net>

Clenna Lumina <savagebeaste@yahoo.com> wrote:
> Tad McClellan wrote:
>> Clenna Lumina <savagebeaste@yahoo.com> wrote:
>>
>>> Although most of the built in functions (sort, grep, map, ...) that
>>> return lists behave as you expect in scalar context too.
>>
>>
>> You expected that sort() in a scalar context behaves
>> in an undefined manner?
>
> Hmmm, I stand corrected. I ran some quick command-line tests, showing 
> that 'map' and 'grep' return the item count but sort does not. It just 
> seems to return undef:
>
>    $ perl -le 'my @list = qw/1 2 4 8 16 32/; print(defined(scalar sort 
> @list) ? "Y" : "N");'
>    N
>
> Why is this?


   perldoc -f sort

       sort SUBNAME LIST
       sort BLOCK LIST
       sort LIST
            In list context, this sorts the LIST and returns the sorted list
            value.  In scalar context, the behaviour of "sort()" is unde‐
            fined.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Tue, 3 Jul 2007 18:03:29 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: using wildcards with -e
Message-Id: <5f09v3F3ag83pU1@mid.individual.net>

Tad McClellan wrote:
> Clenna Lumina <savagebeaste@yahoo.com> wrote:
>> Tad McClellan wrote:
>>> Clenna Lumina <savagebeaste@yahoo.com> wrote:
>>>
>>>> Although most of the built in functions (sort, grep, map, ...) that
>>>> return lists behave as you expect in scalar context too.
>>>
>>>
>>> You expected that sort() in a scalar context behaves
>>> in an undefined manner?
>>
>> Hmmm, I stand corrected. I ran some quick command-line tests, showing
>> that 'map' and 'grep' return the item count but sort does not. It
>> just seems to return undef:
>>
>>    $ perl -le 'my @list = qw/1 2 4 8 16 32/; print(defined(scalar
>> sort @list) ? "Y" : "N");'
>>    N
>>
>> Why is this?
>
>
>   perldoc -f sort
>
>       sort SUBNAME LIST
>       sort BLOCK LIST
>       sort LIST
>            In list context, this sorts the LIST and returns the
>            sorted list value.  In scalar context, the behaviour of
>            "sort()" is unde� fined.

I understand that it is undefined behavior, but what I'm trying to 
determine is what useful purpose could that possibly serve? Why doesn't 
it just return the count?

(Note to self, update perldoc.)


-- 
CL 




------------------------------

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 616
**************************************


home help back first fref pref prev next nref lref last post