[24979] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7229 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 10 00:07:02 2004

Date: Sat, 9 Oct 2004 21:05: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           Sat, 9 Oct 2004     Volume: 10 Number: 7229

Today's topics:
        C (I think) to Perl Conversion <sammie-nospam@greatergreen.com>
    Re: getting telnet banner <usenet@morrow.me.uk>
    Re: How do I Capitalize the first letter? <usenet@morrow.me.uk>
    Re: How do I Capitalize the first letter? <lv@aol.com>
    Re: How to automatically log in a web page? <ceo@nospam.on.net>
    Re: Is PHP still slower than Perl? <jason@ukpost.com>
    Re: locking items in a collection ctcgag@hotmail.com
        reducing regex to common function name (Thomas Randall)
    Re: reducing regex to common function name <usenet@morrow.me.uk>
    Re: reducing regex to common function name <postmaster@castleamber.com>
    Re: subtracting strings <usenet@morrow.me.uk>
    Re: To Tad: Great perl class, and question <tadmc@augustmail.com>
    Re: Using a string as a variable name. <uri@stemsystems.com>
    Re: Using a string as a variable name. <usenet@riddlemaster.org>
    Re: Using a string as a variable name. <uri@stemsystems.com>
    Re: Using a string as a variable name. <jurgenex@hotmail.com>
    Re: Using a string as a variable name. <usenet@morrow.me.uk>
    Re: While query <usenet@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 9 Oct 2004 20:47:50 -0700
From: "Brad Walton" <sammie-nospam@greatergreen.com>
Subject: C (I think) to Perl Conversion
Message-Id: <l6CdnR_E38t7LfXcRVn-ow@comcast.com>

I'm stuck here... I have a sample script which accomplishes the task I need
done, but it's done in another programing language (of which I have no
understanding). I have researched this for hours and hours, but no luck.

The script I need 'deciphered' to Perl:

----
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <netinet/tcp.h>

int main(int argc, char *argv[] )
{
        int sock = socket(  AF_INET, SOCK_STREAM, IPPROTO_TCP );
        if ( sock == -1 )
        {
                printf( "Socket creation failed" );
                exit(-1);
        }

        struct sockaddr_in rcon_server;
        rcon_server.sin_family = AF_INET;
        rcon_server.sin_addr.s_addr = inet_addr( "127.0.0.1" );
        rcon_server.sin_port = htons( 27015 );

        if ( connect( sock, (const struct sockaddr *)&rcon_server,sizeof(
rcon_server ) )!= 0 )
        {
                printf( "Unable to connect\n");
                exit(-1);
        }

        unsigned char send_buf[4096];
        unsigned char *send_ptr = send_buf + sizeof(int);

        *(int *)send_ptr = 0x0001; // request id 1
        send_ptr += sizeof(int);
        *(int *)send_ptr = 0x0003; // command id 3
        send_ptr += sizeof(int);

        strcpy( (char *)send_ptr, "password" ); // the rcon password
        send_ptr += strlen("password") +1; //+1 for null terminator
        *(int *)send_ptr = 0; // 2nd string is just null
        send_ptr++;
        (*(int *)send_buf) = (int)(send_ptr - send_buf - sizeof(int)); //
now setup the size of this packet (NOTE the subtraction of sizeof(int)!!)

        printf( "Sending packet (%d bytes)\n", *(int *)(send_buf) );

        send( sock, send_buf, *(int *)(send_buf) + sizeof(int), 0 ); // send
the auth request

        sleep(1); // ugly hack to give the server time to respond

        long readLen;
        ioctl( sock, FIONREAD, &readLen );
        printf("Got %d bytes from server\n", readLen );

        int len = recv( sock, send_buf, readLen, 0);
        if ( len < 14 )
        {
                printf("Didn't read enough data (%i)( TODO: block on
reads)\n", len);
                exit(-1);
        }

        printf( "packet size: %d, request id:%d, command:%d\n",
(int)send_buf[0],(int)send_buf[4],(int)send_buf[8]);

        if ( len > 14 ) // a 2nd packet is in the response
        {
                printf( "packet size: %d, request id:%d, command:%d\n",
(int)send_buf[14],(int)send_buf[18],(int)send_buf[22]);
        }

        close( sock );
}
----

This is a longshot.. but I don't know what else to do.

Thanks for any help,
Brad




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

Date: Sat, 9 Oct 2004 21:17:08 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: getting telnet banner
Message-Id: <4jtl32-hs4.ln1@osiris.mauzo.dyndns.org>


Quoth zebee@zip.com.au:
> In comp.lang.perl.misc on Sat, 9 Oct 2004 04:56:51 +0000 (UTC)
> David Efflandt <efflandt@xnet.com> wrote:
> > 
> > I don't know if a telnet banner typically has more than one line (I use
> > ssh instead), but following is a simple example that can read/print a line
> > (works as well for polling smtp servers, etc.):
> 
> Mine does... it's one of the reasons I want to read it, as it changes
> depending on certain events.

Then read lines until you get a login prompt, and parse.

> > use IO::Socket;
> > $remote = IO::Socket::INET->new (
> >         Proto           => "tcp",
> >         PeerAddr        => "localhost",
> >         PeerPort        => "telnet(21)",
> >         )
> >         or die "can't connect";
> > $_ = <$remote>;
> > print;
> 
> 
> I can't find any of those items in the IO::Socket perldoc, where do they
> come from?

Try the docs for the class you are using, IO::Socket::INET.

> What's the "telnet(21)" thing, telnet's port 23?

A typo :). 'telnet(21)' as a port specification tells IO::Socket::INET
to look 'telnet' up with getservbyname and if that fails to use port 23
instead. Specifying 21 would mysteriously fail when you ran the script
on a machine with a broken /etc/services.

> I tested it on my system and tcpdump tells me it is connecting, but I 
> see no output and it doesn't exit, same symptoms as my original program.

Try reading more lines; perhaps the first line from your telnet server
is blank.

Ben

-- 
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t    # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.


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

Date: Sat, 9 Oct 2004 19:52:02 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: How do I Capitalize the first letter?
Message-Id: <ijol32-7a4.ln1@osiris.mauzo.dyndns.org>


Quoth Paul Lalli <mritty@gmail.com>:
>
> s/(^|\s)(\w)/$1\u$2/g;

I would use positive look-behind:

s/(?:^|(?<=\s))(\w)/\u$1/g;

just 'cos it's neater. No variable-length lookbehind is annoying, though...

Ben

-- 
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~                   Jorge Luis Borges, 'The Babylon Lottery'


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

Date: Sat, 09 Oct 2004 17:25:48 -0500
From: l v <lv@aol.com>
Subject: Re: How do I Capitalize the first letter?
Message-Id: <41686365$1_4@127.0.0.1>

nntp wrote:
> s/\s(\w)//g;
> how to inclue the fist letter in too?
> 
> I want to make
> abc xyz to Abc Xyz
> 
> 

Not sure on exactly what you are asking for.  Below will capitalize the 
first letter of every word in $a.

join ' ', ( map {ucfirst $_ } split /\W/, $a );

Len


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: Sun, 10 Oct 2004 02:44:23 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: How to automatically log in a web page?
Message-Id: <bm1ad.8314$Rf1.6769@newssvr19.news.prodigy.com>

nntp wrote:

> I did basic UserAgent, but it is not working as it is password protected.
> 
> When I use browser to visit
> http://www.goofiz.com/forum/login.php?redirect=gf_history.php?user_id=1443
> It asks for a password. I checked cookie. It uses a session ID by PHP
> 
> I have the password and login username. How do I access it by automatically
> submit login/pass? Where should I use the POST?
> 

It would help to be more specific about what "it is password protected" 
means.  How were you prompted?  There are a number of ways this can 
happen depending on the page and the server which is serving the pages.

I am unable to check your URL at this time for further clues.

-ceo


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

Date: Sat, 9 Oct 2004 20:07:49 +0100
From: Jason Clifford <jason@ukpost.com>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <Pine.LNX.4.44.0410092006450.28464-100000@yeoshua.ukpost.com>

On Sat, 9 Oct 2004, Eric J. Roode wrote:

> > I'd say it is because C does not have strings as a native data type.
> > Other than initializing an array of char, the C compiler has no
> > string manipulation built in; it requires library functions to do that.
> >      -Joe
> 
> I'm surprised that there aren't any open-source CGI libraries out there for 
> doing things like parsing CGI variables, getting/setting cookies, etc.

Do you mean libraries like GCGI (http://catchen.org/gcgi/)?

Jason Clifford
-- 
UKFSN.ORG		Finance Free Software while you surf the 'net
http://www.ukfsn.org/	   ADSL Broadband from just £21.50 / month 



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

Date: 10 Oct 2004 02:43:53 GMT
From: ctcgag@hotmail.com
Subject: Re: locking items in a collection
Message-Id: <20041009224353.274$oF@newsreader.com>

tkeith@mindspring.com (Tim Keith) wrote:
> I have a collection of 10 named items from which I would like
> to lock 1 to 10 items in a single request.  Multiple processes
> may request "tokens" from the collection.

Are "items" and "tokens" the same thing?

> At any time 1 to 10
> items of the collection can be assigned to unique process ids
> during which time a lock is held on the token.

Are you sure it isn't 0 to 10 of them?  Is the state of an item being
assigned to a process ids identical to the state of a process holding
a lock on a token, or are those two different actions?


> Each item must have a specific name, lock requests are made
> for a count of items.

What is the point of them having specific names if they are not
asked for by that specific name?  What happens if the count can only
be partially satisfied?


> When items are unlocked, the unlock
> request can use either a handle returned by the original
> lock request, or in a special case - unlocked by a request
> using its ordinal value(1 - 10).
>
> Each of the ten items will be tied to a process id (and possibly
> other arbitrary data).

What does this mean?  Obviously, a process that holds a lock on a token
"knows" that it does so.  And a process can contain any aribtrary data,
and therefore can associate it with a token.  Is that not sufficient?  If
not, what else is required?  Does the lock server need to report to other
processes on who own certain locks?


> When the process terminates the token
> can be unlocked so that other processes may request a lock for
> the token.

"Can be" or "must be"?  Is autodetection of dead connections allowed, or
mandatory?

>
> No two requests should be assigned the same token when multiple
> requests for tokens occur simulaneously.
>
> Is there a CPAN module that would provides this functionality?

I was thinking of DBD::MySQL to work with MySQL lock manager (which
let's you coordinate locking of arbitrary string tokens), but it appears
that any connection can only hold one lock at a time.  That means each
client would need upto 10 separate connections, which would not be very
efficient.

Are all the processes going to run ont the same machine? Are they all
going to be started by forking?  Or by threads?  Or independently?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 9 Oct 2004 13:37:34 -0700
From: Thomas_Randall_1950@yahoo.com (Thomas Randall)
Subject: reducing regex to common function name
Message-Id: <37767874.0410091237.65ef4cfd@posting.google.com>

I have been given a project to complete regarding Perl regular
expressions.  I need to evaluate a given regular expression and
evaluate its effect on a string and compare to the effects of a list
of common functions and identify a match so that a Perl function may
be automatically generated with an appropriate name to encapsulate the
regex.

For example:

$out =~ s/^\s*//;
$out =~ s/\s*$//;

These two lines will trim white space from the front and back of the
string $out.  This is equivalent to the function Trim() which can be
found in many languages and function libraries.

I need to write a subroutine such that:

print conversion('s/^\s*//','s/\s*$//');

will generate the output: Trim()

of course I need to be able to match and reduce all regex's to their
equivalent common function name or return undef if there is no
conversion possible.

From there I will need to generate a perl module file containing the
Trim function which will wrap the regex.  I think I can do this part
with no problem.

I would greatly appreciate any advice as to where to start on this
project.  I admit that it is a question on our take home final exam,
so of course I do not ask for too much help, but a pointer in the
right direction would be greatly appreciated.  The professor did allow
us to ask for help on usenet with confidence that we would not be
spoon fed an answer or that at least he could check up on us.

Tom


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

Date: Sat, 9 Oct 2004 23:22:46 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: reducing regex to common function name
Message-Id: <mu4m32-qd8.ln1@osiris.mauzo.dyndns.org>


Quoth Thomas_Randall_1950@yahoo.com (Thomas Randall):
> I have been given a project to complete regarding Perl regular
> expressions.  I need to evaluate a given regular expression and
> evaluate its effect on a string and compare to the effects of a list
> of common functions and identify a match so that a Perl function may
> be automatically generated with an appropriate name to encapsulate the
> regex.

The crucial issue here is 'how is your list of common functions
specified'? I would, for a Perl project, specify it as a mapping from
function to regex; but that makes the project trivial :).

Can you show us the format you have your list in?

Ben

-- 
           All persons, living or dead, are entirely coincidental.
ben@morrow.me.uk                                                  Kurt Vonnegut


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

Date: 10 Oct 2004 00:44:15 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: reducing regex to common function name
Message-Id: <Xns957DC8C42E515castleamber@130.133.1.4>

Ben Morrow wrote:

> 
> Quoth Thomas_Randall_1950@yahoo.com (Thomas Randall):
>> I have been given a project to complete regarding Perl regular
>> expressions.  I need to evaluate a given regular expression and
>> evaluate its effect on a string and compare to the effects of a list
>> of common functions and identify a match so that a Perl function may
>> be automatically generated with an appropriate name to encapsulate the
>> regex.
> 
> The crucial issue here is 'how is your list of common functions
> specified'? I would, for a Perl project, specify it as a mapping from
> function to regex; but that makes the project trivial :).

Finding the regex and mapping them to functions would be less trivial 
however. Especially finding combinations of regexes that can be replaced by 
function(s).

Sounds like jumping into the parse tree of Perl and working from there is a 
good starting point.

-- 
John                               MexIT: http://johnbokma.com/mexit/
                           personal page:       http://johnbokma.com/
        Experienced programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html


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

Date: Sat, 9 Oct 2004 21:13:13 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: subtracting strings
Message-Id: <pbtl32-hs4.ln1@osiris.mauzo.dyndns.org>


Quoth "Jürgen Exner" <jurgenex@hotmail.com>:
> Dan Jones wrote:
> 
> > $stringtosub may contain characters which would need to be escaped in
> > a regex.
> 
> Yep, that's a problem. But you may want to take a look at the "qr" operator.

ITYM 'quotemeta' or the \Q regex escape?

Ben

-- 
"If a book is worth reading when you are six,                * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis


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

Date: Sat, 9 Oct 2004 19:35:16 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: To Tad: Great perl class, and question
Message-Id: <slrncmh0u4.9ar.tadmc@magna.augustmail.com>

John W. Krahn <someone@example.com> wrote:
> Tad McClellan wrote:
>> asdfasd <af4bh@iglou.com> wrote:
>> 
>>>Thanks Tad.  I enjoy your training class a lot during your visit here in
>>>Lexington, Kentucky.
>> 
>> Cool! 
>> 
>> It was my 1st time in Kentucky, I found I liked it a lot.
> 
> Did you bring us back some J.D.   :-)


Yesh, butt it sheems to have gone mishing...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 09 Oct 2004 21:58:36 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Using a string as a variable name.
Message-Id: <x78yafpnbc.fsf@mail.sysarch.com>

>>>>> "EJR" == Eric J Roode <sdn.girths00869@zoemail.net> writes:

  >> Is it possible?

  EJR> Strange that you could figure out how to print the indirect value
  EJR> out, but you couldn't figure out how to assign indirectly.  :-)

  EJR>     ${$v1} = "it worked!";


strange that you should know better than to give a symref answer without
all the usual caveats on how dangerous and wrong it is.

	$hash{$v1} = 'better than just working!' ;

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Sat, 09 Oct 2004 18:11:06 -0500
From: Dan Jones <usenet@riddlemaster.org>
Subject: Re: Using a string as a variable name.
Message-Id: <JLydndLDt-SG__XcRVn-sA@speakeasy.net>

Uri Guttman wrote:

>>>>>> "EJR" == Eric J Roode <sdn.girths00869@zoemail.net> writes:
> 
>   >> Is it possible?
> 
>   EJR> Strange that you could figure out how to print the indirect value
>   EJR> out, but you couldn't figure out how to assign indirectly.  :-)
> 
>   EJR>     ${$v1} = "it worked!";
> 
> 
> strange that you should know better than to give a symref answer without
> all the usual caveats on how dangerous and wrong it is.
> 
> $hash{$v1} = 'better than just working!' ;

Care to expound?  What is dangerous about the first example?  What's with
the "hash" in the second?  As I understand it, there was no hash involved -
it was the name of a scalar variable stored as a string in another scalar. 
Is hash a keyword or simply a variable name?  If this is a FAQ or a perldoc
question, a pointer to the right location would be appreciated.  I don't
find anything looking there and a Google for $hash doesn't show up anything
that seems relevant.




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

Date: Sat, 09 Oct 2004 22:54:42 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Using a string as a variable name.
Message-Id: <x77jpzld0e.fsf@mail.sysarch.com>

>>>>> "DJ" == Dan Jones <usenet@riddlemaster.org> writes:

  DJ> Uri Guttman wrote:

  >> strange that you should know better than to give a symref answer without
  >> all the usual caveats on how dangerous and wrong it is.
  >> 
  >> $hash{$v1} = 'better than just working!' ;

  DJ> Care to expound?  What is dangerous about the first example?
  DJ> What's with the "hash" in the second?  As I understand it, there
  DJ> was no hash involved - it was the name of a scalar variable stored
  DJ> as a string in another scalar.  Is hash a keyword or simply a
  DJ> variable name?  If this is a FAQ or a perldoc question, a pointer
  DJ> to the right location would be appreciated.  I don't find anything
  DJ> looking there and a Google for $hash doesn't show up anything that
  DJ> seems relevant.

search google for my name and posts about symrefs or symbolic refs. i
have posted many times as to why they are wrong.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Sat, 09 Oct 2004 23:06:17 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Using a string as a variable name.
Message-Id: <J9_9d.2780$ua2.1065@trnddc09>

Dan Jones wrote:
> Uri Guttman wrote:
>> strange that you should know better than to give a symref answer
>> without all the usual caveats on how dangerous and wrong it is.
>>
>> $hash{$v1} = 'better than just working!' ;
>
> Care to expound?  What is dangerous about the first example?

You must have missed the gazillions of posts about why symbolic references 
are bad, bad, BAD.

Why would you want to mess around with the system symbol table (that's what 
you are effectively doing with symrefs) instead of using your own hash? Not 
to mention the implied limitations like local variables, strictures, etc.

> What's with the "hash" in the second?  As I understand it, there was no 
> hash
> involved -

Yes, there was. Symbolic references are abusing the internal system symbol 
table hash.

> it was the name of a scalar variable stored as a string in
> another scalar. Is hash a keyword or simply a variable name?  If this
> is a FAQ or a perldoc question, a pointer to the right location would
> be appreciated.  I don't find anything looking there and a Google for
> $hash doesn't show up anything that seems relevant.

perldoc -q "variable name"
http://www.google.com/groups?as_epq=symbolic%20ref&as_ugroup=comp.lang.perl.misc
http://www.google.com/groups?as_epq=symref&as_ugroup=comp.lang.perl.misc

jue




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

Date: Sat, 9 Oct 2004 23:25:34 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Using a string as a variable name.
Message-Id: <u35m32-qd8.ln1@osiris.mauzo.dyndns.org>


Quoth Dan Jones <usenet@riddlemaster.org>:
> Uri Guttman wrote:
> > 
> > strange that you should know better than to give a symref answer without
> > all the usual caveats on how dangerous and wrong it is.
> > 
> > $hash{$v1} = 'better than just working!' ;
> 
> Care to expound?  What is dangerous about the first example?  What's with
> the "hash" in the second?  As I understand it, there was no hash involved -
> it was the name of a scalar variable stored as a string in another scalar. 
> Is hash a keyword or simply a variable name?  If this is a FAQ or a perldoc
> question, a pointer to the right location would be appreciated.  I don't
> find anything looking there and a Google for $hash doesn't show up anything
> that seems relevant.

Google for the several-threads-a-week on this topic (using a variable as
a variable name, or 'symrefs'), or read perldoc -q variable name. If you
don't know what a hash is, start with perldoc perldata.

Ben

-- 
I've seen things you people wouldn't believe: attack ships on fire off
the shoulder of Orion; I watched C-beams glitter in the dark near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die.                                                   ben@morrow.me.uk


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

Date: Sat, 9 Oct 2004 20:10:02 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: While query
Message-Id: <alpl32-7a4.ln1@osiris.mauzo.dyndns.org>


Quoth Paul Lalli <mritty@gmail.com>:
> Ben Morrow wrote:
> 
> > The comma operator constructs lists; a list
> > evaluated in scalar context evaluates all its members but the last in
> > void context and the last in scalar context, which is then the list's
> > value.
> 
> So the Perl FAQ is wrong?  I refer you to the array vs list perlfaq:
<snip>
> And likewise, perldoc perlop is also wrong?

Hmmm.... at the risk of sounding arrogant :), yes, I would say so. Perl
always compiles the comma operator into the same ops: those which build
a list. As a list-in-scalar-context evaluates to its last entry, the
two operators described in perlop will always produce the same results
as the one perl actually uses, making this perhaps an irrelevant
distinction; however, I would say that what actually happens is simpler
and (for me, at least) easier to understand than saying there are two
different comma operators. For example, take

sub foo {
    return (1, 2, 3);
}

 . When this sub is compiled, perl cannot know what context it will be
called in, so how can it know 'which' comma operator you mean?

> > perl -MO=Graph,-dot -e'my $count = (1,2)' | dot -Tps
> 
> I admit to having no idea what any of the above arguments, nor the below 
> output mean.  I will research tomorrow after a night's rest.

:)

B::Graph produces a graph showing the optree perl generates for a given
piece of code. What I typed below is a very simplified diagram showing
the structure of the output for that piece of code.

Ben

-- 
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else ** 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 V10 Issue 7229
***************************************


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