[32184] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3449 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 21 14:14:37 2011

Date: Thu, 21 Jul 2011 11:14:25 -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           Thu, 21 Jul 2011     Volume: 11 Number: 3449

Today's topics:
    Re: a little parsing challenge ? <jurgenex@hotmail.com>
    Re: a little parsing challenge ??? <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: global variable scope in perl <rvtol+usenet@xs4all.nl>
    Re: global variable scope in perl <rweikusat@mssgmbh.com>
    Re: global variable scope in perl <RedGrittyBrick@spamweary.invalid>
    Re: global variable scope in perl <eswar.kodati@gmail.com>
    Re: global variable scope in perl <rvtol+usenet@xs4all.nl>
    Re: global variable scope in perl <rweikusat@mssgmbh.com>
    Re: global variable scope in perl <rvtol+usenet@xs4all.nl>
    Re: global variable scope in perl <rweikusat@mssgmbh.com>
        I can't install cpan DBD::mysql <j.joeyoung@gmail.com>
    Re: I can't install cpan DBD::mysql <gavcomedy@gmail.com>
    Re: I can't install cpan DBD::mysql <gavcomedy@gmail.com>
        Perl - Windows - MP3 player <kiloran.public+news@gmail.com>
    Re: Perl - Windows - MP3 player <willem@toad.stack.nl>
    Re: Perl - Windows - MP3 player <tadmc@seesig.invalid>
        syntax query: ($var++ && next) if /match/ <justin.1104@purestblue.com>
    Re: syntax query: ($var++ && next) if /match/ <rweikusat@mssgmbh.com>
    Re: syntax query: ($var++ && next) if /match/ <willem@toad.stack.nl>
    Re: syntax query: ($var++ && next) if /match/ <rweikusat@mssgmbh.com>
    Re: syntax query: ($var++ && next) if /match/ <kst-u@mib.org>
    Re: What Programing Language are the Largest Website Wr <mike@mumps.ca>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 21 Jul 2011 07:28:18 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: a little parsing challenge ?
Message-Id: <7gdg279v322t10rmhk1qc533dsratkeghb@4ax.com>

rabbits77 <rabbits77@my-deja.com> wrote:
>> how would you then ejimicate all the groups to ignore the troll? the
>> troll has been doing this for years and many ignore/killfile him. yet he
>> always lands a few fish who xpost replies. he thrives on this.
>Just what makes him a troll? I mean besides your opinion?
>It seems he has engaged a large group of people in a profitable
>discussion. It isn't like he is inciting a flame war. In fact, you seem
>to be the only person offended by this activity.

No, he isn't. However the vast majority of readers have learned long ago
that it is best to just ignore any thread started by that Xaa Lee idiot.
Unfortunately each time there are always enough newbies around to keep
the threads which he initiates in a random selection of NGs going for
days and weeks  .

Just check DejaNews/Google.

jue


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

Date: Thu, 21 Jul 2011 07:29:34 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: a little parsing challenge ???
Message-Id: <enplf8xver.ln2@goaway.wombat.san-francisco.ca.us>

On 2011-07-21, rabbits77 <rabbits77@my-deja.com> wrote:
> Just what makes him a troll? I mean besides your opinion?

Xah Lee is most certainly a troll.

> In fact, you seem to be the only person offended by this activity.

Like many of us Uri probably has Xah Lee killfiled; it is the subsequent
followups that Uri is complaining about.

--keith


-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



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

Date: Wed, 20 Jul 2011 12:26:20 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: global variable scope in perl
Message-Id: <4e26ad4c$0$23983$e4fe514c@news2.news.xs4all.nl>

On 2011-07-20 11:21, Eswar wrote:

> I need to move couple of functions from one perl file to another. In
> this course the global variables that are used in the functions also
> moved. I declared the global variables as 'our'. I am updating the
> global variable in (1st)one function and using the same in
> (Second)another function. when I print the variable in the secong
> function, its printing null. But before the moment of the functions,
> its printing the updated value int he 1st functions. I dont know why
> its not printing after the movement. My friend suggested me to use
> declare the variable as $::, then it looks fine. I wanted to know the
> difference between our and $:: and why this dint work with our. If
> anybody helps, I am very thankful.


See perldoc -f our.

Summary: "our" associates a simple name with a package variable in the 
current package, for use within the current scope.

-- 
Ruud


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

Date: Wed, 20 Jul 2011 13:08:53 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: global variable scope in perl
Message-Id: <87wrfdqhm2.fsf@sapphire.mobileactivedefense.com>

Eswar <eswar.kodati@gmail.com> writes:
> I need to move couple of functions from one perl file to another. In
> this course the global variables that are used in the functions also
> moved. I declared the global variables as 'our'. I am updating the
> global variable in (1st)one function and using the same in
> (Second)another function. when I print the variable in the secong
> function, its printing null. But before the moment of the functions,
> its printing the updated value int he 1st functions. I dont know why
> its not printing after the movement. My friend suggested me to use
> declare the variable as $::, then it looks fine. I wanted to know the
> difference between our and $:: and why this dint work with our.

The difference between our and $:: is that the former declares a
variable in the current package while the latter accesses a variable
in package main with a 'fully qualified path', cf

----------
our $a = 17;

package b;

our $a = 53;

print($a, "\t", $::a, "\n");
----------

As to "why doesn't work after the move" that's for some reason which
is not obvious from the information you provided.





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

Date: Wed, 20 Jul 2011 15:33:31 +0100
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: global variable scope in perl
Message-Id: <4e26e73e$0$2540$da0feed9@news.zen.co.uk>

On 20/07/2011 10:21, Eswar wrote:
> I need to move couple of functions from one perl file to another. In
> this course the global variables that are used in the functions also
> moved. I declared the global variables as 'our'. I am updating the
> global variable in (1st)one function and using the same in
> (Second)another function.

Whenever I find myself using a global variable I get an unpleasant 
feeling and spend some time trying to think of a way of refactoring code 
so I don't have to use global variables. Sometimes it is the expedient 
thing to do but I usually prefer to switch to an OO approach and 
instantiate an object to hold the variable and attach the 
subroutines/functions as methods of that object class.

> when I print the variable in the secong
> function, its printing null. But before the moment of the functions,
> its printing the updated value int he 1st functions. I dont know why
> its not printing after the movement. My friend suggested me to use
> declare the variable as $::, then it looks fine. I wanted to know the
> difference between our and $:: and why this dint work with our. If
> anybody helps, I am very thankful.

Here's a procedural way of sharing a "global" variable between two 
functions. Of course, the variable is also visible to other unrelated 
functions in the same file - and therefore vulnerable to unintended 
alteration.

-----------------8<------------------ file x.pl
#!/usr/bin/perl
use strict;
use warnings;
use x;

set_foo(3);
print "foo is ", get_foo();

-----------------8<------------------ file x.pm
package x;
use Exporter;
@ISA = 'Exporter';
@EXPORT = qw(set_foo get_foo);

sub set_foo {
   our $foo = shift;
}

sub get_foo {
   return $foo;
}

1;
-----------------8<------------------

$ perl x.pl
foo is 3


You might want a `BEGIN { our $foo = -1; }` before the first sub in case 
someone calls get_foo() without previously calling set_foo(). Probably 
lots of other issues lurking. I'd use OO. Your Mileage May Vary. 
Batteries not included.


-- 
RGB


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

Date: Wed, 20 Jul 2011 22:09:11 -0700 (PDT)
From: Eswar <eswar.kodati@gmail.com>
Subject: Re: global variable scope in perl
Message-Id: <6bb14e79-18b8-42de-aec8-184ff373b4cb@j14g2000prn.googlegroups.com>

On Jul 20, 5:08=A0pm, Rainer Weikusat <rweiku...@mssgmbh.com> wrote:
> Eswar <eswar.kod...@gmail.com> writes:
> > I need to move couple of functions from one perl file to another. In
> > this course the global variables that are used in the functions also
> > moved. I declared the global variables as 'our'. I am updating the
> > global variable in (1st)one function and using the same in
> > (Second)another function. when I print the variable in the secong
> > function, its printing null. But before the moment of the functions,
> > its printing the updated value int he 1st functions. I dont know why
> > its not printing after the movement. My friend suggested me to use
> > declare the variable as $::, then it looks fine. I wanted to know the
> > difference between our and $:: and why this dint work with our.
>
> The difference between our and $:: is that the former declares a
> variable in the current package while the latter accesses a variable
> in package main with a 'fully qualified path', cf
>
> ----------
> our $a =3D 17;
>
> package b;
>
> our $a =3D 53;
>
> print($a, "\t", $::a, "\n");
> ----------
>
> As to "why doesn't work after the move" that's for some reason which
> is not obvious from the information you provided.

Hi All,

Thank you very much for your help. I got the problem. I declared the
varibles as our and assigned to null at the top of the file. like

package A;
our $x =3D "";

The assignment ot null created the problem. because after I updated
the value in the Ist function and before accessing the variable in the
second function, there are many calls to the other fucntions with in
the package from different files. When others called some function in
the same package the variable are reinitialized to null again. I dint
observe this problem before the movement as there is no other
functions in previous package, so no calls. now I just declared the
variable as 'our $x;', solved my problem. I could have posted the code
in my query for better understanding of the problem.

Once again thankyou for ur help.


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

Date: Thu, 21 Jul 2011 11:16:06 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: global variable scope in perl
Message-Id: <4e27ee56$0$23855$e4fe514c@news2.news.xs4all.nl>

On 2011-07-20 14:08, Rainer Weikusat wrote:

> The difference between our and $:: is that the former declares a
> variable in the current package while the latter accesses a variable
> in package main with a 'fully qualified path',

There is a high chance of failure when trying to reword documentation. 
Why do you call it "the difference" where it is more probably "a 
difference"?


> ----------
> our $a = 17;
>
> package b;
>
> our $a = 53;
>
> print($a, "\t", $::a, "\n");
> ----------
>
> As to "why doesn't work after the move" that's for some reason which
> is not obvious from the information you provided.

For example realize that your second 'our $a' is in the same lexical scope.

perl -wle '
   our $a = 1;

   package b;

   print "start b:", $a;
   $a -= 5;

   our $a = 12;
   print "in b:", $a;

   local $, = "\t";
   print $a, $::a, $b::a, $main::a;
'
start b:1
in b:12
12	-4	12	-4

-- 
Ruud


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

Date: Thu, 21 Jul 2011 13:03:32 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: global variable scope in perl
Message-Id: <87fwlz7sdn.fsf@sapphire.mobileactivedefense.com>

"Dr.Ruud" <rvtol+usenet@xs4all.nl> writes:
> On 2011-07-20 14:08, Rainer Weikusat wrote:
>
>> The difference between our and $:: is that the former declares a
>> variable in the current package while the latter accesses a variable
>> in package main with a 'fully qualified path',
>
> There is a high chance of failure when trying to reword
> documentation. Why do you call it "the difference" where it is more
> probably "a difference"?

Because that's what the OP was asking for. I could also have replied
with "the spelling is obviously different, don't you think so?" or
"each character sequence occured in a different place of you text" or
with whatever other nonsense.

>> ----------
>> our $a = 17;
>>
>> package b;
>>
>> our $a = 53;
>>
>> print($a, "\t", $::a, "\n");
>> ----------
>>
>> As to "why doesn't work after the move" that's for some reason which
>> is not obvious from the information you provided.
>
> For example realize that your second 'our $a' is in the same lexical
> scope.

I'm, 'for example', completely aware of that. I also have a brother
who has a boy child named Moritz and I know a lot more absolutely
irrelevant information you'd hopefully not expect me to repeat here
each time.


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

Date: Thu, 21 Jul 2011 14:43:00 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: global variable scope in perl
Message-Id: <4e281ed4$0$23887$e4fe514c@news2.news.xs4all.nl>

On 2011-07-21 14:02, Rainer Weikusat wrote:

> I also have a brother
> who has a boy child named Mortiz and I know a lot more absolutely
> irrelevant information

*plonk*

-- 
Ruud


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

Date: Thu, 21 Jul 2011 14:03:38 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: global variable scope in perl
Message-Id: <87bown7plh.fsf@sapphire.mobileactivedefense.com>

"Dr.Ruud" <rvtol+usenet@xs4all.nl> writes:
> On 2011-07-21 14:02, Rainer Weikusat wrote:
>
>> I also have a brother
>> who has a boy child named Mortiz and I know a lot more absolutely
>> irrelevant information
>
> *plonk*

,----
| >> ----------
| >> our $a = 17;
| >>
| >> package b;
| >>
| >> our $a = 53;
| >>
| >> print($a, "\t", $::a, "\n");
| >> ----------
| >>
| >> As to "why doesn't work after the move" that's for some reason which
| >> is not obvious from the information you provided.
| >
| > For example realize that your second 'our $a' is in the same lexical
| > scope.
| 
| I'm, 'for example', completely aware of that. I also have a brother
| who has a boy child named Moritz and I know a lot more absolutely
| irrelevant information you'd hopefully not expect me to repeat here
| each time.
`----

I think this should not only include the reaction ('*plonk*') but also
what caused it (stating that a particular assertion made by the 'Dr
Ruud' person was wrong and complaining about the fact that this
unwarranted assertion was made in the first place).


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

Date: Wed, 20 Jul 2011 05:03:24 -0700 (PDT)
From: Joe Young <j.joeyoung@gmail.com>
Subject: I can't install cpan DBD::mysql
Message-Id: <3a04347e-4b6e-4c6f-a528-0d3e3a2bbc4f@g2g2000vbl.googlegroups.com>

Problem:: I can't install cpan DBD::mysql (have tried several c
compilers, inc Oracle Sol Studio)
and am on my second version of perl
==========================================

Solaris 10x86
gcc version 3.4.6
perl 5, version 14, subversion 1 (v5.14.1)

make
cc -c -I/usr/local/lib/perl5/site_perl/5.14.1/i86pc-solaris/auto/DBI -
I/usr/sfw/include/mysql -DDBD_MYSQL_INSERT_ID_IS_GOOD -g -fno-strict-
aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -
D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O -DVERSION=\"4.019\" -
DXS_VERSION=\"4.019\" -fPIC "-I/usr/local/lib/perl5/5.14.1/i86pc-
solaris/CORE" dbdimp.c
dbdimp.c:3481: error: syntax error before "if"
dbdimp.c:3495: error: syntax error before '->' token
dbdimp.c:3510: error: syntax error before '(' token
dbdimp.c:3510: error: conflicting types for 'PerlIO_printf'
dbdimp.c:3510: note: a parameter list with an ellipsis can't match an
empty parameter name list declaration
/usr/local/lib/perl5/5.14.1/i86pc-solaris/CORE/perlio.h:287: error:
previous declaration of 'PerlIO_printf' was here
dbdimp.c:3510: error: conflicting types for 'PerlIO_printf'
dbdimp.c:3510: note: a parameter list with an ellipsis can't match an
empty parameter name list declaration
/usr/local/lib/perl5/5.14.1/i86pc-solaris/CORE/perlio.h:287: error:
previous declaration of 'PerlIO_printf' was here
make: *** [dbdimp.o] Error 1



PS: cc is a symlink to /usr/local/bin/gcc


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

Date: Wed, 20 Jul 2011 17:25:42 -0700 (PDT)
From: gavino <gavcomedy@gmail.com>
Subject: Re: I can't install cpan DBD::mysql
Message-Id: <1c2b51d0-5407-4b0f-8af5-6e42b9b023eb@glegroupsg2000goo.googlegroups.com>

cpanp

cpanp> o

 ..
 ..
23 blah

cpanp>i 1..23 [enter]
3) install all deps

wait...


cpanp> i DBD::MySQL
wait
3)install deps
wait

done

as root of course


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

Date: Wed, 20 Jul 2011 20:48:18 -0700 (PDT)
From: gavino <gavcomedy@gmail.com>
Subject: Re: I can't install cpan DBD::mysql
Message-Id: <4c7f6e1c-31b0-4829-869f-1cb40571827b@glegroupsg2000goo.googlegroups.com>

ah yes, must install mysql FIRST


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

Date: Wed, 20 Jul 2011 12:02:06 +0100
From: kiloran <kiloran.public+news@gmail.com>
Subject: Perl - Windows - MP3 player
Message-Id: <ov2dnW7owf0hKLvTnZ2dnUVZ7qCdnZ2d@bt.com>

Not sure if this is a Windows or perl question....

I have an MP3 player which connects to my Windows PC via USB. When 
connected, it's visible in Windows Explorer just like a mapped drive. I 
can create folders, copy/paste files, etc.

I want to read this with Activestate perl. If it was truly a mapped 
drive, I could read this with perl (along the lines of: open INFILE, 
"H:\\foldername\filename")

However, it is not a mapped drive. No drive letter is assigned to it. 
Any suggestions how I can access this with perl? I'm struggling to even 
know what I need to Google to get a pointer in the right direction.

--kiloran


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

Date: Wed, 20 Jul 2011 11:54:09 +0000 (UTC)
From: Willem <willem@toad.stack.nl>
Subject: Re: Perl - Windows - MP3 player
Message-Id: <slrnj2dgf1.2pia.willem@toad.stack.nl>

kiloran wrote:
) Not sure if this is a Windows or perl question....

It's a Windows question.

) I have an MP3 player which connects to my Windows PC via USB. When 
) connected, it's visible in Windows Explorer just like a mapped drive. I 
) can create folders, copy/paste files, etc.
)
) I want to read this with Activestate perl. If it was truly a mapped 
) drive, I could read this with perl (along the lines of: open INFILE, 
) "H:\\foldername\filename")
)
) However, it is not a mapped drive. No drive letter is assigned to it. 
) Any suggestions how I can access this with perl? I'm struggling to even 
) know what I need to Google to get a pointer in the right direction.

Try to find out what the exact path is under which the drive is mapped.
I think you can do that by drag-dropping a file onto a CMD window (dosbox).
But for more informed answers, try a windows group.


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT


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

Date: Wed, 20 Jul 2011 18:04:54 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Perl - Windows - MP3 player
Message-Id: <slrnj2enat.65s.tadmc@tadbox.sbcglobal.net>

kiloran <kiloran.public+news@gmail.com> wrote:
> open INFILE, 
> "H:\\foldername\filename")
                 ^^
                 ^^
Did you really intend to insert a form-feed character there?

You do NOT need to use backslashes, so use sane slashes and
you won't be making similar mistakes all the time.

    open INFILE, "H:/foldername/filename"

or, even better:

    open INFILE, 'H:/foldername/filename'


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Thu, 21 Jul 2011 16:11:36 +0100
From: Justin C <justin.1104@purestblue.com>
Subject: syntax query: ($var++ && next) if /match/
Message-Id: <86slf8-rgv.ln1@zem.masonsmusic.co.uk>


I have:

#!/usr/bin/perl

use strict;
use warnings;

my $seen = 0;
my @arr = qw/john paul george ringo/;

for (@arr) {
	($seen = 1 && next) if /^paul/;
	next unless $seen;
	print $_, "\n";
}

__END__

which prints no output. But if I change the `&&` to a comma it does as
expected.... ($seen = 1, next) if ...

I've just read perldoc perlop for Comma Operator, and for &&, but I
don't understand why one works and the other doesn't. Can anyone explain
this in simple terms?

   Justin.

-- 
Justin C, by the sea.


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

Date: Thu, 21 Jul 2011 17:25:08 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: syntax query: ($var++ && next) if /match/
Message-Id: <87pql361p7.fsf@sapphire.mobileactivedefense.com>

Justin C <justin.1104@purestblue.com> writes:
> I have:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my $seen = 0;
> my @arr = qw/john paul george ringo/;
>
> for (@arr) {
> 	($seen = 1 && next) if /^paul/;
> 	next unless $seen;
> 	print $_, "\n";
> }
>
> __END__
>
> which prints no output. But if I change the `&&` to a comma it does as
> expected.... ($seen = 1, next) if ...
>
> I've just read perldoc perlop for Comma Operator, and for &&, but I
> don't understand why one works and the other doesn't.

The precedence of && is higher than that of =, meaning,

$seen = 1 && next is equivalent to $seen = (1 && next) or (as
B::Deparse would tell you) $seen = next. And next doesn't return a
value, hence, $seen is never set. The obvious way to fix this:

--------------
#!/usr/bin/perl

use strict;
use warnings;

my $seen = 0;
my @arr = qw/john paul george ringo/;

for (@arr) {
	(($seen = 1) &&  next) if /^paul/;
	next unless $seen;
	print $_, "\n";
}
--------------

leads to a particularly useless warning:

[rw@sapphire]/tmp $perl a.pl 
Found = in conditional, should be == at a.pl line 10.
george
ringo

It certainly shouldn't be == but I assume that exploiting the
short-circuiting-ness of && and || for control flow control has
meanwhile also been declared as 'simply not kosher !!1' by the
'rotting Perl'[*] thought police ..

A half-way German word play: 'modern' is 'modern' in German and adding
appending a d to that yields modernd <=> rotting.


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

Date: Thu, 21 Jul 2011 16:31:05 +0000 (UTC)
From: Willem <willem@toad.stack.nl>
Subject: Re: syntax query: ($var++ && next) if /match/
Message-Id: <slrnj2gl29.cqs.willem@toad.stack.nl>

Rainer Weikusat wrote:
) The precedence of && is higher than that of =, meaning,
)
) $seen = 1 && next is equivalent to $seen = (1 && next) or (as
) B::Deparse would tell you) $seen = next. And next doesn't return a
) value, hence, $seen is never set. The obvious way to fix this:

 ...
) for (@arr) {
) 	(($seen = 1) &&  next) if /^paul/;

Or you use 'and':

 for (@arr) {
      ($seen = 1 and next) if /^paul/;

) 	next unless $seen;
) 	print $_, "\n";
) }


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT


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

Date: Thu, 21 Jul 2011 18:15:41 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: syntax query: ($var++ && next) if /match/
Message-Id: <87livr5zcy.fsf@sapphire.mobileactivedefense.com>

Willem <willem@toad.stack.nl> writes:
> Rainer Weikusat wrote:
> ) The precedence of && is higher than that of =, meaning,
> )
> ) $seen = 1 && next is equivalent to $seen = (1 && next) or (as
> ) B::Deparse would tell you) $seen = next. And next doesn't return a
> ) value, hence, $seen is never set. The obvious way to fix this:
>
>  ...
> ) for (@arr) {
> ) 	(($seen = 1) &&  next) if /^paul/;
>
> Or you use 'and':
>
>  for (@arr) {
>       ($seen = 1 and next) if /^paul/;

Arguably a better idea. But the parenthesises can be dropped as well,
making this

	$seen = 1 and next if /^paul/;

which I consider to be preferable.


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

Date: Thu, 21 Jul 2011 10:50:29 -0700
From: Keith Thompson <kst-u@mib.org>
Subject: Re: syntax query: ($var++ && next) if /match/
Message-Id: <lny5zrjzfe.fsf@nuthaus.mib.org>

Rainer Weikusat <rweikusat@mssgmbh.com> writes:
> Willem <willem@toad.stack.nl> writes:
>> Rainer Weikusat wrote:
>> ) The precedence of && is higher than that of =, meaning,
>> )
>> ) $seen = 1 && next is equivalent to $seen = (1 && next) or (as
>> ) B::Deparse would tell you) $seen = next. And next doesn't return a
>> ) value, hence, $seen is never set. The obvious way to fix this:
>>
>>  ...
>> ) for (@arr) {
>> ) 	(($seen = 1) &&  next) if /^paul/;
>>
>> Or you use 'and':
>>
>>  for (@arr) {
>>       ($seen = 1 and next) if /^paul/;
>
> Arguably a better idea. But the parenthesises can be dropped as well,
> making this
>
> 	$seen = 1 and next if /^paul/;
>
> which I consider to be preferable.

Some might consider

    if (/^paul/) {
        $seen = 1;
        next;
    }

to be preferable.  You can put it on one line:

    if (/^paul/) { $seen = 1; next; }

if you're afraid of wearning out your enter key.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"


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

Date: Wed, 20 Jul 2011 18:03:07 -0700 (PDT)
From: igotmumps <mike@mumps.ca>
Subject: Re: What Programing Language are the Largest Website Written In?
Message-Id: <45bb22bb-64f5-46e2-8466-fd9b9f7e4b39@cq10g2000vbb.googlegroups.com>

On Jul 13, 1:04 pm, ccc31807 <carte...@gmail.com> wrote:
> On Jul 12, 7:54 am, Xah Lee <xah...@gmail.com> wrote:
>
> > maybe this will be of interest.
>
> > =A1=B4What Programing Language Are the Largest Website Written In?=A1=
=B5http://xahlee.org/comp/website_lang_popularity.html
>
> About five years ago, I did some pretty extensive research, and
> concluded that the biggest sites were written serverside with JSP.
> Obviously, this wouldn't include The Biggest site, but if you were a
> big, multinational corporation, or listed on the NYSE, you used JSP
> for your web programming.
>
> I doubt very seriously PHP is used for the biggest sites -- I'd still
> guess JSP, or maybe a MS technology (not VB), but it's only a guess.
>
> CC.

I believe Facebook uses a PHP/C compiler.  i.e. the site is written in
PHP, but compiled down to C/C++...

MZ



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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 3449
***************************************


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