[14071] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1481 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 24 18:05:49 1999

Date: Wed, 24 Nov 1999 15:05:28 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <943484727-v9-i1481@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 24 Nov 1999     Volume: 9 Number: 1481

Today's topics:
    Re: advanced whois query (Dan Birchall)
    Re: Array/hash of subroutines? <jtolley@bellatlantic.net>
    Re: Array/hash of subroutines? <slanning@bu.edu>
    Re: Array/hash of subroutines? (Tad McClellan)
    Re: Array/hash of subroutines? (Brett W. McCoy)
    Re: Array/hash of subroutines? (Cat)
    Re: Best Database Engine? <peter@berghold.net>
    Re: can a "cookie-monster" mess with my cookies? (Abigail)
    Re: Can Perl Answer Prompts <peter@berghold.net>
    Re: CGI that doesn't return any result?? <cau.quach@sympatico.ca>
    Re: Clearing QUERY_STRING <gellyfish@gellyfish.com>
    Re: compare a string to values in an array? (Craig Berry)
    Re: compare a string to values in an array? (Abigail)
    Re: compare a string to values in an array? (Tad McClellan)
    Re: compare a string to values in an array? (Scott McMahan)
    Re: compare a string to values in an array? (Craig Berry)
    Re: compare a string to values in an array? <sariq@texas.net>
    Re: Concatenating a string <gellyfish@gellyfish.com>
        cookies <sparker@averstar.com>
    Re: cookies <tristar@direct.ca>
        Exception handling with eval <r9gNOr9SPAM@mailcity.com.invalid>
    Re: Exception handling with eval <dchristensen@california.com>
    Re: execute hidden form within perl cgi script <cau.quach@sympatico.ca>
    Re: file empty? <peter@berghold.net>
    Re: Initialize Variables (Abigail)
        Learning LWP <pradeep.kalyan@nwa.com>
    Re: lex, yacc perl ports (Joe Petolino)
    Re: Merging files (Scott McMahan)
    Re: mirror : y2k compliance <sariq@texas.net>
    Re: Need Design Guidance (Abigail)
    Re: Need Design Guidance (Scott McMahan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 24 Nov 1999 19:13:42 GMT
From: djb991124@scream.org (Dan Birchall)
Subject: Re: advanced whois query
Message-Id: <slrn83odvq.bne.djb991124@sun24hnl.hnl.cheaptickets.com>

On Wed, 24 Nov 1999 18:44:48 -0000, Jon <jon@home.com> wrote:
>Can anyone point me towards information on how to setup advanced queries
>network solutions whois database? I am trying to find / build a perl tool
>that will query the whois by field

I don't think NSI's database is designed to accept those sorts
of queries, and I think they'd be really irate at you if you
attempted it. :)

-- 
Dan 'Shag' Birchall, Palolo Valley, HI, http://dan.scream.org/
My addresses expire.  If replies bounce, remove the datestamp.


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

Date: Wed, 24 Nov 1999 19:20:22 GMT
From: James Tolley <jtolley@bellatlantic.net>
Subject: Re: Array/hash of subroutines?
Message-Id: <3831AE14.64597560@bellatlantic.net>

Cat wrote:
>  
> I need to set up an array of refs to subroutines.

my @subs = (sub {'one'}, sub {'two'});
print join("\n", map { $_->() } # <-- call them like this: $subref->();
                 @subs);

hth,

James


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

Date: 24 Nov 1999 14:26:06 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: Array/hash of subroutines?
Message-Id: <kusyabn8ze9.fsf@strange.bu.edu>

digilady@NOhome.SPAMcom (Cat) writes:
> How on earth (or can I) then call it?

If you have a subroutine reference $s, then
$s->() would deference it with no parameters,
$s->($foo), with one parameter, etc...


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

Date: Wed, 24 Nov 1999 09:21:45 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Array/hash of subroutines?
Message-Id: <slrn83nt3p.eba.tadmc@magna.metronet.com>

On Wed, 24 Nov 1999 17:54:43 GMT, Cat <digilady@NOhome.SPAMcom> wrote:

>I need to set up an array of refs to subroutines. Attempted to glob
>them, 


   Don't use globs when a real reference will do.


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

sub nada { print "nada got called\n" }
sub nada2 { print "nada2 got called\n" }

my @subs = (\&nada, \&nada2);     # code refs

&{$subs[0]};

&{$subs[1]};
-----------------


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 24 Nov 1999 19:44:22 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Array/hash of subroutines?
Message-Id: <slrn83og5h.g0r.bmccoy@moebius.foiservices.com>

Also Sprach Cat <digilady@NOhome.SPAMcom>:

>I need to set up an array of refs to subroutines. Attempted to glob
>them, and actually *saw* a ref at one point, but can't then call the
>thing.
>
>Code looks like this:
>  sub nada;
>  sub nada2;
>
>@subs2=(*nada,*nada2);
>\&s=$subs[0];
>print "$s";
>
>sure enough, it prints main::nada.
>
>How on earth (or can I) then call it?

Ooh, symbolic references, not good, very bad...

You are better off doing:

@subs = (\&nada, \&nada2);

Then you can say:

$subs[0]->(@args); #or &$subs[0](@args)
$subs[1]->(@args); #or &$subs[1](@args)

Take a look at perlref for more details.

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: Wed, 24 Nov 1999 20:59:54 GMT
From: digilady@NOhome.SPAMcom (Cat)
Subject: Re: Array/hash of subroutines?
Message-Id: <383c518e.13525652@news>

:Also Sprach Cat <digilady@NOhome.SPAMcom>:
:>I need to set up an array of refs to subroutines. Attempted to glob
:>them, and actually *saw* a ref at one point, but can't then call the
:>thing.
<snip of nasty code which didn't go there>

Brett W. McCoy wrote:
:Ooh, symbolic references, not good, very bad...
Yes, you're right. Mea Culpa!

:You are better off doing:
:@subs = (\&nada, \&nada2);
:Then you can say:
:$subs[0]->(@args); #or &$subs[0](@args)
:$subs[1]->(@args); #or &$subs[1](@args)

THANK you. That is just what I needed. Of course, I immediately
realized that I required a hash instead of an array, and was able to
tweak it to work, thanks to your so-kind help.

The client has a load of files to be processed, each according to file
"type", which is pulled out of the file name. I now have code to get
the filetype & process it, like this (in case anyone else can use
this:)

sub parseCust;
sub parseDelivery;

$key1="CU";
 ...
$subs{$key1}=\&parseCust;

 ... (get $fileType via substr()
$subs{$fileType}->();

This, instead of a monster "if.. elsif..elsif...elsif...

I'm hoping this method is less expensive.

thank you again,

Cat


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

Date: Wed, 24 Nov 1999 19:49:44 GMT
From: "Peter L. Berghold" <peter@berghold.net>
Subject: Re: Best Database Engine?
Message-Id: <Pine.LNX.3.96.991124144046.2881I-100000@uboat.berghold.net>




On Sun, 21 Nov 1999, James Thurley wrote:

> I was looking at the Database Engines in the CPAN archives but couldn't
> descide which would be the best.
> I want to have a database contaning hundreds of thousands of users and need
> quick access.
> Does anyone have any recomendations?
>

James, 

I get paid all sorts of money  by companies that want me to help them make
this sort of decision.  There all sorts of variables that I take into
consideration when makeing that decision for them.  

Some of those variables are: 
    + Environment
       What kind of hardware? 
       What types of clients are connecting to the RDBMS
       Is there going to be middleware invovled?
       Is this mission critical?
       What kind of suport is going to be needed?

    + How much budget is allocated? (Very important that!)

    + Application
       (some of these may seem repeats from Environment)
      What APIs need to be supported?
        (JDBC,ODBC, dblib, ctlib, Perl, etc. etc.)
      Transaction rates
      Data table sizes and quantity

Anyway, this is way off topic. There are more considerations that need to
be thought of than I have enumerated, but there you have it. 

OBTW:  As much as a proponent of Open Source software as I am I  recognize
that Open Source is not always the answer.  You might want to consider
commercial packages depending on the answers to the above....

 
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           ICQ# 11455958



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

Date: 24 Nov 1999 16:09:32 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: can a "cookie-monster" mess with my cookies?
Message-Id: <slrn83oomv.m2v.abigail@alexandra.delanet.com>

BLIMP8 (blimp8@aol.com) wrote on MMCCLXXVI September MCMXCIII in
<URL:news:19991123192620.10949.00001217@ng-bj1.aol.com>:
{} if a cgi script sets a cookie that will expire on exiting the browser , can
{} this cookie be changed by a hacker ?

What is a `hacker'? At what moment in time has this `hacker' access
to the generating program, the communication link and the browser?

{}                                      will the browser be able to tell the
{} difference between a cookie created by the hacker and a legitimate one create
{} by a cgi script ?

Of course not. There isn't something magical in cookies that say `this one
was created by a cgi program' and `this one was created by a "hacker"'.


Now, what has any of this to do with Perl?



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 24 Nov 1999 19:18:15 GMT
From: "Peter L. Berghold" <peter@berghold.net>
Subject: Re: Can Perl Answer Prompts
Message-Id: <Pine.LNX.3.96.991124141450.2881G-100000@uboat.berghold.net>




On Sat, 20 Nov 1999, JG wrote:

> Can perl answer prompts similar to the way expect does? If so, any
> special moduals needed? An exmple available?
> 

Check out the Expect module for perl.  It's on CPAN.

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           ICQ# 11455958




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

Date: Wed, 24 Nov 1999 22:07:18 GMT
From: "Hacka" <cau.quach@sympatico.ca>
Subject: Re: CGI that doesn't return any result??
Message-Id: <qkZ_3.6026$sy5.8087@news20.bellglobal.com>

"state" ?
use <form> without "action" tag.

Kieu.





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

Date: 23 Nov 1999 22:16:20 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Clearing QUERY_STRING
Message-Id: <81f3nk$2q6$1@gellyfish.btinternet.com>

On Mon, 22 Nov 1999 22:50:40 GMT Jeff Givens wrote:
> 
> The database has a key field that is unique; no records will have a
> duplicate value for this field. I can check the database before the update
> is made for a duplicate, which means the addition shouldn't be made anyway,
> but am looking for something more elegant.

Any half way reasonable database should allow you to enforce the unique
key so that row will not get inserted - you should ask in some group
in the comp.databases.* hierarchy about this ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Wed, 24 Nov 1999 19:04:41 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: compare a string to values in an array?
Message-Id: <s3odm9qrrp51@corp.supernews.com>

Mark-Jason Dominus (mjd@op.net) wrote:
: In article <81h71m$351$1@nnrp1.deja.com>,  <geetago@my-deja.com> wrote:
: >Is there a way to compare a string to values in an array to see if
: >there is a match without looping through each value in the array?
: 
: There are two answers to your question.
: 
: 2. There is no way to examine the elements of an array without looping
:    over them.  The program is not clairvoyant.

But with certain array-like constructs the looping or other lookup work is
hidden from the programmer... 

: 1. You should have been using a hash instead of an array.  If the
:    values in the array were hash keys instead of array elements, then
:    you could use
: 
: 	exists $hash{string};
: 
: to see if the string was one of the keys.

Such as this way.  The mechanics of obtaining a hash value, doing the
lookup to the right bucket, and iterating over the list for that bucket
are hidden from the programmer, making it look like a 'direct' lookup.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "They do not preach that their God will rouse them
      a little before the nuts work loose." - Kipling


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

Date: 24 Nov 1999 13:39:12 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: compare a string to values in an array?
Message-Id: <slrn83oft3.m2v.abigail@alexandra.delanet.com>

Larry Rosler (lr@hpl.hp.com) wrote on MMCCLXXVI September MCMXCIII in
<URL:news:MPG.12a5c872a007081a98a278@nntp.hpl.hp.com>:
[] In article <81h71m$351$1@nnrp1.deja.com> on Wed, 24 Nov 1999 17:25:17 
[] GMT, geetago@my-deja.com <geetago@my-deja.com> says...
[] > Is there a way to compare a string to values in an array to see if
[] > there is a match without looping through each value in the array?
[] 
[] Not without looping through the array at least once.

Not really, there's a possibility to do it without a loop. It requires
though that your query string is the first element of the array. Then,
you only have to make one check, not a loop.

I doubt it's even remotely useful though.


Abigail
-- 
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 24 Nov 1999 09:26:12 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: compare a string to values in an array?
Message-Id: <slrn83ntc4.eba.tadmc@magna.metronet.com>

On Wed, 24 Nov 1999 17:25:17 GMT, geetago@my-deja.com <geetago@my-deja.com> wrote:

>Is there a way to compare a string to values in an array to see if
>there is a match without looping through each value in the array?


   Perl FAQ, part 4:

      "How can I tell whether a list or array contains a certain element?"


>Would appreciate your suggestions.


   I suggest checking the Perl FAQ before posting to the Perl
   newsgroup, as netiquette demands.


>thanks

   Uh huh.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 24 Nov 1999 20:27:18 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: compare a string to values in an array?
Message-Id: <GSX_3.2222$Eh5.126115@monger.newsread.com>

geetago@my-deja.com wrote:
> Is there a way to compare a string to values in an array to see if
> there is a match without looping through each value in the array?

You could use join() and a regex, but I don't think this would
be faster than a loop.

Scott


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

Date: Wed, 24 Nov 1999 20:42:53 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: compare a string to values in an array?
Message-Id: <s3ojedojrrp77@corp.supernews.com>

Abigail (abigail@delanet.com) wrote:
: [] Not without looping through the array at least once.
: 
: Not really, there's a possibility to do it without a loop. It requires
: though that your query string is the first element of the array. Then,
: you only have to make one check, not a loop.
: 
: I doubt it's even remotely useful though.

Well, you could manually unroll the loop and do the same sort of loopless
check up to some finite bounding array size: 

  sub noloop_find {
    my ($target, @list) = @_;

    return undef unless @list > 0;
    return 0 if $list[0] eq $target;
    return undef unless @list > 1;
    return 1 if $list[1] eq $target;
    # ...
    return undef unless @list > 457;
    return 457 if $list[457] eq $target;
  }

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "They do not preach that their God will rouse them
      a little before the nuts work loose." - Kipling


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

Date: Wed, 24 Nov 1999 14:59:37 -0600
From: Tom Briles <sariq@texas.net>
Subject: Re: compare a string to values in an array?
Message-Id: <383C51B9.2C0BDAE1@texas.net>

geetago@my-deja.com wrote:
> 
> Is there a way to compare a string to values in an array to see if
> there is a match without looping through each value in the array?

You are expected to make a reasonable attempt to find answers to your
questions before posting.

The answer to this question is in the Perl FAQ.

- Tom


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

Date: 23 Nov 1999 21:55:01 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Concatenating a string
Message-Id: <81f2fl$2pq$1@gellyfish.btinternet.com>

On 22 Nov 1999 23:50:56 -0500 Uri Guttman wrote:
>>>>>> "A" == Abigail  <abigail@delanet.com> writes:
> 
>   A> Hilaire deSa (hdesa@bellsouth.net) wrote on MMCCLXXIV September MCMXCIII
>   A> in <URL:news:wTm_3.1477$0Y5.15813@news4.mia>:
>   A> ## Wanted to know the cleanest way to concatenate a Space (" ") after a string.
>   A>     $MyString = $ARGV [0];
>   A>     substr ($MyString => length $MyString) = chr 32;
> 
> 	sprintf "%-${\($MyString =~ tr///c + 1 )}s", $MyString
> 

$string = join '', split( //,$string),' ';

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Wed, 24 Nov 1999 19:57:48 GMT
From: Parker Sorenson <sparker@averstar.com>
Subject: cookies
Message-Id: <383C433B.5126E0FE@averstar.com>

Could somebody point me to a good resource on using Perl to set and
retrieve cookies in most browsers?

any help is appreciated in advance

-parker



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

Date: Wed, 24 Nov 1999 21:04:53 GMT
From: "Darryl Dyck" <tristar@direct.ca>
Subject: Re: cookies
Message-Id: <VpY_3.1705$I5.12304@news1.rdc1.bc.home.com>

For cookie info: http://www.cookiecentral.com

http://builder.cnet.com/Programming/Cookies/splash.html

For cookie scripts: http://www.worldwidemart.com/scripts/cookielib.shtml

http://www.scriptsearch.com/pages/l9c3c15.shtml
or use CGI.pm

If you are still unable to implement cookies, we offer this service
at http://www.gethits.com/services/cookies.html

God Bless,
Darryl Dyck

Parker Sorenson <sparker@averstar.com> wrote in message
news:383C433B.5126E0FE@averstar.com...
> Could somebody point me to a good resource on using Perl to set and
> retrieve cookies in most browsers?
>
> any help is appreciated in advance
>
> -parker
>




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

Date: Wed, 24 Nov 1999 11:58:36 -0800
From: seeker <r9gNOr9SPAM@mailcity.com.invalid>
Subject: Exception handling with eval
Message-Id: <210046ed.7fa4f7b3@usw-ex0102-015.remarq.com>

I must execute several lines of cleanup if a file can not be opened;
"die" only allows a
message.  What is wrong with the following "if" test (I would like to
understand "eval"
better), or is there a better way?

A:
eval { open (FILE,$name) };
if ( $@ ) {
  warn "some-kind of warning-text";
  # a group of cleanup lines
  exit;
}

B:
Standard handling for open would be:
open (FILE,$name) || die "message text $@";

C:
Possible though inelegant alternate might be:
open (FILE,$name) || &error($name);
sub error {
  warn "some-kind of warning-text";
  # a group of cleanup lines
  exit;
}


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Wed, 24 Nov 1999 13:03:15 -0800
From: "David Christensen" <dchristensen@california.com>
Subject: Re: Exception handling with eval
Message-Id: <383c5740_3@news5.newsfeeds.com>

seeker:

I typically check the return value of open() (and close) directly, and
include the system error in the error message:

    unless ( open(FH, ">$name") )
    {
        carp "cannot open $name: $!";
        # clean-up
        exit 1;
    }


BTW the convention for exit value is that zero indicates okay and
non-zero indicates error (the range 1-127 should work on most systems).

--
David Christensen
dchristensen@california.com





  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 24 Nov 1999 22:21:09 GMT
From: "Hacka" <cau.quach@sympatico.ca>
Subject: Re: execute hidden form within perl cgi script
Message-Id: <pxZ_3.6029$sy5.8093@news20.bellglobal.com>


<funnyface@bigfoot.com> wrote in message news:81gpgf$oeu$1@nnrp1.deja.com...
>............... I am adding a third parameter, which if present, will run a
> new hidden form within the script ..............................
You add a /value=$nothing/ ? or /value=$somerthing/ ?
Just do if /$nothing'/ or if /$something/ then print "<input blahtype
blahname-blahvalue>"....so long
they are html "text".

Kieu





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

Date: Wed, 24 Nov 1999 19:14:12 GMT
From: "Peter L. Berghold" <peter@berghold.net>
Subject: Re: file empty?
Message-Id: <Pine.LNX.3.96.991124141340.2881F-100000@uboat.berghold.net>




On Sat, 20 Nov 1999, Alan J. Flavell wrote:

> On Sat, 20 Nov 1999, Matthew Bafford wrote:
> 
> > : Ah, but will it be empty afterwards?
> > 
> > Once no more bits and bytes fall out, yes.
> 
> Does that include the sticky bits?
> 
 .... or the naughty bits?

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           ICQ# 11455958




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

Date: 24 Nov 1999 13:24:22 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Initialize Variables
Message-Id: <slrn83of18.m2v.abigail@alexandra.delanet.com>

David Cassell (cassell@mail.cor.epa.gov) wrote on MMCCLXXVI September
MCMXCIII in <URL:news:383C2912.5ACD9F4@mail.cor.epa.gov>:
?? Abigail wrote:
?? [snip] 
?? >     reset 'aB';  # ;-)
?? 
?? Nifty.  I hadn't thought of using reset() .  But if the querent's
?? variables are lexically scoped, reset() won't wipe them.
?? 
?? And won't you need to say:
?? 
?? reset 'abcAB';
?? 
?? to get all the listed variables?  Uh-oh, I just ate @ARGV ...

No. You seemed to have snipped:

## If you have $a, @a, $B, %B, you can do typeglobbing:
##
## undef *a;
## undef *B;

I don't see anything starting with b, c, or A. Furthermore, lexicals
don't have typeglobs, do they?

    { my $a = 3;
      undef *a;
      print "$a\n"; }

That prints 3.



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 24 Nov 1999 16:52:15 -0600
From: "Pradeep Kalyan" <pradeep.kalyan@nwa.com>
Subject: Learning LWP
Message-Id: <81hq6v$17l2$1@nwanews.nwa.com>

Could anybody suggest resources on web to learn LWP modules of PERL. I
appreciate your reply.

Pradeep Kalyan




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

Date: 24 Nov 1999 19:28:02 GMT
From: petolino@Eng.Sun.COM (Joe Petolino)
Subject: Re: lex, yacc perl ports
Message-Id: <81he82$pl2$1@engnews3.Eng.Sun.COM>

>Does perl have any mods for these two standard
>programs?  I searched cpan and didn't come up
>with anything.

This may not be what you're looking for, but there are versions of byacc
capable of outputting Perl code instead of C.  Do a web search for 
'byacc perl'.

-Joe


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

Date: Wed, 24 Nov 1999 20:22:27 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: Merging files
Message-Id: <7OX_3.2220$Eh5.126115@monger.newsread.com>

Magne Oevregaard (b.m.ovregard@shell.no) wrote:
> Hi all,

> I have made a perl script to merge to ascii listings.
> I used a "while loop within a while loop" to test on conditions
> within the second file, and extracted a field from it.
> The script scans the complete second file for each line in the first
> file.
> The script works, but it's slow.

> Could any of you suggest other ways of doing this. witch speeds up
> things?.

A witch would not toil and trouble like this, she'd presort each file
and then merge them. Since both files are already sorted, all the merge
has to do is collate them; it would never have to backtrack because the
files would already be in the expected order.  Plus you'd only have to
sort each file once. The runtime would be one sort on each file, plus the
merge time. That ought to be less than three passes through two files,
let alone one pass per line of one file. (Even if you had to make copies
of the files, because you couldn't clobber the originals, you'd have a
good case for using temporary space for speed.)  If you had a sufficiently
clever system sort, it might be able to sort both and merge them faster
than your own hand-coded solution, with the caveat of not being portable.

Scott



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

Date: Wed, 24 Nov 1999 13:44:29 -0600
From: Tom Briles <sariq@texas.net>
Subject: Re: mirror : y2k compliance
Message-Id: <383C401D.6E7FD22D@texas.net>

xtof wrote:
> 
> Hi,
> 
> I was told that the perl mirroring script "mirror" is not y2k compliant.
> Might there be any perl 4 y2k compliance ? Then running mirror with perl 5
> should be ok !?

Perl (at any version) does not have a y2k problem.

Perhaps you should go back to that wonderful site called Deja.com and do
some more looking around.

Alternatively, contact the people who support 'mirror', and ask them
about *the programs* y2k compliance.

- Tom


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

Date: 24 Nov 1999 13:45:54 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Need Design Guidance
Message-Id: <slrn83og9l.m2v.abigail@alexandra.delanet.com>

Rhino (rhino@wwdc.com) wrote on MMCCLXXVI September MCMXCIII in
<URL:news:4XS_3.2040$qy2.12194@newsfeed.slurp.net>:
,, 
,, What is my best approach to storing and sorting the data? I was thinking
,, about reading the data into a two-dimensional array so that it looked like
,, this:
,, DATE        TOPIC    AUTHOR    TYPE
,, 1983-12    Dune    Herbert      Book
,, 1984-01    1984    Orwell        Film
,, 1984-02    Cyberia Enoon       Story
,, 1984-03    Time     Dann         Book
,, 
,, Then, using the sort column and direction specified by the user, I was going
,, to use a subroutine to split the array into a hash of hashes so that the
,, desired sort key is the key of the hash and the remaining data is in an
,, anonymous hash within the value of the key. For example, if the user wanted

Eew. Just use an array of refs to anon arrays. Then look in the FAQ
how to sort this.

    @info = (["1983-12", "Dune",    "Herbert", "Book"],
             ["1984-01", "1984",    "Orwell",  "Film"],
             ["1984-02", "Cyberia", "Enoon",   "Story"],
             ["1984-03", "Time",    "Dann",    "Book"]);

    $key = {Date => 0, Topic => 1, Author => 2, Type => 3} -> {$sortby};

    @sorted = sort {$a -> {$key} cmp $b -> {$key}} @info;

    @sorted = reverse @sorted if $reverse_sort;



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";`$@`'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 24 Nov 1999 20:16:54 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: Need Design Guidance
Message-Id: <WIX_3.2217$Eh5.126115@monger.newsread.com>

Rhino (rhino@wwdc.com) wrote:

> I also want to be able to present the data sorted by any column of the
> table, ascending or descending.

The cheap, cop-out, lazy way is to read each line into an array, and then
split the original into four fields, then join them with the sort field
first in a new array. Then sort the new array. This will sort it in order
of the first field by collating sequence. Then print out the results.
This is not perfect, and in some cases it might not work, but it ought
to be good enough. If you need better sorting, write your own sort sub,
split each line on the first field and the rest, and compare just the
first field.

I assume you're looking for this kind of dirty, fast hack rather than
using a relational database or something.

Scott



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

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 V9 Issue 1481
**************************************


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