[30807] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2052 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 12 18:09:46 2008

Date: Fri, 12 Dec 2008 15:09:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 12 Dec 2008     Volume: 11 Number: 2052

Today's topics:
    Re: Mathematica 7 compares to other languages <gneuner2@comcast.net>
    Re: Mathematica 7 compares to other languages <gneuner2@comcast.net>
    Re: Mathematica 7 compares to other languages <gneuner2@comcast.net>
    Re: Mathematica 7 compares to other languages <bakul+usenet@bitblocks.com>
    Re: querying Active Directory via LDAP in perl joseph85750@yahoo.com
    Re: The single biggest STUPIDITY in Perl ... <tim@burlyhost.com>
    Re: The single biggest STUPIDITY in Perl ... <tzz@lifelogs.com>
        Trouble with array syntax <r.ted.byers@gmail.com>
    Re: Trouble with array syntax xhoster@gmail.com
    Re: Trouble with array syntax <smallpond@juno.com>
    Re: Trouble with array syntax <tadmc@seesig.invalid>
        Try to exit inner loop and start next iteration of outt <rodbass63@gmail.com>
    Re: Try to exit inner loop and start next iteration of  xhoster@gmail.com
    Re: Try to exit inner loop and start next iteration of  <glex_no-spam@qwest-spam-no.invalid>
    Re: Try to exit inner loop and start next iteration of  <tadmc@seesig.invalid>
    Re: Try to exit inner loop and start next iteration of  <jurgenex@hotmail.com>
        Using Curl in a package <beauchamp.jim@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 12 Dec 2008 12:15:21 -0500
From: George Neuner <gneuner2@comcast.net>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <d075k4tpj01c71b2j57i5v19kufu0dvefm@4ax.com>

On Wed, 10 Dec 2008 21:37:34 +0000 (UTC), Kaz Kylheku
<kkylheku@gmail.com> wrote:

>Now try writing a device driver for your wireless LAN adapter in Mathematica.

Notice how Xah chose not to respond to this.

George


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

Date: Fri, 12 Dec 2008 12:39:26 -0500
From: George Neuner <gneuner2@comcast.net>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <6375k4pf1mleb6im67nkpec5olqbsom88e@4ax.com>

On Thu, 11 Dec 2008 10:41:59 -0800 (PST), Xah Lee <xahlee@gmail.com>
wrote:

>On Dec 10, 2:47 pm, John W Kennedy <jwke...@attglobal.net> wrote:
>> Xah Lee wrote:
>> > In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java,
>> > you'll have 50 or hundreds lines.
>>
>> C:
>>
>> #include <stdlib.h>
>> #include <math.h>
>>
>> void normal(int dim, float* x, float* a) {
>>     float sum = 0.0f;
>>     int i;
>>     float divisor;
>>     for (i = 0; i < dim; ++i) sum += x[i] * x[i];
>>     divisor = sqrt(sum);
>>     for (i = 0; i < dim; ++i) a[i] = x[i]/divisor;
>>
>> }
>
>i don't have experience coding C. 

Then why do you talk about it as if you know something?

>The code above doesn't seems to satisfy the spec.

It does.

>The input should be just a vector, array, list, or
>whatever the lang supports. The output is the same 
>datatype of the same dimension.

C's native arrays are stored contiguously.  Multidimensional arrays
can be accessed as a vector of length (dim1 * dim2 * ... * dimN).

This code handles arrays of any dimensionality.  The poorly named
argument 'dim' specifies the total number of elements in the array.

George


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

Date: Fri, 12 Dec 2008 14:47:17 -0500
From: George Neuner <gneuner2@comcast.net>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <i5e5k41fhnnleh1nsbbk4210g1vf436e6s@4ax.com>

On Mon, 8 Dec 2008 15:14:18 -0800 (PST), Xah Lee <xahlee@gmail.com>
wrote:

>Dear George Neuner,
>
>Xah Lee wrote:
>> >For example,
>> >the level or power of lang can be roughly order as
>> >this:
>>
>> >assembly langs
>> >C, pascal
>> >C++, java, c#
>> >unix shells
>> >perl, python, ruby, php
>> >lisp
>> >Mathematica
>
>George wrote:
>> According to what "power" estimation?  Assembly, C/C++, C#, Pascal,
>> Java, Python, Ruby and Lisp are all Turing Complete.  I don't know
>> offhand whether Mathematica is also TC, but if it is then it is at
>> most equally powerful.
>
>it's amazing that every tech geekers (aka idiots) want to quote
>“Turing Complete” in every chance. Even a simple cellular automata,
>such as Conway's game of life or rule 110, are complete.
>
>http://en.wikipedia.org/wiki/Conway's_Game_of_Life
>http://en.wikipedia.org/wiki/Rule_110
>
>in fact, according to Stephen Wolfram's controversial thesis by the
>name of “Principle of computational equivalence”, every goddamn thing
>in nature is just about turing complete. (just imagine, when you take
>a piss, the stream of yellow fluid is actually doing turning complete
>computations!)

Wolfram's thesis does not make the case that everything is somehow
doing computation.  

>for a change, it'd be far more interesting and effective knowledge
>showoff to cite langs that are not so-called fuck of the turing
>complete.

We geek idiots cite Turing because it is an important measure of a
language.  There are plenty of languages which are not complete.  That
you completely disregard a fundamental truth of computing is
disturbing.

>the rest of you message went on stupidly on the turing complete point
>of view on language's power, mixed with lisp fanaticism, and personal
>gribes about merits and applicability assembly vs higher level langs.

You don't seem to understand the difference between leverage and power
and that disturbs all the geeks here who do.  We worry that newbies
might actually listen to your ridiculous ramblings and be led away
from the truth.

>It's fine to go on with your gribes, but be careful in using me as a
>stepping stone.

Xah, if I wanted to step on you I would do it with combat boots.  You
should be thankful that you live 3000 miles away and I don't care
enough about your petty name calling to come looking for you.  If you
insult people in person like you do on usenet then I'm amazed that
you've lived this long.

George


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

Date: Fri, 12 Dec 2008 13:19:29 -0800
From: Bakul Shah <bakul+usenet@bitblocks.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <4942D561.5020203@bitblocks.com>

George Neuner wrote:
> On Thu, 11 Dec 2008 10:41:59 -0800 (PST), Xah Lee <xahlee@gmail.com>
> wrote:
> 
>> On Dec 10, 2:47 pm, John W Kennedy <jwke...@attglobal.net> wrote:
>>> Xah Lee wrote:
>>>> In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java,
>>>> you'll have 50 or hundreds lines.
>>> C:
>>>
>>> #include <stdlib.h>
>>> #include <math.h>
>>>
>>> void normal(int dim, float* x, float* a) {
>>>     float sum = 0.0f;
>>>     int i;
>>>     float divisor;
>>>     for (i = 0; i < dim; ++i) sum += x[i] * x[i];
>>>     divisor = sqrt(sum);
>>>     for (i = 0; i < dim; ++i) a[i] = x[i]/divisor;
>>>
>>> }
>> i don't have experience coding C. 
> 
> Then why do you talk about it as if you know something?
> 
>> The code above doesn't seems to satisfy the spec.
> 
> It does.
> 
>> The input should be just a vector, array, list, or
>> whatever the lang supports. The output is the same 
>> datatype of the same dimension.
> 
> C's native arrays are stored contiguously.  Multidimensional arrays
> can be accessed as a vector of length (dim1 * dim2 * ... * dimN).
> 
> This code handles arrays of any dimensionality.  The poorly named
> argument 'dim' specifies the total number of elements in the array.
> 
> George

Only if the length in each dimension is known at compile time (or
in C99, if this is an automatic array). When this is not the case,
you may have to implement something like the following (not the only
way, just one way):

float** new_matrix(int rows, int cols) {
	float** m = malloc(sizeof(float*)*rows);
	int i;
	for (i = 0; i < rows; i++)
		m[i] = malloc(sizeof(float)*cols);
	return m;
}

In this case normal() fails since matrix m is not in a single
contiguous area.

But I suspect Xah is complaining because the function doesn't
*return* a value of the same type; instead you have to pass in
the result vector. But such is life if you code in C!


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

Date: Fri, 12 Dec 2008 08:26:06 -0800 (PST)
From: joseph85750@yahoo.com
Subject: Re: querying Active Directory via LDAP in perl
Message-Id: <e34ecf39-ee6c-42de-8056-d462661916f6@i24g2000prf.googlegroups.com>

On Dec 11, 7:11=A0pm, "Thrill5" <nos...@somewhere.com> wrote:
> <joseph85...@yahoo.com> wrote in message
>
> news:03a34234-c330-464e-9a0c-6bd65c28b96b@k36g2000pri.googlegroups.com...
>
>
>
> > I've been poking at this on and off over the past few months, never
> > having much success. =A0I was never sure what sort of crazy query strin=
g
> > the AD server wanted. =A0 But then it occurred to me that my Linux
> > Evolution email client does this without any problems-- only using the
> > IP address of the Active Directory LDAP server. =A0I can query/search,
> > and it immediately returns all matches.
>
> > How can it do this without the big ugly
> > "cn=3Dusers,dc=3Dfoo,dc=3Dblah,o=3Dacme......" string ?
>
> > Since this is obviously possible and simple (except for me), how could
> > I do this same simple query in perl-- only armed with the IP address
> > of my AD/LDAP server?
>
> > Curiously,
> > JS
>
> Google "LDAP query syntax", =A0and you will find a whole bunch of informa=
tion
> about querying AD via LDAP.

Yes, google returns many articles mentioning query strings, such as:

search DN: ou=3Dgroups,ou=3D@company,dc=3Dcorp,dc=3Dtrx,dc=3Dcom

But back to my original question-- Evolution doesn't seem to need any
of this.  In Evolution, you simply give it the IP address of your AD/
LDAP server and it all magically works.  Evolution is running on a
linux box, which has no knowledge of the query string variables.

I even tried running a tcpdump on the connection to figure out what it
was doing but couldn't figure it out.


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

Date: Fri, 12 Dec 2008 10:22:53 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: The single biggest STUPIDITY in Perl ...
Message-Id: <2_x0l.4101$%z5.2403@newsfe09.iad>

cartercc wrote:

> I've used both embedded technologies (PHP, JSP, ASP, etc) and
> technologies that emit HTML (like traditional CGI). I strongly prefer
> the latter. If you embed logic in HTML, you are mixing data, logic,
> and document markup.

I don't overall mind the mixing of the HTML and logic, but I too prefer
the latter.  I think too many people just don't understand the ease of
using Perl and CGI for serving content.  Too many people are convinced
that Perl IS CGI and that CGI is "deathly slow".  The differences are
negligible and I trust Perl over PHP any day regarding bug and security
ramifications.  Not that I dislike PHP, I just know better.

I suppose if you get someone new and they don't want to be bothered by
specifying the content type/header and take 5 minutes to understand
permissions, that they might prefer PHP.  I really don't mind either
way, but all of my code for the last 10 years has started in Perl
unless I'm told or asked to code in another language.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


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

Date: Fri, 12 Dec 2008 16:15:33 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: The single biggest STUPIDITY in Perl ...
Message-Id: <86skotoxa2.fsf@lifelogs.com>

On Fri, 12 Dec 2008 07:57:49 -0800 (PST) cartercc <cartercc@gmail.com> wrote: 

c> As a general rule, I believe that The Best methodology for building
c> large web apps is to build a wall of separation between the data,
c> logic, and interface, using your logic components to control both the
c> data (and access to data) and the interface. Mixing interface with
c> logic isn't a good idea, IMO.

This is a great rule as long as you accept that you have to break it
occasionally.

Ted


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

Date: Fri, 12 Dec 2008 10:08:09 -0800 (PST)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Trouble with array syntax
Message-Id: <6794f583-a897-40bd-b230-d4602aabdb9e@e3g2000vbe.googlegroups.com>

I am setting up a new table for use in a PDF

The existing tables work fine, but their structure is static.  I can
therefore use something like:
@row = ["Transaction type","Response text","Transaction Count"];
push @table2,@row;
@row = [$tt,$rt,$tc];
push @table2,@row;

When I pass @table2 to the PDF routine for maing tables, this works
flawlessly.

Now, however, I need to make a new table where the column names and
numbers are not know until run time.  I tried the following, but all
that got displayed in the table were reference values:

$tmp= "Merchant";
push @row,$tmp;
foreach $action_type (sort @master_transaction_types) {
  $tmp= "Percent $action_type transactions declined";
  push @row,$tmp;
}
print "@row\n";
push @table4,\@row;
foreach $merchant (sort keys %declined_transaction_ratio) {
  undef @row;
  push @row,$merchant;
  foreach $action_type (sort @master_transaction_types) {
    push @row,$declined_transaction_ratio{$merchant}{$action_type};
  }
  print "@row\n";
  push @table4,\@row;
}

NB: When I tried the above using "push @table4,@row;" instead of "push
@table4,\@row;", I got an error message complaining that "Merchant"
isn't a reference.

So, then, how do I create a table, like @table2 above, when the column
numbers and names are not known until run time?

I must have missed something simple, but what?

Thanks

Ted


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

Date: 12 Dec 2008 20:19:43 GMT
From: xhoster@gmail.com
Subject: Re: Trouble with array syntax
Message-Id: <20081212151832.628$nN@newsreader.com>

Ted Byers <r.ted.byers@gmail.com> wrote:
> I am setting up a new table for use in a PDF
>
> The existing tables work fine, but their structure is static.  I can
> therefore use something like:
> @row = ["Transaction type","Response text","Transaction Count"];
> push @table2,@row;
> @row = [$tt,$rt,$tc];
> push @table2,@row;

You are only using the first slot of @row, $row[0].  So you might as well
use a scalar rather than an array if you are only going to use one of its
slots.

Also, you should use lexical variables, and "use strict".


> When I pass @table2 to the PDF routine for maing tables, this works
> flawlessly.
>
> Now, however, I need to make a new table where the column names and
> numbers are not know until run time.  I tried the following, but all
> that got displayed in the table were reference values:
>
> $tmp= "Merchant";
> push @row,$tmp;

Again, you should lexical variables and use strict.  Where did @row come
from?  What kind of variable is it?

> foreach $action_type (sort @master_transaction_types) {
>   $tmp= "Percent $action_type transactions declined";
>   push @row,$tmp;
> }
> print "@row\n";
> push @table4,\@row;

I'll assume @table4 started out as empty until it got to this point.


> foreach $merchant (sort keys %declined_transaction_ratio) {
>   undef @row;

You just undefined the thing that $table4[0] is referring to.

One way around this is to create a new variable @row, that just happens
to share a source-code name, but nothing else, with the old variable @row.
You do that like:

    my @row; # starts empty, no need to undef it.

(For that matter, you could give it a new name.  I think it'd keep this one
named @row and change the first occurrence to @header, to better reflect
their natures.  But inside the loop, you would still have to use my,
otherwise you have just moved the problem down one level.  Your header
would be different from your rows, but all your rows would just be pointing
to the same thing.

>   push @row,$merchant;
>   foreach $action_type (sort @master_transaction_types) {
>     push @row,$declined_transaction_ratio{$merchant}{$action_type};
>   }
>   print "@row\n";
>   push @table4,\@row;

In the absence of the change I proposed, @table4 now holds two references
to the *same* array.

> }
>
> NB: When I tried the above using "push @table4,@row;" instead of "push
> @table4,\@row;", I got an error message complaining that "Merchant"
> isn't a reference.

Presumably you got that error at some later step than what you have shown
us. The push itself would not generate such an error.

>
> So, then, how do I create a table, like @table2 above, when the column
> numbers and names are not known until run time?

If you make your programs "use strict" compliant, it will hope (but not
perfectly) figure this stuff out.

>
> I must have missed something simple, but what?

The nature of references, the differences between shallow copies and
deep copies.

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: Fri, 12 Dec 2008 12:52:34 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: Trouble with array syntax
Message-Id: <76458f9f-4fc7-48ce-9da0-211bc208476c@c36g2000prc.googlegroups.com>

On Dec 12, 1:08 pm, Ted Byers <r.ted.by...@gmail.com> wrote:
> I am setting up a new table for use in a PDF
>
> The existing tables work fine, but their structure is static.  I can
> therefore use something like:
> @row = ["Transaction type","Response text","Transaction Count"];
> push @table2,@row;
> @row = [$tt,$rt,$tc];
> push @table2,@row;


Would this make more sense to you if you wrote it as:

$row = ["Transaction type","Response text","Transaction Count"];
push @table2,$row;
$row = [$tt,$rt,$tc];
push @table2,$row;

$row (or $row[0] as you call it) is a list reference which you
are pushing into @table2.




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

Date: Fri, 12 Dec 2008 16:22:51 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Trouble with array syntax
Message-Id: <slrngk5p1r.251.tadmc@tadmc30.sbcglobal.net>

smallpond <smallpond@juno.com> wrote:
> On Dec 12, 1:08 pm, Ted Byers <r.ted.by...@gmail.com> wrote:
>> I am setting up a new table for use in a PDF
>>
>> The existing tables work fine, but their structure is static.  I can
>> therefore use something like:
>> @row = ["Transaction type","Response text","Transaction Count"];
>> push @table2,@row;
>> @row = [$tt,$rt,$tc];
>> push @table2,@row;
>
>
> Would this make more sense to you if you wrote it as:
>
> $row = ["Transaction type","Response text","Transaction Count"];
> push @table2,$row;
> $row = [$tt,$rt,$tc];
> push @table2,$row;
>
> $row (or $row[0] as you call it) is a list reference which you
> are pushing into @table2.


And, of course, you do not need the intermediate temporary variable either.

You can build the same data structure as above with:

   push @table2, ["Transaction type","Response text","Transaction Count"];
   push @table2, [$tt,$rt,$tc];

or even with just:

   push @table2, ["Transaction type","Response text","Transaction Count"], [$tt,$rt,$tc];


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


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

Date: Fri, 12 Dec 2008 13:22:49 -0800 (PST)
From: Nene <rodbass63@gmail.com>
Subject: Try to exit inner loop and start next iteration of outter loop.
Message-Id: <710929dc-1985-4331-b812-84b192b87ac0@r32g2000vba.googlegroups.com>

Hello,

What I'm trying to do is once my inner loop reaches a count of 5, I
want it to exit the while statement and go back to the foreach loop.
But it hangs after it reaches '5' and takes a long time for it go to
to the second iteration (really large files) of the for foreach loop:

#!/usr/bin/perl -w
use strict;

my @LIST = qw/
server_1
server_2
/;

my $count = 0;

FIRST: foreach my $SERVER (@LIST)  {

my $ssh = "ssh $SERVER";
my $cmd = "perl -ne 'print' /server/directory/file";


open(SSH, "$ssh $cmd |") || die "ssh: $!";

print "\n";
print "Connected to $SERVER\n";


LINE: while (my $current_line = <SSH>) {
if ($current_line =~ /Failed at the server/) {
$count++;
print "$current_line\n";
next FIRST if $count == 5;
}
}
}


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

Date: 12 Dec 2008 22:06:41 GMT
From: xhoster@gmail.com
Subject: Re: Try to exit inner loop and start next iteration of outter loop.
Message-Id: <20081212170530.517$ck@newsreader.com>

Nene <rodbass63@gmail.com> wrote:
> Hello,
>
> What I'm trying to do is once my inner loop reaches a count of 5, I
> want it to exit the while statement and go back to the foreach loop.
> But it hangs after it reaches '5' and takes a long time for it go to
> to the second iteration (really large files) of the for foreach loop:
>
> #!/usr/bin/perl -w
> use strict;
>
> my @LIST = qw/
> server_1
> server_2
> /;
>
> my $count = 0;

Don't you want to reset $count for the next server?

>
> FIRST: foreach my $SERVER (@LIST)  {
>
> my $ssh = "ssh $SERVER";
> my $cmd = "perl -ne 'print' /server/directory/file";
>
> open(SSH, "$ssh $cmd |") || die "ssh: $!";

For Pete's sake indent your code.

What is happening is that when
you re-open SSH, the old handle gets closed.  And when a handle from a
piped open gets closed, it waits for the underlying process to exit.  It
can take a while for your ssh command to decide you stopped listening to it
and exit.

You could catch the pid from your open and then kill the pid just before
you do the "next FIRST".  Or you could make the open do a double-fork by
using the bit of trickery:

open(SSH, "$ssh $cmd & |") || die "ssh: $!";

Or you could by-pass the piped-open "magic" by doing the fork and exec
yourself.

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: Fri, 12 Dec 2008 16:14:03 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Try to exit inner loop and start next iteration of outter loop.
Message-Id: <4942e22c$0$87071$815e3792@news.qwest.net>

xhoster@gmail.com wrote:
> Nene <rodbass63@gmail.com> wrote:
>> Hello,
>>
>> What I'm trying to do is once my inner loop reaches a count of 5, I
>> want it to exit the while statement and go back to the foreach loop.
>> But it hangs after it reaches '5' and takes a long time for it go to
>> to the second iteration (really large files) of the for foreach loop:
>>
>> #!/usr/bin/perl -w
>> use strict;
>>
>> my @LIST = qw/
>> server_1
>> server_2
>> /;
>>
>> my $count = 0;
> 
> Don't you want to reset $count for the next server?
> 
>> FIRST: foreach my $SERVER (@LIST)  {
>>
>> my $ssh = "ssh $SERVER";
>> my $cmd = "perl -ne 'print' /server/directory/file";
>>
>> open(SSH, "$ssh $cmd |") || die "ssh: $!";
> 
> For Pete's sake indent your code.
> 
> What is happening is that when
> you re-open SSH, the old handle gets closed.  And when a handle from a
> piped open gets closed, it waits for the underlying process to exit.  It
> can take a while for your ssh command to decide you stopped listening to it
> and exit.
> 
> You could catch the pid from your open and then kill the pid just before
> you do the "next FIRST".  Or you could make the open do a double-fork by
> using the bit of trickery:
> 
> open(SSH, "$ssh $cmd & |") || die "ssh: $!";
> 
> Or you could by-pass the piped-open "magic" by doing the fork and exec
> yourself.

Or it'd probably be cleaner to simply move the logic of "printing until 
you reach the 5th time /Failed at the server/ happens" to $cmd.

Also, In the original code, there's no difference between using
'next FIRST' and simply 'last'.  Neither label is needed.

perldoc -f last


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

Date: Fri, 12 Dec 2008 16:24:57 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Try to exit inner loop and start next iteration of outter loop.
Message-Id: <slrngk5p5p.251.tadmc@tadmc30.sbcglobal.net>

Nene <rodbass63@gmail.com> wrote:

> #!/usr/bin/perl -w


The modern, and much better, way is to use lexical warnings
instead of the command line switch:

    #!/usr/bin/perl
    use warnings;


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


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

Date: Fri, 12 Dec 2008 14:30:45 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Try to exit inner loop and start next iteration of outter loop.
Message-Id: <bcp5k4hu2st77j50hcvajq73gtiv6602qq@4ax.com>

Nene <rodbass63@gmail.com> wrote:
>Hello,
>
>What I'm trying to do is once my inner loop reaches a count of 5, I
>want it to exit the while statement and go back to the foreach loop.
>But it hangs after it reaches '5' and takes a long time for it go to
>to the second iteration (really large files) of the for foreach loop:
>
>#!/usr/bin/perl -w
>use strict;
>
>my @LIST = qw/
>server_1
>server_2
>/;
>
>my $count = 0;
>
>FIRST: foreach my $SERVER (@LIST)  {
>
>my $ssh = "ssh $SERVER";
>my $cmd = "perl -ne 'print' /server/directory/file";
>
>
>open(SSH, "$ssh $cmd |") || die "ssh: $!";
>
>print "\n";
>print "Connected to $SERVER\n";
>
>
>LINE: while (my $current_line = <SSH>) {

Just change this line to 

	while (my $current_line = <SSH> and $count < 5) {

and you can get rid of those stupid labels.

>if ($current_line =~ /Failed at the server/) {
>$count++;
>print "$current_line\n";
>next FIRST if $count == 5;
>}
>}
>}

jue


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

Date: Fri, 12 Dec 2008 09:01:02 -0800 (PST)
From: Bucker <beauchamp.jim@gmail.com>
Subject: Using Curl in a package
Message-Id: <6e5f0b39-9ef9-4b48-8b58-dc49a9cd257b@s9g2000vbp.googlegroups.com>

Hi Folks,

I developed a simple perl script which sets up a curl call with the
following callback

$curl->setopt(CURLOPT_WRITEFUNCTION,\&ret_data2);

this follows several lines after the all in a seperate sub
sub ret_data2 {

}

The above works fine when its not in a package.

If I put the same code in a package the curl->errbuf returns 0 which
is good
but it never calls the ret_data2 sub.

Inside a package do I need to reference the WRITEFUNCTION sub
differently?

Regards,

J


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

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


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