[18446] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 614 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 3 03:16:04 2001

Date: Tue, 3 Apr 2001 00:15:41 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <986282140-v10-i614@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 3 Apr 2001     Volume: 10 Number: 614

Today's topics:
    Re: Multidimensional Arrays? <uri@sysarch.com>
    Re: Multidimensional Arrays? <joe+usenet@sunstarsys.com>
    Re: my and local (The Mosquito ScriptKiddiot)
        net::smtp and authentication <paulthomson@hotmail.com>
    Re: Newbie: keep on matching until end of string <johnlin@chttl.com.tw>
    Re: NT file permissions (Gary Perkins)
        OT: Re: The best book for Win98??? <wayne.keenan@ntlworld.com>
        parrot!?! <anduguid@NOThome.com>
    Re: parrot!?! <wayne.keenan@ntlworld.com>
    Re: parrot!?! <ellem@webcombo.net>
    Re: parrot!?! <ellem@webcombo.net>
    Re: parrot!?! <wyzelli@yahoo.com>
    Re: parrot!?! <brondsem@my-deja.com>
    Re: parrot!?! <wyzelli@yahoo.com>
    Re: parrot!?! <webmaster@webdragon.unmunge.net>
        prepare sql with null values <ori_m57@hotmail.co.il>
    Re: prepare sql with null values <kevin@vaildc.net>
    Re: prepare sql with null values <gh221@email.com>
    Re: Regexp for multiple matches (Rafael Garcia-Suarez)
    Re: regular expression aa versus a{2} (Garry Williams)
    Re: require problem, help?? <JIMIT@prodigy.net>
        Retreiving (W32) internet connection byte counts <mnemotronic@mind\no-spam/spring.com>
    Re: Script optimization question <andrew@mvt.ie>
        Search script <chris@reality-syndicateGETRIDOFTHISTORESPOND.com>
    Re: simultaneously open file handles -- limit? (Garry Williams)
    Re: SMTP Connections <tlav1@mediaone.net>
    Re: sort array contents from file question (Jay Tilton)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 03 Apr 2001 04:33:28 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Multidimensional Arrays?
Message-Id: <x7bsqevbza.fsf@home.sysarch.com>

>>>>> "BG" == Benjamin Goldberg <goldbb2@earthlink.net> writes:

  BG> Milliwave wrote:
  >> 
  >> I'm new to Perl, and have been reading about how to create a (n-row by
  >> 7 column) array?
  >> The book I have only shows me how to access a multidimensional array,
  >> but does not inform me how to go about creating one?

  BG> As others have said, Perl does not have true multidimensional
  BG> array, but it emulates them with references.  That said, don't
  BG> worry about it.  The arrays will spring into existance as needed.

that is called autovivification. for more on this read:

http://tlc.perlarchive.com/articles/perl/ug0002.shtml

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 03 Apr 2001 01:04:05 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Multidimensional Arrays?
Message-Id: <m3pueuvaka.fsf@mumonkan.sunstarsys.com>

Benjamin Goldberg <goldbb2@earthlink.net> writes:

> Garry T. Williams wrote:
> > 
> > On Mon, 02 Apr 2001 22:14:52 GMT, Benjamin Goldberg
> > <goldbb2@earthlink.net> wrote:
> > 
> > >
> > > For example:
> > > my @x;
> > > $x[$i][$j] = 4 foreach my $i (0..6) foreach my $j (0..3);
> > >
> > > Magically makes x into a 7x4 array.
> > 
> > Funny, it doesn't compile:
> > 
> > perl -we 'my @x;$x[$i][$j] = 4 foreach my $i (0..6) foreach my $j (0..3);'
> > syntax error at -e line 1, near "$i ("
> > Execution of -e aborted due to compilation errors.
> 
> Umm, oops?
> 
> Well, the error is with my loop code, not with my array code, anyway.
> 

Umm, it's a syntax error, so perl can't appreciate the difference.
But it does tell you where it's getting stuck, and apparently 
you haven't yet understood what perl is complaining about.

> > > Another way of doing something like this is:
> > > @$x[$i] = ($a, $b, $c, $d) foreach my $i (0..6);
> > 
> > Do I detect a pattern?
> 
> Guess so :)
> 
> And my next suggestion would have been
> $x[$i] = [$a, $b, $c, $d] for my $i (0..6);
> 
> Or something like that :)

  % perl -wce  '$x[$i] = [$a, $b, $c, $d] for my $i (0..6);'

Can you guess what happens now?

See 
  
  % man perlsyn

in particular the section on "Simple statements".

-- 
Joe Schaefer   "How many legs does a dog have if you call the tail a leg? Four.
                         Calling a tail a leg doesn't make it a leg."
                                               -- Abraham Lincoln


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

Date: 03 Apr 2001 06:04:45 GMT
From: anotherway83@aol.com (The Mosquito ScriptKiddiot)
Subject: Re: my and local
Message-Id: <20010403020445.22640.00003736@ng-md1.aol.com>

>http://perl.plover.com/FAQs/Namespaces.html
>
>explains this in detail.
>
>Hope this helps.

thats perfect, explains my problem away

thanks 

peace
The Mosquito ScriptKiddiot
Championing the Cause of Mosquitoes in Technology


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

Date: Sun, 1 Apr 2001 23:34:19 +0100
From: "Paul" <paulthomson@hotmail.com>
Subject: net::smtp and authentication
Message-Id: <3ac7aca3@news1.homechoice.co.uk>

Hi,

I am trying to use net::smtp to send mail but I have discovered that my
server requires authentication. Is there a way to do this with this module?

Thanks in advance,

Paul





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

Date: Mon, 2 Apr 2001 09:06:33 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Newbie: keep on matching until end of string
Message-Id: <9a911q$2s6@netnews.hinet.net>

"Walter Hafner" wrote
> "John Lin" writes:
>
> > I wonder can we use just regular expressions to do it?
>                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Oh, no. Not again.

But it is healthy to your brains.  From this question, I finally
found the solution and learned pos().  Isn't it good?  : )

$_ = 'trash garbabe START some interested words';
my @results;
if(/START/) { pos = $+[0]; @results = /\G\s*(\w+)/g }
print map {"[$_]"} @results;

__END__
[some][interested][words]

John Lin






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

Date: Mon, 02 Apr 2001 07:02:14 GMT
From: garyp@bgm.com.au (Gary Perkins)
Subject: Re: NT file permissions
Message-Id: <3ac823df.746112@wa.nnrp.telstra.net>

Duh.....OK now, just slipped with the keys during the password.

On Mon, 02 Apr 2001 04:44:18 GMT, garyp@bgm.com.au (Gary Perkins)
wrote:

>Thanks but the account I tried already has that priv.  I'll keep
>looking but I'm sure this is where the problem is.
>
>Cheers
>GP
>
>On 30 Mar 2001 00:32:28 -0800, Petri Oksanen
><Petri_member@newsguy.com> wrote:
>
>>In article <3ac40838.17596882@wa.nnrp.telstra.net>, garyp@bgm.com.au says...
>>
>>>>> This script runs fine from the command prompt but fails from
>>>>> the browser.
>>
>>>>> I tried to get the apache service to run under another
>>>>> username but it wont even start.
>>
>>>> This is not really a perl problem.
>>
>>Agreed.
>>He is trying to make use of Perl, though.
>>
>>> The log file gives me 'Cannot opendir .' yet I can from a command
>>> prompt on the server.
>>
>>I have never used Apache on a Win32 system, but I assume it installs itself to
>>run as the _local_ System Account by default.
>>If you need to access resources on other computers in the domain, you need to
>>run the web server under another account, which has the correct domain
>>privileges.
>>You do need to add the "run as service" right to the account you choose,
>>otherwise the web-server won't be able to start.
>>Good luck.
>>
>>
>>Petri Oksanen
>>
>



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

Date: Sun, 01 Apr 2001 23:32:05 +0100
From: "wayne.keenan" <wayne.keenan@ntlworld.com>
Subject: OT: Re: The best book for Win98???
Message-Id: <3AC7AC64.169476C6@ntlworld.com>

why is Activestate distro so great?  addmitedly  it's what I'm using but  I've just
bumped into (not installed) PerlMagic,
(http://www.codemagiccd.com/) and that seems to offer the ability to be able to
install modules direct from CPAN,
not in AS propietry PPM format.

anyone got any thoughts on this?

"Clinton A. Pierce" wrote:

> [Posted and mailed]
>
> In article <20010401124023.01186.00001070@ng-df1.aol.com>,
>         hed2099@aol.com (HeD2099) writes:
> > Hey I'm running Windows 98 on my computer right now and will I still be able to
> > create and run scripts using this machine?  If so, which would be the best book
> > for me to read?  I have no previous perl experience, I'm just starting out with
> > the language.
>
> I'm biased, but Teach Yourself Perl in 24 Hours is very platform neutral
> (i.e. it all works in Win98, Unix, MacOS, etc..), has a CD in the jacket with
> a fairly recent Activestate distribtion on it, and is a pretty good
> introduction to Perl.
>
> *ahem*
>
> --
>     Clinton A. Pierce              Teach Yourself Perl in 24 Hours  *and*
>   clintp@geeksalad.org         Perl Developer's Dictionary -- May 2001
> "If you rush a Miracle Man,     for details, see http://geeksalad.org
>         you get rotten Miracles." --Miracle Max, The Princess Bride



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

Date: Sun, 01 Apr 2001 22:09:19 GMT
From: "Luke" <anduguid@NOThome.com>
Subject: parrot!?!
Message-Id: <jGNx6.176907$tP3.2720423@news1.rdc1.bc.home.com>

for all you non slashdotter's, thought u might find this interesting...

http://slashdot.org/articles/01/03/28/1742237.shtml

http://www.oreilly.com/parrot/

the time stamp says on Sunday April 01, @02:20PM
that would suggest to late for a april fools right?

anyway...is it possible? :P~

--
***remove the NOT from the email address***



--
***remove the NOT from the email address***




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

Date: Sun, 01 Apr 2001 23:24:41 +0100
From: "wayne.keenan" <wayne.keenan@ntlworld.com>
Subject: Re: parrot!?!
Message-Id: <3AC7AAA9.76DAE320@ntlworld.com>

a joke,
and it is late, tradition goes you have up until 12:00pm, but how that
tradition holds in a global community I dunno!

Luke wrote:

> for all you non slashdotter's, thought u might find this interesting...
>
> http://slashdot.org/articles/01/03/28/1742237.shtml
>
> http://www.oreilly.com/parrot/
>
> the time stamp says on Sunday April 01, @02:20PM
> that would suggest to late for a april fools right?
>
> anyway...is it possible? :P~
>
> --
> ***remove the NOT from the email address***
>
> --
> ***remove the NOT from the email address***



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

Date: Sun, 01 Apr 2001 18:39:13 -0400
From: LM <ellem@webcombo.net>
Subject: Re: parrot!?!
Message-Id: <sbbfctk246sqaru43984jcgjg31h7uam27@4ax.com>

On Sun, 01 Apr 2001 22:09:19 GMT, "Luke" <anduguid@NOThome.com> wrote
wonderful things about sparkplugs:

Top Posting on purpose:

This is a brilliantly crafted spoof if it is a hoax.  Very recently
GvR was quoted as saying something like, Python is implemented more
than Perl which created a fire storm on the /. boards due to /.'s
penchant for Linux and Perl advocacy.  

I for one wouldn't mind such an animal.

>for all you non slashdotter's, thought u might find this interesting...
>
>http://slashdot.org/articles/01/03/28/1742237.shtml
>
>http://www.oreilly.com/parrot/
>
>the time stamp says on Sunday April 01, @02:20PM
>that would suggest to late for a april fools right?
>
>anyway...is it possible? :P~
>
>--
>***remove the NOT from the email address***



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

Date: Sun, 01 Apr 2001 19:17:42 -0400
From: LM <ellem@webcombo.net>
Subject: Re: parrot!?!
Message-Id: <ildfctkah7gbmqj5t4v98dcv1gskr7fcji@4ax.com>

On Sun, 01 Apr 2001 18:39:13 -0400, LM <ellem@webcombo.net> wrote
wonderful things about sparkplugs:

It IS a spof, I read this Parrot code.  It's prety funny:

    # copy stdin to stdout, except for lines starting with #
    while left_angle_right_angle:
        if dollar_underscore[0] =eq= "#":
            continue_next;
        }
        print dollar_underscore;
    }


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

Date: Mon, 2 Apr 2001 09:28:58 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: parrot!?!
Message-Id: <X3Px6.1$yi2.1903@vic.nntp.telstra.net>

"Luke" <anduguid@NOThome.com> wrote in message
news:jGNx6.176907$tP3.2720423@news1.rdc1.bc.home.com...
> for all you non slashdotter's, thought u might find this
interesting...
>
> http://slashdot.org/articles/01/03/28/1742237.shtml
>
> http://www.oreilly.com/parrot/
>
> the time stamp says on Sunday April 01, @02:20PM
> that would suggest to late for a april fools right?
>
> anyway...is it possible? :P~
>

    # copy stdin to stdout, except for lines starting with #
    while left_angle_right_angle:
        if dollar_underscore[0] =eq= "#":
            continue_next;
        }
        print dollar_underscore;
    }

This looks real cool....  Hehe... April 1 indeed

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
$d='$_$a$s$b$w';$e='$_$a$s$b';sub
d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
sub
e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e
);
$c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";




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

Date: Mon, 02 Apr 2001 02:21:23 GMT
From: "Dave Brondsema" <brondsem@my-deja.com>
Subject: Re: parrot!?!
Message-Id: <DmRx6.127121$W05.24571769@news1.rdc1.mi.home.com>


"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:X3Px6.1$yi2.1903@vic.nntp.telstra.net...
> "Luke" <anduguid@NOThome.com> wrote in message
> news:jGNx6.176907$tP3.2720423@news1.rdc1.bc.home.com...
> > for all you non slashdotter's, thought u might find this
> interesting...
> >
> > http://slashdot.org/articles/01/03/28/1742237.shtml
> >
> > http://www.oreilly.com/parrot/
> >
> > the time stamp says on Sunday April 01, @02:20PM
> > that would suggest to late for a april fools right?
> >
> > anyway...is it possible? :P~
> >
>
>     # copy stdin to stdout, except for lines starting with #
>     while left_angle_right_angle:
>         if dollar_underscore[0] =eq= "#":
>             continue_next;
>         }
>         print dollar_underscore;
>     }
>
> This looks real cool....  Hehe... April 1 indeed
>
> Wyzelli
> --
> ($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
> it around');
> $d='$_$a$s$b$w';$e='$_$a$s$b';sub
> d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
> sub
> e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e
> );
> $c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";
>
>

I would use dollar_underscore all the time!




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

Date: Mon, 2 Apr 2001 12:14:23 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: parrot!?!
Message-Id: <0vRx6.2$yi2.2520@vic.nntp.telstra.net>

"Dave Brondsema" <brondsem@my-deja.com> wrote in message
news:DmRx6.127121$W05.24571769@news1.rdc1.mi.home.com...
>
> > ($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down,
pass
> > it around');
> > $d='$_$a$s$b$w';$e='$_$a$s$b';sub
> > d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
> > sub
> >
e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e
> > );
> >
$c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";
> >
> >
>
> I would use dollar_underscore all the time!
>

Is that pronounced "dollar underscore underscore" ?

Just imagine talking someone through that..."No the second one is
spelled out,  What?, NO, the first one is an underscore.  NO There
aren't any spaces!... Just type dollar underscore underscore..." hehe

Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;




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

Date: 2 Apr 2001 13:09:45 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: parrot!?!
Message-Id: <9a9tmp$mjv$5@216.155.32.18>

In article <wOTx6.64$u15.15376@news.interact.net.au>,
 "Chris W" <chrisw+usenet@dynamite.com.au> wrote:

 | He he he
 | 
 | I guess they'll have to implement a Patch Seed Block to pass around.
 | 
 
*groan*

"Pieces of Nine! Pieces of Nine!" - another parroty error. 

:-)

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: Sun, 01 Apr 2001 17:30:04 -0000
From: ori <ori_m57@hotmail.co.il>
Subject: prepare sql with null values
Message-Id: <tcepcs1atgcsa5@corp.supernews.com>

Hi 

one question,

when preparing sql with '?' in the 'where' part seems to make a
problem when the variable is Null. for example

my $sth = $dbh->prepare ('select * from A where A.name=?) or die($dbh->errstr);
$sth->execute($value) or die($dbh->errstr,$sql17);

the dbi will get the right result only if $value is not null.but if it is null it will bring 0
rows even if there are some rows that A.name are empty.
true, I can ask for IS NULL. but that is no good because then I will have to use
2 difrent sql's.
onther way is to build dynamic the sql using perl, but then I will lose all the prepare benefints!

is there some way to slove this problem?

thanks
ori

--
Posted via CNET Help.com
http://www.help.com/


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

Date: Sun, 01 Apr 2001 17:10:06 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: prepare sql with null values
Message-Id: <010420011710065418%kevin@vaildc.net>

In article <tcepcs1atgcsa5@corp.supernews.com>, ori
<ori_m57@hotmail.co.il> wrote:

> when preparing sql with '?' in the 'where' part seems to make a
> problem when the variable is Null. for example
> 
> my $sth = $dbh->prepare ('select * from A where A.name=?) or
> die($dbh->errstr);
> $sth->execute($value) or die($dbh->errstr,$sql17);
> 
> the dbi will get the right result only if $value is not null.but if
> it is null it will bring 0 rows even if there are some rows that
> A.name are empty. true, I can ask for IS NULL. but that is no good
> because then I will have to use 2 difrent sql's.

I'm afraid there isn't a way around this by the nature of NULL. 
Nothing compares equal to null, not even null.  However, you should be
able to prepare two different queries and use whichever is
appropriate...that will give you the benefits of prepare without too
much extra hassle.

-- 
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net   | blazing high above your head.
 . . . . . . . . .  | But _in_ you is the presence that
 . . . . . . . . . | will be, when all the stars are dead.  (Rainer Maria Rilke)


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

Date: Mon, 2 Apr 2001 12:00:14 +0100
From: "Grant Husbands" <gh221@email.com>
Subject: Re: prepare sql with null values
Message-Id: <o1m9a9.umq.ln@192.168.1.5>

"ori" <ori_m57@hotmail.co.il> wrote in message
news:tcepcs1atgcsa5@corp.supernews.com...
> when preparing sql with '?' in the 'where' part seems to make a
> problem when the variable is Null. for example
>
> my $sth = $dbh->prepare ('select * from A where A.name=?) or
die($dbh->errstr);
> $sth->execute($value) or die($dbh->errstr,$sql17);
>
> the dbi will get the right result only if $value is not null.but if it is
null it will bring 0
> rows even if there are some rows that A.name are empty.
> true, I can ask for IS NULL. but that is no good because then I will have
to use
> 2 difrent sql's.
> onther way is to build dynamic the sql using perl, but then I will lose
all the prepare benefints!
>
> is there some way to slove this problem?

Here's a changed version using a method from the DBI perldocs (perldoc DBI):

my $sth = $dbh->prepare ('select * from A where A.name=? or (A.name is null
and ? is null)') or die($dbh->errstr);
$sth->execute($value,$value) or die($dbh->errstr,$sql17);

Here's the relevent section of the DBI perldoc:

"Binding an undef (NULL) to the placeholder will not select rows which have
a NULL product_code! Refer to the SQL manual for your database engine or any
SQL book for the reasons for this.  To explicitly select NULLs you have to
say "where product_code is NULL" and to make that general you have to say:

 ... WHERE (product_code = ? OR (? IS NULL AND product_code IS NULL))

and bind the same value to both placeholders."

Regards,
Grant Husbands.




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

Date: Mon, 02 Apr 2001 15:27:17 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Regexp for multiple matches
Message-Id: <slrn9ch6j9.2aa.rgarciasuarez@rafael.kazibao.net>

Christoph Kiehl wrote in comp.lang.perl.misc:
> Hi,
> 
> I'm trying to build a regexp to parse something like that:
> 
> <ol>
> <li>dd
> <li>cc
> <li>ff
> </ol>
> 
> what I need from that data is the "<li>"-Items as an array or so. Is there a
> possibility to do that with a regexp or do I have to parse it line for line
> ...

You can do it :

#!/usr/local/bin/perl
my $text = join '', <DATA>;
my @items = $text =~ /<li>(.+)/g;
print "- $_\n" for @items;
__DATA__
<ol>
<li>dd
<li>cc
<li>ff
</ol>

Output :
- dd
- cc
- ff

(See the perlop documentation to find how it works, section about Regexp
quote-like operators).

For anything more complicated, you should consider using a HTML parser
module (such as HTML::Parser).

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Tue, 03 Apr 2001 05:39:24 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: regular expression aa versus a{2}
Message-Id: <slrn9ciogc.sbk.garry@zfw.zvolve.net>

On Tue, 03 Apr 2001 11:48:29 +0930, Don Koks
<don.koks@defence.gov.auREMOVE_CAPITALS> wrote:

> Can anyone tell me the difference between the regular expressions aa and
> a{2} please.
> 
> They are often said to be the same, but are not, as the following bit of
> code shows:
> 
> if ("zaab" =~ /([^a]*)(a{2})b/) {
>     print "\$1 = $1\n";
>     print "\$2 = $2\n";
> }
> 
> This produces no match.  

I think you are hiding something...

  $ cat try
  #!/usr/local/bin/perl -w
  if ("zaab" =~ /([^a]*)(a{2})b/) {
      print "\$1 = $1\n";
      print "\$2 = $2\n";
  }
  $ perl try
  $1 = z
  $2 = aa
  $ 

> If we replace a{2} by aa then we do get a
> match: $1 = z and $2 = aa
> 
> And to make matters even more obscure, if we leave the a{2} there but
> remove the b, it matches again with $1 and $2 as above.
> 
> Can anyone shed any light on this?

I bet *you* can.  

-- 
Garry Williams


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

Date: Sun, 1 Apr 2001 18:11:45 -0500
From: "Jimi  Thompson" <JIMIT@prodigy.net>
Subject: Re: require problem, help??
Message-Id: <9a8ckj$4ge4$1@newssvr05-en0.news.prodigy.com>

RTFM or go to www.bookpool.com and purchase the OReilly Perl books.
You also need to consider upgrading your version of Perl to 5.6

Mickey Mestel <mickm@ix.netcom.com> wrote in message
news:3AC4CDFD.1EE1B66D@ix.netcom.com...
> hi,
>
> i am at perl5 (5.0 patchlevel 5 subversion 2) and i have the following
> script:
>
> #!/usr/local/bin/perl
>
> $foo = Foo::foo;
> #$foo = "Foo/foo.pm";
> require Foo::foo;
> #require $foo;
>
> and the following in the cwd, the file Foo/foo.pm, which is:
>
> package Foo::foo;
>
> print "hello\n";
> 1;
>
> if i run it as above, then it works.  if i instead run the script with
> the line
>
> require $foo;
>
> then i get the following:
> Can't locate Foo::foo in @INC (@INC contains:
> /usr/local/lib/perl5/5.00502/i
> 86pc-solaris /usr/local/lib/perl5/5.00502
> /usr/local/lib/perl5/site_perl/5.005/i
> 86pc-solaris /usr/local/lib/perl5/site_perl/5.005 .) at foo.prl line 6.
>
> if i run it with the lines:
>
> $foo = "Foo/foo.pm";
> require $foo;
>
> then it works.  so it seems that using require in this situation, i'm
> able to get it to find it if i provide a file name, but not a package
> name.  i need this as i am dynamically loading modules depending on the
> input to the script.
>
> can anyone give me a hand on this?  i'm sure i'm missing something
> really simple, but can't figure it out.
>
> also, i don't have access to the newsgroups from work, or very often,
> so i have to get there through this channel.  can you please respond to
>
> mickm@baygate.com
>
> thanks,
>
> mickm
> --
>
> -----------------------------------------------------------------------
> This is a signature file.  This is only a signature file.  Had this
> been an actual piece of useful information, you would have been
> instructed on what to do with it.
> -----------------------------------------------------------------------




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

Date: Sun, 01 Apr 2001 17:50:37 -0600
From: pt <mnemotronic@mind\no-spam/spring.com>
Subject: Retreiving (W32) internet connection byte counts
Message-Id: <3AC7BECC.EB741BD8@mindspring.com>

    Apologies in advance.  This is probably the wrong newsgroup, but I
don't know which would be the right NG.

    I would like to (using Perl) retrieve the number of bytes
transferred (bytes xmitted & bytes received) over the "current network
connection", i.e. current dial-up network connection under W98.  This is
a connection established and used by Netscape.  The Perl script will be
acting mostly as a monitor.  Can this be done using any of the standard
modules, or will I need to stick my nose into the windoze API?  Needless
to say, I've checked the docs.




Remove the obvious anti-spam to reply.


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

Date: Mon, 2 Apr 2001 16:39:17 +0100
From: "Andrew" <andrew@mvt.ie>
Subject: Re: Script optimization question
Message-Id: <9aa6f9$icg$1@kermit.esat.net>


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:9aa4rn$r0g$1@mamenchi.zrz.TU-Berlin.DE...
> According to Andrew <andrew@mvt.ie>:
> > The problem that I'm trying to solve is this;
> > I have a file, each line of which contains an x coordinate, a y
coordinate
> > and a unique reference.  I want to be able to specify a distance
threshold
> > and have all items in the list which are closer to each other than this
> > threshold merged together.  The solution I have come up with is as
follows;
>
> Pity you don't say what "merged together" means, but probably you are
> replacing two sufficiently close points with one new point.  At what
> co-ordinates?  And will it take part in the game again?

Yes, what I want to do is replace an arbitrary number of sufficiently close
points with one point which is at the centroid of those points.  It will no
longer take part since it will now include all points which are within the
threshold distance of each other.  The piece of code I posted works to do
what I want, but I want to know if anyone can give pointers on how to
optimise it to make it faster.

> I am asking because it seems to me that your problem doesn't have a
> unique solution.  Depending on which elements you merge first you may
> end up with different patterns of which elements make up which of the
> final entries.

There should be one unique solution.  Hopefully the clarification above
should indicate why.

>
> So your optimization question is hard to deal with, because we don't
> know what counts as a solution.
>
> I would think of the problem in terms of shifting discs (or, as your
> code seems to imply, squares) of a given size around the plane, trying
> to cover all the points with a minimal number of disks.  This is a
> coverage problem, and they love to turn out NP-hard, so maybe all you
> can expect is an approximate solution.

I had originally used :
$distance = sqrt(($x[$i]-$temp_x[$j])**2 + ($y[$i]-$temp_y[$j])**2);
if ($distance <= $dist)
{
 ....
}
but that took almost twice as long to complete as :
if(abs($x[$i]-$temp_x[$j]) <= $dist && abs($y[$i]-$temp_y[$j]) <= $dist)

{
 ....
}

The difference between squares & discs in this case is not terribly
important

>
> The problem is probably covered (ha ha) in computational geometry.
> Abigail?
>
> Anno
>
> [algorithm and code snipped]




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

Date: Mon, 2 Apr 2001 01:03:17 -0700
From: "Fraggler?" <chris@reality-syndicateGETRIDOFTHISTORESPOND.com>
Subject: Search script
Message-Id: <0rVx6.3716$Ug7.606767@news.uswest.net>

Sorry if this is off topic or the wrong news group, but hey, I'm new.

I'm looking for a search script.  I have an old one which is a CGI script
(and I belive it's written in perl) but I'm very dissatisfied with it,
especially since I can't have it write the search  results to a page that
already has stuff on it, like the buttons and graphics common to every page
of our site.

I just need a search script that will search pages only on the local site
and can be configured to write to a page with content, or even write the
common content (buttons and graphics) along with the search results.

Does anyone know of any links to such scripts?

Thanks!

--

-Fraggler?

www.reality-syndicate.com
A forum for the free exchange
of abnormal ideas and media!





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

Date: Tue, 03 Apr 2001 05:57:48 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: simultaneously open file handles -- limit?
Message-Id: <slrn9cipir.sbk.garry@zfw.zvolve.net>

On Mon, 2 Apr 2001 12:29:52 -0700, B McDonald <plz@righthere.com> wrote:
> Hi. Would someone please tell me if there is a limit on the number of
> simultaneously open file handles? 

Yes.  

> I have a script that processes XML files
> and generates a number of CSV output files for bulk load into SQL 7. I was
> generating 10 of these "slurp" files, but then, when I added two new files
> to the total, file 12 was not getting written to... and it looked as if some
> data was not getting written to other files as well.

Why guess?  Enable warnings and check the result of open() and print
$! on errors.  It's a *very* good idea to check the result of close()
on output files.  You can learn about disk space shortages that way.
:-)  

> I've checked the ActivePerl (5.6.0.613 under Win98) documentation and don't
> see any info on the max number of files that may be simultaneously open for
> writing. Does anyone have any information/experience on this?

I guess that the issue is really an operating system question.  You
might find more information about it in a more appropriate news group
for that sort of thing.  Heck, it might be in the manual.  I know it
is on my system: 

  $ man ulimit
  $ man sysdef
  $ sysdef
  ...
  *
  * Process Resource Limit Tunables (Current:Maximum)
  *
  ...
  0x00000040:0x0000186a   file descriptors

So it's 64 on my system, although there are ways to increase that to
as many as 6,250.  I don't have a clue what your system's limit is,
though.  Sorry.  

-- 
Garry Williams


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

Date: Mon, 02 Apr 2001 01:56:57 GMT
From: ted <tlav1@mediaone.net>
Subject: Re: SMTP Connections
Message-Id: <3AC8074B.C03FB156@mediaone.net>

Good answer!

ted



Ilmari Karonen wrote:

> In article <9a6vcq$g8c$1@news.netmar.com>, peter.reid2000@ntlworld.com wrote:
> >Guys, I need some help here. Can any1 give me a COMPLETE walkthrough on how
> >to send email from Perl.
>
>  1. Open a web browser.
>
>  2. Go to "http://search.cpan.org/".
>
>  3. Click on the link "Mail and Usenet News".
>
>  4. Click on the link "MailTools".
>
>  5. Click on the link "Mail::Send".
>
>  6. Read.
>
> There are, of course, many ways to do it.  You could, for example, use
> Net::SMTP directly -- in fact, I might prefer doing it that way.  Or you
> could open a pipe to sendmail or some other mailer.  Or you could look
> more closely at the module list between steps 3 and 4 to see what other
> modules have been written for this purpose.
>
> --
> Ilmari Karonen - http://www.sci.fi/~iltzu/
> Please ignore Godzilla / Kira -- do not feed the troll.



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

Date: Sun, 01 Apr 2001 18:41:16 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: sort array contents from file question
Message-Id: <3ac773e7.51879788@news.erols.com>

On Sun, 01 Apr 2001 11:01:16 -0500, CoralBanded
<whynot117@hotmail.com> wrote:

>The routine works but when I put in
>the sort command:
>foreach $line (sort @lines)
>or
>@sortedlist = sort @lines;
>nothing gets processed so I assume its an issue with how I should assign
>the results of the sort command so that the foreach can then process it?

Nope.  There's no reason why foreach(@list) should behave differently
when @list is an array than it does when it's a list returned from a
function like sort.  Whatever is causing your program to fail, it
doesn't appear to be the fault of foreach and sort.

sort_sample.pl
--------------
#!/usr/bin/perl -w
use strict;

chomp (my @lines = <DATA>);

print "Unsorted: ";
foreach my $line (@lines) { print "$line " }

print "\nSorted: ";
my @sortedlist = sort @lines;
foreach my $line (@sortedlist) { print "$line " }

print "\nSorted: ";
foreach my $line (sort @lines) { print "$line " }

__DATA__
40
10
35
15
30
25


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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