[22506] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4727 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 18 18:10:39 2003

Date: Tue, 18 Mar 2003 15:10:14 -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           Tue, 18 Mar 2003     Volume: 10 Number: 4727

Today's topics:
    Re: text filter <user@someserver123abc.com>
    Re: text filter <abigail@abigail.nl>
    Re: text filter <uri@stemsystems.com>
    Re: text filter <mgjv@tradingpost.com.au>
    Re: text filter <mgjv@tradingpost.com.au>
    Re: text filter <uri@stemsystems.com>
    Re: text filter <abigail@abigail.nl>
    Re: text filter <abigail@abigail.nl>
        UDP Comms Problem <carriera@nortelnetworks.com>
    Re: UDP Comms Problem <uri@stemsystems.com>
    Re: use of uninitialized value (david)
    Re: What's wrong with the Perl docs <dover@nortelnetworks.com>
    Re: why can't I last? (Nataku)
    Re: why can't I last? <mjcarman@mchsi.com>
    Re: why can't I last? <stevenm@bogus.blackwater-pacific.com>
    Re: why can't I last? <stevenm@bogus.blackwater-pacific.com>
    Re: why can't I last? <bart.lateur@pandora.be>
    Re: Win32 Perl newsgroup? <aknntp@yahoo.com>
    Re: Win32 Perl newsgroup? <aknntp@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 18 Mar 2003 14:07:48 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: Re: text filter
Message-Id: <3E776E84.26068FB2@someserver123abc.com>



Uri Guttman wrote:
> 
> >>>>> "JM" == Josef Möllers <josef.moellers@fujitsu-siemens.com> writes:
> 
 ...........

> 
> \d is a regex thing and doesn't expand in tr. only - does any expansions
> in tr. and you forgot the /cd there as well.
> 
> and tr is generally much faster that s/// when it does the same kind of
> work and deleting chars is one of those places.
> 
 ....

generally?
in what cases would it not be?
is it signifigantly faster if a string is 54321 Duhzillion Bytes?


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


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

Date: 18 Mar 2003 21:25:13 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: text filter
Message-Id: <slrnb7f3lp.u4a.abigail@alexandra.abigail.nl>

stinkbomb (user@someserver123abc.com) wrote on MMMCDLXXXVI September
MCMXCIII in <URL:news:3E776E84.26068FB2@someserver123abc.com>:
;;  
;;  
;;  Uri Guttman wrote:
;; > 
;; > >>>>> "JM" == Josef Möllers <josef.moellers@fujitsu-siemens.com> writes:
;; > 
;;  ...........
;;  
;; > 
;; > \d is a regex thing and doesn't expand in tr. only - does any expansions
;; > in tr. and you forgot the /cd there as well.
;; > 
;; > and tr is generally much faster that s/// when it does the same kind of
;; > work and deleting chars is one of those places.
;; > 
;;  ....
;;  
;;  generally?
;;  in what cases would it not be?


use strict;
use warnings;
use Benchmark;

$a = "a" x 100;

Benchmark::cmpthese timethese -1 => {
    s  =>  '$::a =~ s/ //g;',
    y  =>  '$::a =~ y/ //d;',
}

__END__
Name "main::a" used only once: possible typo at z.pl line 5.
Benchmark: running s, y for at least 1 CPU seconds...
         s:  1 wallclock secs ( 1.04 usr + -0.02 sys =  1.02 CPU) @ 1349270.59/s (n=1376256)
         y:  2 wallclock secs ( 1.18 usr +  0.00 sys =  1.18 CPU) @ 583158.47/s (n=688127)
       Rate    y    s
y  583158/s   -- -57%
s 1349271/s 131%   --



In this case, s/// beats the shit out of y///.



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: Tue, 18 Mar 2003 21:38:33 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: text filter
Message-Id: <x7el54we1z.fsf@mail.sysarch.com>

>>>>> "A" == Abigail  <abigail@abigail.nl> writes:

  A>     s  =>  '$::a =~ s/ //g;',
  A>     y  =>  '$::a =~ y/ //d;',
  A> Name "main::a" used only once: possible typo at z.pl line 5.
  A> Benchmark: running s, y for at least 1 CPU seconds...
  A>          s:  1 wallclock secs ( 1.04 usr + -0.02 sys =  1.02 CPU) @ 1349270.59/s (n=1376256)
  A>          y:  2 wallclock secs ( 1.18 usr +  0.00 sys =  1.18 CPU) @ 583158.47/s (n=688127)
  A>        Rate    y    s
  A> y  583158/s   -- -57%
  A> s 1349271/s 131%   --

  A> In this case, s/// beats the shit out of y///.

i knew enough to say generally since there are always edge cases that
break rules like tr/// is always faster than s///. but this is a total
failure case, can you find one where data changes happen?

uri

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


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

Date: Tue, 18 Mar 2003 22:07:55 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: text filter
Message-Id: <slrnb7f65r.bkm.mgjv@verbruggen.comdyn.com.au>

On Tue, 18 Mar 2003 18:08:11 GMT,
	Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "JM" == Josef Möllers <josef.moellers@fujitsu-siemens.com> writes:
> 
>  JM> Helgi Briem wrote:
>  >> 
>  >> 
>  >> $str =~ s/[^\/,a-z0-9]//g;
> 
>  JM> TMTOWTDI
> 
>  JM> $str =~ tr/\/,a-z0-9//cd;
> 
>  JM> It's even one character shorter B-{)
>  JM> One can even do it with less:
>  JM> $str =~ y|/,a-z\d||;
> 
> \d is a regex thing and doesn't expand in tr. only - does any expansions
> in tr. and you forgot the /cd there as well.
> 
> and tr is generally much faster that s/// when it does the same kind of
> work and deleting chars is one of those places.

Additionally, and since the OP's original question was:

>> I have "3iji3j4ij34+_=,,//[]24" and I only want alpha numeric and
>> commas and slash (a..z 1..9 , /)

If you only look at the last bit, between the brackets, then both
questions above seem to answer the question. If you only look at the
description (alpha numeric and commas and slash) then neither does.
I'm just adding this note for completeness, not to criticise anyone's
reading of the OP.

The character range a-z does not necessarily represent all alphas in
non-English locales (and it misses out on uppercase alphas in all
locales). For the regex this can be easily fixed by using POSIX
character classes:

$str =~ s#[^[:alnum:],/]##g;

but tr/// does not take POSIX character classes, so it cannot be fixed
in general, only for specific known character sets.

Martien
-- 
                        | 
Martien Verbruggen      | 
Trading Post Australia  | Hi, Dave here, what's the root password?
                        | 


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

Date: Tue, 18 Mar 2003 22:29:56 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: text filter
Message-Id: <slrnb7f7f4.bkm.mgjv@verbruggen.comdyn.com.au>

On Tue, 18 Mar 2003 21:38:33 GMT,
	Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "A" == Abigail  <abigail@abigail.nl> writes:
> 
[snip of quoted material, and reinsert of benchmark code]

use Benchmark;

$a = "a" x 100;

Benchmark::cmpthese timethese -1 => {
    s  =>  '$::a =~ s/ //g;',
    y  =>  '$::a =~ y/ //d;',
}

> i knew enough to say generally since there are always edge cases that
> break rules like tr/// is always faster than s///. but this is a total
> failure case, can you find one where data changes happen?

Change $a to

$a = "a " x 100;

and run the above benchmark.


Or the following where each character is changed in-place:

use Benchmark;

$a = "a " x 100;

Benchmark::cmpthese timethese -1 => {
    s  =>  '$::a =~ s/ /T/g;',
    y  =>  '$::a =~ y/ /T/;',
}

Even for the case under discussion, the differences are not too big (a
factor of two). Note that the regular expressions below are not always
exactly equivalent (see my other post in this thread).

use Benchmark;

$a = "aji_+,/f-12 " x 100;

Benchmark::cmpthese timethese -1 => {
    s1 =>  '$::a =~ s#[^[:alnum:],/]##g',
    s2 =>  '$::a =~ s#[^a-zA-Z\d,/]##g',
    y  =>  '$::a =~ y#a-zA-Z0-9,/##dc',
}

__END__
Benchmark: running s1, s2, y, each for at least 1 CPU seconds...
[SNIP]
       Rate   s1   s2    y
s1  61265/s   --  -3% -47%
s2  63015/s   3%   -- -45%
y  114841/s  87%  82%   --


I don't really know whether other locales would influence these
benchmarks.

Martien
-- 
                        | 
Martien Verbruggen      | If at first you don't succeed, destroy all
Trading Post Australia  | evidence that you tried.
                        | 


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

Date: Tue, 18 Mar 2003 22:35:00 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: text filter
Message-Id: <x7of48uwvk.fsf@mail.sysarch.com>

>>>>> "MV" == Martien Verbruggen <mgjv@tradingpost.com.au> writes:

  MV> Even for the case under discussion, the differences are not too big (a
  MV> factor of two). Note that the regular expressions below are not always
  MV> exactly equivalent (see my other post in this thread).

  MV> use Benchmark;

  MV> $a = "aji_+,/f-12 " x 100;

  MV> Benchmark::cmpthese timethese -1 => {
  MV>     s1 =>  '$::a =~ s#[^[:alnum:],/]##g',
  MV>     s2 =>  '$::a =~ s#[^a-zA-Z\d,/]##g',
  MV>     y  =>  '$::a =~ y#a-zA-Z0-9,/##dc',
  MV> }

ummm, don't you need to reset $a to the string each time? otherwise
after the first call the rest are all failure cases and it seems that
s/// is faster than tr for those. what i asked for was a case where data
was changed and s/// is faster. 

uri

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


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

Date: 18 Mar 2003 22:55:44 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: text filter
Message-Id: <slrnb7f8vf.u4a.abigail@alexandra.abigail.nl>

Uri Guttman (uri@stemsystems.com) wrote on MMMCDLXXXVI September MCMXCIII
in <URL:news:x7el54we1z.fsf@mail.sysarch.com>:
}} >>>>> "A" == Abigail  <abigail@abigail.nl> writes:
}}  
}}   A> In this case, s/// beats the shit out of y///.
}}  
}}  i knew enough to say generally since there are always edge cases that
}}  break rules like tr/// is always faster than s///. but this is a total
}}  failure case, can you find one where data changes happen?


I don't think that total failure cases for s/// or y/// should be
considered 'edge cases', they are common enough.

Cases that have matches are much harder to benchmark, as you need to
copy the string in each iteration, making it harder to compare the s///
and y///.

Using strings of the form:

    ('a' x 100) . ' '
    
or
    ('a' x 100) . ' ' . ('a' x 100)
    
shows y/// to be a few % faster than s///.



Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54"; s/<<EOT/<<EOT/e; print;
Just another Perl Hacker
EOT


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

Date: 18 Mar 2003 22:59:30 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: text filter
Message-Id: <slrnb7f96i.u4a.abigail@alexandra.abigail.nl>

Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMMCDLXXXVI
September MCMXCIII in <URL:news:slrnb7f7f4.bkm.mgjv@verbruggen.comdyn.com.au>:
``  
``  
``  Or the following where each character is changed in-place:
``  
``  use Benchmark;
``  
``  $a = "a " x 100;
``  
``  Benchmark::cmpthese timethese -1 => {
``      s  =>  '$::a =~ s/ /T/g;',
``      y  =>  '$::a =~ y/ /T/;',
``  }


Uhm, after the first iteration, the string doesn't contain any spaces
any more. You'd need to copy the string first.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: Mon, 17 Mar 2003 12:00:40 -0600
From: "Al" <carriera@nortelnetworks.com>
Subject: UDP Comms Problem
Message-Id: <b552k6$csm$1@zcars0v6.ca.nortel.com>

I'm waiting on a packet from a device of known IP address. There is no
connect/accept, it just sends me a packet and I want to respond back with a
slightly modified version of the message ot sent me. I'm failing on the send
command...can someone please point out why? Same deal if I use just
send(SocketHandle,$reply); .......

use Socket;
$proto = getprotobyname('udp');
socket(Socket_Handle, PF_INET, SOCK_DGRAM, $proto);
$iaddr = inet_aton(192.168.122.188);    $port = 4399;
$dest = sockaddr_in($port, $iaddr);
bind(Socket_Handle,$dest) || die $!;
$buffer="";
while (1)
  {
    recv(Socket_Handle,$buffer,1000,0) ;
    print("$count  $buffer");
    if($buffer =~ /^N/)
    {
      $buffer =~ s/N...(..)/$1/;
      $reply=$reply.$buffer;
      send(SocketHandle,$reply,0,$dest) || die "Couldn't send";
    }
  }
exit(0);


thanks,
Al




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

Date: Tue, 18 Mar 2003 21:33:10 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: UDP Comms Problem
Message-Id: <x7isugweay.fsf@mail.sysarch.com>

>>>>> "A" == Al  <carriera@nortelnetworks.com> writes:

  A> I'm waiting on a packet from a device of known IP address. There is no
  A> connect/accept, it just sends me a packet and I want to respond back with a
  A> slightly modified version of the message ot sent me. I'm failing on the send
  A> command...can someone please point out why? Same deal if I use just
  A> send(SocketHandle,$reply); .......

  A> use Socket;
  A> $proto = getprotobyname('udp');
  A> socket(Socket_Handle, PF_INET, SOCK_DGRAM, $proto);
            ^^^^^^^^^^^^^
  A> $iaddr = inet_aton(192.168.122.188);    $port = 4399;
  A> $dest = sockaddr_in($port, $iaddr);
  A> bind(Socket_Handle,$dest) || die $!;
          ^^^^^^^^^^^^^

  A> $buffer="";
  A> while (1)
  A>   {
  A>     recv(Socket_Handle,$buffer,1000,0) ;
              ^^^^^^^^^^^^^
  A>     print("$count  $buffer");
  A>     if($buffer =~ /^N/)
  A>     {
  A>       $buffer =~ s/N...(..)/$1/;
  A>       $reply=$reply.$buffer;
  A>       send(SocketHandle,$reply,0,$dest) || die "Couldn't send";
                ^^^^^^^^^^^^
  A>     }
  A>   }
  A> exit(0);

one of those is not like the others.

yoy should be using IO::Socket anyhow and a lexical variable under
strict. then your code would be greatly reduced and that bug won't
happen.

uri

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


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

Date: 18 Mar 2003 13:28:13 -0800
From: dwlepage@yahoo.com (david)
Subject: Re: use of uninitialized value
Message-Id: <b09a22ae.0303181328.5c41d5b8@posting.google.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<b5791k$l2l$1@mamenchi.zrz.TU-Berlin.DE>...
> david <dwlepage@yahoo.com> wrote in comp.lang.perl.misc:
> > anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> > news:<b56nek$6h5$1@mamenchi.zrz.TU-Berlin.DE>...
> > > david <dwlepage@yahoo.com> wrote in comp.lang.perl.misc:
> > > > I am continuously getting a message "Use of uninitialized value in
> > > > pattern match (m//) at test.pl line 15, <FILE> line 2130." This
> > > 
> > > Line s 13-15 are
> > > 
> > >            my @fields = split ( /,/ );
> > >          # Grab token serial number from Comments field if exists
> > >                  if (!($fields[8] =~ m/S\/N:\s(\w+)/ )) {
> > > 
> > > You would have done us all a favor if you had identified the critical
> > > line instead of letting everyone count.
> > > 
> > > Obviously, $fields[8] is undefined because some input lines don't
> > > have enough comma-delimited fields.
> > > 
> > > > happens for every line parsed by my script. I have tried this on
> > > > several deffernt data files and the strange this is that it doesn't
> > > > happen when I parse against all of them, only some.
> > > 
> > > Some have eight or more fields per line, others don't.
> > > 
> > > >                                                      I have looked at
> > > > older postings and searched around and it appears it must have
> > > 
> > > You should have looked at the error message and your script.
> > > 
> > > [...]
> > > 
> > > Anno
> > 
> > Sorry - I didnt realize counting to line 14 was going to be a problem.
> 
> Then why didn't you?
> 
> Every effort you save yourself in preparing a posting must be compensated
> by *every one* of your readers.  That is inefficient and annoying.
> 
> > And I did look at the error message which I indicated in the original
> > post, That is why I asked the question.. I wasnt sure why... Thanks
> > for your time.
> 
> Well, there is only one variable ($fields[8]) in the line that could be
> undefined.  There isn't much room for interpretation or doubt, is there?  
> From your posting, one could get the impression you hadn't even bothered
> to identify the offending line.  That's another reason why it would
> have been wise to mark it.
> 
> Anno

If I could draw conclusions on what the problem was, I would not have
asked. The confusion I had was because I never received these errors
when testing against my original file - only when I started testing
with different ones.. I will try and be more precise next time.

thanks,


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

Date: Thu, 13 Mar 2003 10:06:37 -0600
From: "Bob Dover" <dover@nortelnetworks.com>
Subject: Re: What's wrong with the Perl docs
Message-Id: <b4qaar$29m$1@zcars0v6.ca.nortel.com>

"Helgi Briem" wrote...
>
> I find that a ridiculous request/requirement.  The
> standard docs should be in the language the technology
> is implemented in...

As someone who once had to write code in a German assembly language,
I'll tell you I was damn glad to have support docs in English.  I can
understand
a request for support docs to be in the programmer's language, but that's
not
the job for those developing/supporting perl.  That's a task for some local
group.  All I would expect is for there to exist sufficient tools to allow
that local
group to replace English with the local translation in perldoc, etc.

-Bob




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

Date: 18 Mar 2003 11:08:27 -0800
From: Crapnut566@yahoo.com (Nataku)
Subject: Re: why can't I last?
Message-Id: <7e48fc99.0303181108.f29f404@posting.google.com>

Its my guess that the conditional isnt being evaluated to true ever. 
Try using a regexp match instead of perl's eq operator.

if( $date =~ m/$today/i ){
 ...
}

the 'i' will make sure that case insensitivity is used, so mon will
match MON or MoN etc.

ctcgag@hotmail.com wrote in message news:<20030318105956.142$gg@newsreader.com>...
> stinkbomb <user@someserver123abc.com> wrote:
> > foreach $rec (@db){
> >     @dates_boxes=split /$splitDates_Boxes/, $rec;
> >     $dates_boxes[0]=~ s/[^\/,a-z0-9]//g;
> >     @dates=split /$splitDates/,$dates_boxes[0];
> >     foreach $date (@dates){
> >         if ($date eq $today){
> >             print "$date = $today<br>";
> >             last;
> >         }
> >     }
> >     print "<br>oooooo<br>"; #decoration
> > }
> 
> 
> What makes you think you can't last?
> 
> Xho


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

Date: Tue, 18 Mar 2003 13:41:31 -0600
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: why can't I last?
Message-Id: <b57spc$ic16@onews.collins.rockwell.com>

On 3/18/2003 12:45 PM, Andras Malatinszky wrote:
> 
> I presume [...] that Steve's thinking that since the MAIN: label is
> before the outer loop, saying last MAIN returns control to the point
> before the outer loop begins

Perhaps. last ne goto.

-mjc



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

Date: Tue, 18 Mar 2003 12:50:11 -0800
From: Steve May <stevenm@bogus.blackwater-pacific.com>
Subject: Re: why can't I last?
Message-Id: <b5807g$gpt$1@quark.scn.rain.com>

Andras Malatinszky wrote:
> 
> 
> Michael Carman wrote:
> 
>> On 3/18/2003 10:50 AM, Steve May wrote:
>>
>>> Bart Lateur wrote:
>>>
>>>> You have nested loops. You probably want to jump out of the
>>>> outer loop. For that, use a label.
>>>>
>>>>     MAIN:
>>>>     foreach $rec (@db){
>>>>     ...
>>>>        foreach ... {
>>>>            ...
>>>>            last MAIN;
>>>>        }
>>>>     }
>>>>
>>>>
>>> Ah.... that appears to be an infinite loop unless I'm mistaken...
>>>
>>
>> You are. It's a nested loop, not an infinite one.
>>
>> Well, okay, the '...' are arbitrary, so it *could* be infinite, but in
>> general, it isn't.
> 
> 
> I presume -- and I may be wrong here -- that Steve's thinking that since 
>  the MAIN: label is before the outer loop, saying last MAIN returns 
> control to the point before the outer loop begins, so the program enters 
> the outer loop again, the loops are run until the last MAIN is executed 
> again, at which point control is returned to the point before the outer 
> loop, and things keep getting repeated over and over again. Frankly, 
> it's not illogical to think that; it's just not the way Perl works.
> 

That was my thought.  I rarely ever use the construct above and in fact
I rarely use labels at all....

Shame on me. :-)

s.



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

Date: Tue, 18 Mar 2003 13:12:22 -0800
From: Steve May <stevenm@bogus.blackwater-pacific.com>
Subject: Re: why can't I last?
Message-Id: <b581h1$ip4$1@quark.scn.rain.com>

Michael Carman wrote:
> On 3/18/2003 10:50 AM, Steve May wrote:
> 
>>Bart Lateur wrote:
>>
>>>You have nested loops. You probably want to jump out of the
>>>outer loop. For that, use a label.
>>>
>>>	MAIN:
>>>	foreach $rec (@db){
>>>	...
>>>	   foreach ... {
>>>	       ...
>>>	       last MAIN;
>>>	   }
>>>	}
>>>
>>
>>Ah.... that appears to be an infinite loop unless I'm mistaken...
> 
> 
> You are. It's a nested loop, not an infinite one.
> 
> Well, okay, the '...' are arbitrary, so it *could* be infinite, but in
> general, it isn't.
> 
> 
>>Personally, I'd lean towards putting the loop in a sub
>>or subref and then using return to bail, something like:
>>
>>my @list = qw( some values to match against );
>>
>>my $db_loop = sub{
>>  my @rows = @_;
>>  foreach my $row( @rows ){
>>    for( @list ){
>>       $row =~ /$_/ and return;
>>    }
>>  }
>>};
>>
>>&$db_loop( @db );
> 
> 
> That seems like a hideous and unnecessary obfuscation. How is that
> better than using 'last LABEL' ?
> 
> 

Ah yes, one person's clarity is another's obfuscation. :-)

The OP code apparently reminded me of constructs I use to recusively
drill down into data records.

In fact I was just setting one up a few hours before I posted my
orginal reply.  I suppose I was fixated on that approach as a general
solution which it's not in this case.

Though I don't know that I'd call it hideous.
Weird perhaps. :-)

s.





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

Date: Tue, 18 Mar 2003 21:07:46 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: why can't I last?
Message-Id: <1k2f7vkr2t4eov1ru82lth4t3be01142u1@4ax.com>

Andras Malatinszky wrote:

>I presume -- and I may be wrong here -- that Steve's thinking that since 
>  the MAIN: label is before the outer loop, saying last MAIN returns 
>control to the point before the outer loop begins

Actually, the label identifies the loop. So "last MAIN" simply tells
which loop you're exiting -- on the rear side, of course.

-- 
	Bart.


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

Date: Tue, 18 Mar 2003 16:51:14 -0500
From: AK <aknntp@yahoo.com>
Subject: Re: Win32 Perl newsgroup?
Message-Id: <9t4f7v4at9a7stv331te15ovq1s3ie0403@4ax.com>

On Tue, 18 Mar 2003 00:11:47 GMT, "Bob X" <bobx@linuxmail.org> wrote:
>Here you go:
>news://news.roth.net/

I am sorry, this may be because I'm a relative newbie to newsgroups - How do I
access this newsgroup? That *is* what it is, isn't it?  Is it a 'regular'
newsgroup that I should get with Agent? I couldn't find it on Google Groups as
well.

In any case, I did find the Active State Win32 Perl mailing list thanks to Tad.

- AK



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

Date: Tue, 18 Mar 2003 17:24:41 -0500
From: AK <aknntp@yahoo.com>
Subject: Re: Win32 Perl newsgroup?
Message-Id: <m65f7v4mmlq36j7ma5rjj39mjeia2bsngm@4ax.com>

>On Mon, 17 Mar 2003 12:39:59 -0500, AK <aknntp@yahoo.com> wrote:
>>Is there a newsgroup dedicated to Perl on Win32?
>No.  Perl is Perl.  It's as close to being a platform
>independent language as possible.

Sure, for the most part that is true and in fact, this aspect of Perl is a huge
reason why I am drifting more and more toward it!

But if you have ever been fortunate enough :-) to be confined to Window$ for a
particular task you will quickly find that things are *not* exactly the same
across platforms. :-(

Like I mentioned, the issue I have right now is finding a way to send an email
via Yahoo's SMTP server from a Perl script running on my Win2K laptop. I do not
have access to any other SMTP server right now, unlike Unix boxes where a
functional sendmail (or equivalent) is practically assumed to work without any
explicit SMTP authentication. Yahoo's SMTP servers require you to explicitly
authenticate before they will relay the email.

>>In any case, can I get some recommended sites where online 
>>discussion about Perl on Win32?
>No, but Activestate.com has lots of mailing lists to
>deal with the Windows specificc issues.  Pretty trivial.

Yes, I did find the Activestate mailing lists and subscribing to them was pretty
trivial. If only, I could get a solution to my email issue as easily :)

>>At the moment, my main issue is trying to send out email through an
>>authenticated SMTP server (eg: smtp.mail.yahoo.com) on Windows 2000.
>Any number of modules will do that just fine, whatever
>the platform, Windows or Unix doesn't matter.
>I use MIME::Lite. 

Using the caveat that I am a relative newcomer to Perl, let me say that I have
looked at a few email-related modules - for example:  Mail::Sendmail (Simple
platform independent mailer) - and have not been able to get my script past the
point where the server requires authentication. It fails there (I can post the
actual messages later, if necessary).

I haven't lost all hope yet as I have found another module - Mail::Sender - that
looks promising. I will be trying that out next. Another alternative I have read
about is to run an SMTP server on my machine, thus (hopefully) bypassing any
authentication requirement. Let's see...

Anyway, if you have an example using MIME::Lite (or any other module for that
matter) where you can authenticate with the SMTP server before sending out an
email, I'd appreciate it if you could share it with me.

- AK



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

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.  

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


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