[9894] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3487 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 19 23:07:23 1998

Date: Wed, 19 Aug 98 20:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 19 Aug 1998     Volume: 8 Number: 3487

Today's topics:
        5.004_04: 'sort' core dumps, 'TIEHASH' is buggy... <bmcnett@bigpanda.com>
    Re: ATP what is it? (Martien Verbruggen)
    Re: comp.lang.perl.announce redux (John Moreno)
    Re: comp.lang.perl.newbie (Michael Rubenstein)
    Re: Complex Regular Expression (Martien Verbruggen)
        CVS protocol <allana@NOSPAM*cnet.com>
    Re: CVS protocol (Alastair)
    Re: example for sending mail with perl under win32 <jdw@dev.tivoli.com>
    Re: example for sending mail with perl under win32 <gt2214a@prism.gatech.edu>
        EXCITE / ALTAVISTA-TYPE WEB SPIDER girls@littlegirls.com
    Re: How do I execute perl from html program (Martien Verbruggen)
    Re: How do I pass "Hello World" to a scipt? (NEWBIE) (Bob Trieger)
    Re: How do I pass "Hello World" to a scipt? (NEWBIE) <r28629@email.sps.mot.com>
    Re: Last_modified (help with configureing date output) <jeffinfl@ix.netcom.com>
    Re: Perl & vim (Martien Verbruggen)
        perldoc: No documentation found... <r28629@email.sps.mot.com>
    Re: Pg::perl (Gary D. Foster)
    Re: Protecting a data struc with local or my?--More Con <rick.delaney@shaw.wave.ca>
    Re: Protecting a data struc with local or my?--More Con (Maurice Aubrey)
        setting environment variables <niting@raleigh.ibm.com>
        system call "find" in PERL <shenge@ece.ucdavis.edu>
    Re: system call "find" in PERL (Alastair)
        Webpage sourcecode <jhr@best.com>
    Re: Writing text to another server <niting@raleigh.ibm.com>
    Re: wtf is the obsession with "foo" and "bar" <rra@stanford.edu>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 20 Aug 1998 00:26:54 GMT
From: "Bryan McNett" <bmcnett@bigpanda.com>
Subject: 5.004_04: 'sort' core dumps, 'TIEHASH' is buggy...
Message-Id: <i3KC1.482$_c3.3040805@news.rdc1.nj.home.com>

hiya. i use perl 5.004_04.

sort seems to be having problems. when i try this:

$foo = sub{ $_[0]<=>$_[1] };
sort { &{$foo}($a,$b) } @bar;

perl core dumps.

also, i am getting unexpected results from TIEHASH:

1. tie %user, 'MODULE1', ...
2. $user{bob}{password} = 'xyzzy';
3. $user{bob}{age} = 13;
4. $user{bob}{size} = 7;

in line 2, MODULE1::FETCH('bob') makes a new hash, puts a reference to the
hash in a dictionary, ties the hash to MODULE2 and returns a reference to
the hash.

in lines 3 and 4, MODULE1::FETCH('bob') just looks up the hash reference in
the dictionary and returns it.

as i expect, MODULE2::STORE('age',13) and MODULE2::STORE('size',7) are
called. but mysteriously, MODULE2::STORE('password','xyzzy')  is never
called. is this what i should expect?

but, when i do this instead:

1. tie %user, 'MODULE1', ...
2. $me = $user{bob};
2. $me->{password} = 'xyzzy';
3. $me->{age} = 13;
4. $me->{size} = 7;

MODULE2::STORE('password','xyzzy') is called...






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

Date: 20 Aug 1998 02:54:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: ATP what is it?
Message-Id: <6rg35s$mas$3@nswpull.telstra.net>

[Newsgroups: comp.lang.perl.misc,comp.lang.perl.misc]
There really is no need to name this group twice

In article <35D878B4.18F0B9DE@cisco.com>,
	user <user@cisco.com> writes:
> I come across this Advanced Template Package, what is this
> and hwo and why do the CGI programmers need this?

Why don't you aks the people who wrote that package?

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Wed, 19 Aug 1998 19:26:41 -0400
From: phenix@interpath.com (John Moreno)
Subject: Re: comp.lang.perl.announce redux
Message-Id: <1de0r00.iol4b4gzpwycN@roxboro0-033.dyn.interpath.net>

David Cantrell <NukeEmUp@ThePentagon.com> wrote:

>   phenix@interpath.com (John Moreno) enlightened us thusly:
> 
> >Daniel Adams <dan@fearsome.net> wrote:
> >
> >> Actually, Paddy was entirely correct in what he said. The language
> >> known as English is documented in dictionaries such as the Oxford
> >> English Dictionary. American English, whilst stemming from the same
> >> origins as British English, is sufficiently different to be classified
> >> as a different language. That is why many products ship with electronic
> >> dictionaries in which American English and British ENglish are two
> >> options.
> >
> >This is of course ridiculous - please, a hundred words that are British
> >English and not American English (no slang or food please).
> 
> Just to get started then, words which are common in British English
> and which either have different meanings or aren't used in American
> English ;-)
> 
> boot (merkan* 'trunk')

I'll give you that one.

> pavement (merkan 'sidewalk')

Nope - pavement can mean either in merkan, in fact it can mean any paved
surface.

> railway (merkan 'railroad')

Nope, railway is a legitimate term - not frequently used, but
legitimate.

> almost (merkan 'most', as in merkan 'most all' and british 'amost
>         all')

I hardly ever say most all, I almost always say almost all.

> couldn't (merkan 'could' as in merkan 'could care less' which is just
>           WRONG because they really mean 'don't care at all', as in
>           'could NOT care less')

I couldn't care less about this one - because you couldn't be more wrong
(also when used as 'could care less', it's exactly right because there
is a unspoken [and often forgotten about] "but I can't see how").

> pissed (not to be confused with british 'pissed off' which is
>         something else entirely)

This has several usages in english (at least as I use it).  which do you
mean.

> cider (as opposed to british 'apple juice')

Both are appropriate.  Cider is more often 'hard cider' which isn't
apple juice any more.

> hash (merkan 'pound', meaning the '#' sign)

Infrequent but used.

> gallon (which is a different amount of liquid in merkan and british)

So?  It means a certain volume of liquid in both - we just disagree as
to how much that is.

> faggot (a bundle of sticks (or a meal), of course)

Not a meal, but a bundle of sticks still works.

> nappy (merkan 'diaper')

I don't hang out around the diaper crowd - I wouldn't know what all they
call it.

> Listing a hundred words with their definitions and usage examples
> would be rather boring so I'll leave it at that.  Actually, some of
> the above _are_ slang, but that doesn't matter.  Slang terms are just
> as much a part of the language as respectable words are.

Slang terms are not just as much as part of the language as respectable
words - they are much more likely to disappear tomorrow.

"That cat is cool" just isn't used that much any more.

"He's my boy" doesn't mean the same thing either.

> Currently, use pretty nearly identical vocabularies, but they are
> diverging as the meaning of words changes is different ways.  However,
> our vocabularies are diverging, and we put our sentences together in
> subtlely different ways.  We are currently mutually intelligible, at
> least when writing.

Which all taken together hardly amounts to a different dialect let alone
a whole 'nother language.  There are plenty of places in the US where
you can drive from one part of the city to another and get a more
significant separation in dialect.

> * - merkan is easier to type than 'american' and corresponds better to
> my pronunciation to boot.  It is not meant to be derogatory in case
> there are highly sensitive souls out there in merka reading this.
> Please don't confuse it with 'merkin' ;-)
> 
> --
> David Cantrell, part-time NT/java/SQL techie
>                 full-time chef/musician/homebrewer
>                 http://www.ThePentagon.com/NukeEmUp

I'll promise not to do so if you will add a space (one and only one)
after those two dashes, it's not a sigdash without the space and
programs won't recognize it as one (which they shouldn't because it's
not).

-- 
John Moreno


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

Date: Thu, 20 Aug 1998 00:46:20 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: comp.lang.perl.newbie
Message-Id: <35db71c0.125129977@nntp.ix.netcom.com>

On Tue, 18 Aug 1998 23:21:26 -0400, rjk@coos.dartmouth.edu (Ronald J
Kimball) wrote:

>Andrew M. Langmead <aml@world.std.com> wrote:
>
>> Especially with a language like Perl ... that gives you enough rope to bury
>> yourself.
>
>Okay, I have to ask...  How much rope does it take to bury yourself?

About twice as much as it takes to shoot yourself in the foot.
--
Michael M Rubenstein


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

Date: 20 Aug 1998 02:46:08 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Complex Regular Expression
Message-Id: <6rg2lg$mas$1@nswpull.telstra.net>

Subject: Re: Complex Regular Expression

Complex? In what way?

In article <35D885B8.63ADFE91@templegames.com>,
	Kevin Holbrook <kevin@templegames.com> writes:
> Sorry for my ignorance here, but does anyone know the proper expression
> for matching a comma in the middle of a double-quoted alpha-numeric
> string?
> 
> i.e. to find the comma in :
> 
> "Hello, Dolly"

m|,|;

Now.. You will very likely have to be a bit more specific to make
clear why you think that matching a comma is hard. If it has to be
between two quotes:

m|".*,.*"|;

If you want to be able to match things like:

"Hello Dolly","Hello, Paul"

where you want to match all commas of the type of the second one in
this example, but for an arbitrary number, then you will find that
that is a lot harder. But that is not what you asked. if you want to
know why it is hard, read perlfaq6

# perldoc perlfaq6
     Can I use Perl regular expressions to match balanced text?

You might also want to have a look at the Text::CSV module, to see how
you could go about doing things like this. A regex is not the way to
go. Heh, maybe Text::CSV is actually what you need.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: 20 Aug 1998 00:51:39 GMT
From: Allan Anderson <allana@NOSPAM*cnet.com>
Subject: CVS protocol
Message-Id: <6rfrur$eu5$1@nntp2.ba.best.com>

Does anyone here know much about the CVS client/server protocol?

I'd like to make a module that allows one to check new versions
in w/o having a local checked-out repository.  I think that this
is achievable by using the cvs c/s protocol, and talking directly
to the cvs server, but I'm a little confused as to how it would work.

I'd want to use it to check in stuff that gets updated in a database.
It would be cool if a CGI could just do it all without having to worry
about a local repository.

-- 
Allan Anderson
mailto:allana@NOSPAM*cnet.com
phoneto:415.395.7800x5124
---
Label jars, not people.


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

Date: Thu, 20 Aug 1998 01:08:26 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: CVS protocol
Message-Id: <slrn6tn1e3.a3.alastair@calliope.demon.co.uk>

Allan Anderson <allana@NOSPAM*cnet.com> wrote:
>Does anyone here know much about the CVS client/server protocol?

I'm not sure if this is of interest but there's a module called 'cvswebedit' on
CPAN ;

cpan> d /cvs/
Distribution id = MRJC/cvswebedit-v2.0b1.tar.gz
    CPAN_USERID  MRJC (Martin RJ Cleaver <Martin.Cleaver@BCS.org.uk>)

I don't know CVS myself though ...

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: 19 Aug 1998 16:26:41 -0500
From: "Jim Woodgate" <jdw@dev.tivoli.com>
Subject: Re: example for sending mail with perl under win32
Message-Id: <obvhnoirxq.fsf@alder.dev.tivoli.com>


"K.Posern" <posern@informatik.uni-marburg.de> writes:
> I am hardly interested in an example, how to send a short email with
> perl under a win32-System by direct connecting to the mailhost and using
> the SMTP-Protokoll-commands.

try perldoc Net::SMTP, there are quite a few examples...

-- 
Jim Woodgate 
Tivoli Systems
E-Mail: jdw@dev.tivoli.com


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

Date: Wed, 19 Aug 1998 20:52:04 -0400
From: Alejandro Lay <gt2214a@prism.gatech.edu>
To: "K.Posern" <posern@informatik.uni-marburg.de>
Subject: Re: example for sending mail with perl under win32
Message-Id: <35DB7334.2C52ADC1@prism.gatech.edu>

This is not the solution you are looking for, but after spending
2 weeks tackling the problem using sockets, SMTP, etc... to no avail I
found a work around to the problem and made a sub out of it.
Just locate where your mail program stores the outgoing email messages on
your Win32 system and replace the $into variable with it and you should
be up and going.

########################
###Mailer sends an email message
######################## 
sub mailerDaemon {
   $name_from = $_[0];
   $e_mail_from = $_[1];
   $name_to = $_[2];
   $e_mail_to = $_[3];
   $subject = $_[4];
   $body = $_[5];
   $file = $_[6];

   $Message = "From: $e_mail_from\n";
   $Message .= "To: $e_mail_to\n\n";
   $Message .= "From: $name_from <$e_mail_from>\n";
   $Message .= "To: $name_to <$e_mail_to>\n";
   $Message .= "Reply-To: $name_from <$e_mail_from>\n";
   $Message .= "Subject: $subject\n";
   $Message .= "X-Mailer: Mailer Daemon v 1.0 by IBMex\n\n";
   $Message .= "$body\n";

   $into = "d:/progra~1/slmail/in/" . $file . ".in";
   flock(table,$LOCK_FILE);
   open(table,">$into") || die "Error del Servidor.\n";
   print table "$Message\n";
   close(table);
   flock(table,$UNLOCK_FILE);
}

BTW, I added the $file variable to avoid overwritting the mesages before
they get sent.
Hope it helps.
Alejandro

> Hi.
> 
> I am hardly interested in an example, how to send a short email with
> perl under a win32-System by direct connecting to the mailhost and using
> the SMTP-Protokoll-commands.
> 
> It would be very GREAT if someone has such code, or knows where to get
> it!
> 
> Thanks a LOT - already right here.
> 
> Bye.
> 
> Knuth.


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

Date: Thu, 20 Aug 1998 02:26:16 GMT
From: girls@littlegirls.com
Subject: EXCITE / ALTAVISTA-TYPE WEB SPIDER
Message-Id: <35db892a.2538631@news.phoenix.net>

Anyone know of a script/program that can perform this type of action
and save the data to a delimited text file?

I have a search engine that I need this type of script/program for.

I paid a freelance cgi guy to make one and he can't/won't make it
work. It is quite frustrating.

I don't care what lang. is used, or even how it works, as long as it
works properly and reliably. It can run on the web or from my PC.

If you wish to tinker with the perl scripts I am currently using, you
can download them in .zip format @ http://musiclink.com/script/cgi.zip


Thank you for your interest.

J Cornelius
jc@musiclink.com


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

Date: 20 Aug 1998 02:52:28 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How do I execute perl from html program
Message-Id: <6rg31c$mas$2@nswpull.telstra.net>

In article <35D9E1CE.A51FE7E8@viper.net>,
	Todd Smith <tbsmith@viper.net> writes:
> where you want the script's output, put
> 
> <!--exec cmd="script.pl" -->
> 
> 
> guys- just answer the question!

No. Answer questions when they have something to do with perl. If the
question really has nothing to do with perl, the poster should be
gently pointed in the right direction. Failure to do so will result in
more and more off-topic questions.

Would you answer a question about the home-growing of bananas, if
asked on this group?

Martien

PS. In case you don't get it: This question had nothing to do with
perl. The question was (translated) 'How do I run a CGI program?'. The
fact that this one was written in perl has no bearing on the issue.

PPS. I wish people would stop this stupidity.
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Wed, 19 Aug 1998 22:49:33 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: How do I pass "Hello World" to a scipt? (NEWBIE)
Message-Id: <6rfkvn$pjj$1@ligarius.ultra.net>

[ posted and mailed ]

Wayne Cochrane <Wayne_D_Cochrane@keane.com> wrote:
-> I am setting up a new intranet with IIS. I want to test some simple Perl
-> scripts to see what I can do. The "Hello World" script below works fine.

 ... > snip < ....

If the script works fine from the command line, that means you do not have a 
problem with perl.

Your question is dealing with the interface between perl and your HTTP server 
and I have no doubt that the answer can be located in the CGI FAQs. If by 
chance you don't find an answer in the faq's, check out the 
news:comp.infosystems.www.authoring.cgi newsgroup.

HTH

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-400-1972 
  Ext: 1949 and let the jerk that answers know 
  that his toll free number was sent as spam. "


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

Date: Wed, 19 Aug 1998 17:46:55 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: How do I pass "Hello World" to a scipt? (NEWBIE)
Message-Id: <35DB55DF.C5FEA37D@email.sps.mot.com>

I don't know much about CGI, but if you just want to get the command
line arguments, you can use the internal @ARGV array, while @#ARGV tells
you how many arguments, minus one, there are. 

If you insist on using <STDIN>, try this:

	unix% echo Hello World | your_perl_script.pl

$in will then contain "Hello World\n".

-TK

Wayne Cochrane wrote:
> 
> I am setting up a new intranet with IIS. I want to test some simple Perl
> scripts to see what I can do. The "Hello World" script below works fine.
> I can not, however, seem to figure out how to pass "Hello World" to the
> script at run time. I changed the variable line to "$in = <STDIN>;" and
> tried to pass many parameters when calling the script, some examples
> are:
> 
> http://Intranet/cgi-bin/test2.pl?HelloWorld
> http://Intranet/cgi-bin/test2.pl?in=HelloWorld
> 
> I can not seem to figure out how to pass "Hello World" to the script
> below from Netscape. Please help a newbie to Perl. Thanks in advance.
> 
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> # $in = <STDIN>;    # tried to get this to work with no success.
> $in = "Hello World";
> print "HTTP/1.0 200 OK\n"; print "Content-Type: text/html\n\n";
> 
> print "<HTML>\n"; print "<HEAD>\n"; print "<TITLE>dasfasd</TITLE>\n";
> print "</HEAD>\n";
> print "<BODY>\n";
> print "<H4>$in</H4>\n";
> print "<P>\n"; print "Your IP Address is $ENV{REMOTE_ADDR}.\n";
> print "<P>"; print "<H5>Have a nice day</H5>\n";
> print "</BODY>\n"; print "</HTML>\n";
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> --
> Wayne Cochrane


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

Date: Wed, 19 Aug 1998 19:01:06 -0400
From: Jeff Litwiller <jeffinfl@ix.netcom.com>
To: Steve Linberg <linberg@literacy.upenn.edu>
Subject: Re: Last_modified (help with configureing date output)
Message-Id: <35DB5932.4928DF11@ix.netcom.com>

The first one outputs Wednesday, August 19 1998 02:16 PM and the second one
outputs Wed Aug 19 18:53:58 1998. I just like to control what part of the date
I want displayed and how. Abreviated or written out. Now I understand that
#config and #echo are webserver process and they have nothing to do with Perl,
but I use them as SSI call to get what I want. I would just like include this
option in one of my scripts. but If I do not want the time and just the date
output for files last modification, is there a way?

Is there a way to find out when the file was last viewed? So I could say my
last visitor was here 10 minutes ago? like atime but I am not sure how to use
it. Yes I am fairly new at this but am glad for any help in learning.

Jeff Litwiller

Steve Linberg wrote:

> In article <35DB1FBF.DD8FEDD9@ix.netcom.com>, Jeff Litwiller
> <jeffinfl@ix.netcom.com> wrote:
>
> > I have been struggling with this but have not found the answer. I want
> > to configure how the date is displayed when I ask for LAST_MODIFIED. I
> > am able to configure the date when I put it in as a SSI :
> > <!--#config timefmt="%A, %B %e %Y %I:%M %p"-->
> > <!--#echo var="LAST_MODIFIED"-->
> > The first part configures my date output.
> > Now I want to do that in a cgi with a page count and call it through SSI
> > like :
> > <!--#exec cgi="/cgi-bin/count_lstmod.cgi"-->
> > The best answer so far was :
> > #!/usr/bin/perl
> >
> > require "ctime.pl";
> >
> > $last_updated = &ctime (time);
> > print "Last updated $last_updated\n";
> >
> > It prints out a easier to read date and time.
> >
> > Please post and email me with an answer.
>
> What's the problem with the answer you were given?
>
> You understand that #config and #echo are webserver process that have
> nothing to do with Perl, right?
> _____________________________________________________________________
> Steve Linberg                       National Center on Adult Literacy
> Systems Programmer &c.                     University of Pennsylvania
> linberg@literacy.upenn.edu              http://www.literacyonline.org





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

Date: 20 Aug 1998 02:57:15 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl & vim
Message-Id: <6rg3ab$mas$4@nswpull.telstra.net>

In article <01bdca8a$70d2c240$13386ccb@ilyyzusv>,
	"Pen and Ron Savage" <rpsavage@ozemail.com.au> writes:

> So, does anyone have a _simple_ recommendation on patching vim's colors?

Ask on a group that talks about editors (comp.editors) or join the vim
mailing list. It's mentioned in the vim documentation. This has
nothing at all to do with perl.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Wed, 19 Aug 1998 17:56:23 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: perldoc: No documentation found...
Message-Id: <35DB5817.74060AF4@email.sps.mot.com>

My department's system admin recently updated the perl version, since
then perldoc couldn't locate the document on some modules that I
installed in my user account. Do I have reinstall the modules, or there
is a quicker way to the 'new' perl where the module (documents) are? 

-V commend showed that the path of my perl-lib directory is still there.

-TK


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

Date: 19 Aug 1998 16:46:03 -0700
From: Gary.Foster@corp.Sun.COM (Gary D. Foster)
To: Greg Flanders <gflan@avalon.net>
Subject: Re: Pg::perl
Message-Id: <bcizpd08ric.fsf@corp.Sun.COM>

>>>>> "GF" == Greg Flanders <gflan@avalon.net> writes:

    GF> Has anyone used Pg::perl's error control facilities? I'm doing
    GF> some queries using $result = $conn-> exec($query), but
    GF> sometimes the query fails, and I want to be able to check that
    GF> before I try and access $result. The man page is a little
    GF> cryptic, I should be able to check with

    GF> $result_status = $result->resultStatus;

    GF> right? how exactly do I use this?

Here's what I use:

$conn=Pg::connectdb("dbname=$DBNAME");
if ($conn->status != PGRES_CONNECTION_OK) {
  exit(256);
}

-- Gary F.

-- 
  "A committee is a cul-de-sac down which ideas are lured and quietly 
   strangled."                     Bennett Cocks, 1973


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

Date: Wed, 19 Aug 1998 23:41:40 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Protecting a data struc with local or my?--More Confusion
Message-Id: <35DB6426.60C2CAA4@shaw.wave.ca>

Craig Berry wrote:
> 
> Matt Murdock (mmurdock@mail.Globalserve.net) wrote:
> :     I have a program which repeatedly passes a complex data 
> : structure toa subroutine by reference.  The struc is essentially a 
> : list of hashes of arrays.  The subroutine needs to check the 
> : 'defined'ness of the arrays referenced by the hash keys.  It seems 
> : that in so doing the hash keys are created.  The next time the 
> : structure is passed to the sub, the once undefined hash keys are 
> : suddenly defined!  How can I avoid this behaviour?
> 
> Use 'exists' to check for the existence of the key, and iff it exists
> proceed to check for the defined-ness of its value.  E.g,
> 
>   if (exists $myhash{foo} && defined $myhash{foo}) {
>     ...
>   }
> 

Unfortunately 'exists' will also allow references to spring into
existence with some flavours of perl (5.004_04).  For example:

#!/usr/local/bin/perl -w

use strict;
my %hash = (1 => { 2 => 1 });

print "First call\n";
test_defined(\%hash);
print "Second call\n";
test_defined(\%hash);

sub test_defined {
    my $ref = shift;
    for my $x (1..2) {
        print "x = $x does not exist\n" unless exists($ref->{$x});
        for my $y (1..2) {
            print "$y\n" if exists($ref->{$x}{$y});
        }
    }
    $ref->{1}{2} = 5;# This is to demonstrate that the original
                     # hash gets changed.
}
print "$hash{1}{2}\n";

This prints:
First call
2
x = 2 does not exist
Second call
2
5

One way to get around this is to make a copy of the data structure. 
Replacing 
    my $ref = shift; 
with 
    my %hash = %{$_[0]};
    my $ref = \%hash;

produces the output:
First call
2
x = 2 does not exist
Second call
2
x = 2 does not exist
5

as desired.  However, I am now confused about the scoping of $ref.  In
both cases the original hash is modified, but only the first case causes
keys to spring into existence.

What's the story here?

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Thu, 20 Aug 1998 00:22:27 GMT
From: maurice@hevanet.com (Maurice Aubrey)
Subject: Re: Protecting a data struc with local or my?--More Confusion
Message-Id: <slrn6tmr25.43r.maurice@localhost.localdomain>

On Wed, 19 Aug 1998 23:41:40 GMT, Rick Delaney <rick.delaney@shaw.wave.ca> 
wrote:

>Unfortunately 'exists' will also allow references to spring into
>existence with some flavours of perl (5.004_04).  For example:
>
>#!/usr/local/bin/perl -w
>
>use strict;
>my %hash = (1 => { 2 => 1 });
>
>print "First call\n";
>test_defined(\%hash);
>print "Second call\n";
>test_defined(\%hash);
>
>sub test_defined {
>    my $ref = shift;
>    for my $x (1..2) {
>        print "x = $x does not exist\n" unless exists($ref->{$x});
>        for my $y (1..2) {
>            print "$y\n" if exists($ref->{$x}{$y});
>        }
>    }
>    $ref->{1}{2} = 5;# This is to demonstrate that the original
>                     # hash gets changed.
>}
>print "$hash{1}{2}\n";
>
>This prints:
>First call
>2
>x = 2 does not exist
>Second call
>2
>5
>

Try this:

sub test_defined {
    my $ref = shift;
    for my $x (1..2) {
        if (exists $ref->{$x}) {
          for my $y (1..2) {
            print "$y\n" if exists($ref->{$x}{$y});
          }
        } else {
          print "x = $x does not exist\n";
        }
    }
    $ref->{1}{2} = 5;# This is to demonstrate that the original
                     # hash gets changed.
}                           

This prints:

First call
2
x = 2 does not exist
Second call
2
x = 2 does not exist
5                  

You were causing the references to spring into existence, through
your second exists test:

  print "$y\n" if exists($ref->{$x}{$y}); 

-- 
Maurice Aubrey <maurice@hevanet.com>

A complex system that works is invariably found to have evolved 
from a simple system that worked. 
  - John Gall, Systemantics


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

Date: Wed, 19 Aug 1998 14:18:59 -0700
From: "Nitin Gupta" <niting@raleigh.ibm.com>
Subject: setting environment variables
Message-Id: <6rfmir$1eri$1@ausnews.austin.ibm.com>

How can I set an env variable dynamically from within PERL? I have a script
which sometimes needs to access the proxy server so I need to set the
'http_proxy' env. variable for the session the script is running under.

Any pointers are appreciated.

-Nitin




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

Date: 20 Aug 1998 00:06:51 GMT
From: Eric Sheng <shenge@ece.ucdavis.edu>
Subject: system call "find" in PERL
Message-Id: <6rfpar$bk2$1@mark.ucdavis.edu>

Hi All,

	I am experience an extremely long run time when I do a `find` call in my PERL.  The
following is the detail.

	The directory structure I need to retrieve information from is as follows:


				Grandpa_ma
				    |
		    --------------------------------------
		    |		|			 |
		son_one	     son_two      ...		son_n
		    |	
	-----------------
	|		|
  grandson_hacker     grandson_non_hacker
	|			|
     ----------		     -------
     |        |		      doctor.ext
  prog_PERL  prog_C	      lawyer.ext
    -----    ------	      writer.ext
   foo.ext   hello.ext		.
   goo.ext   world.ext		.
   hoo.ext      .		.
   too.ext      .
      .	        .
      .
      .


	The structure can be seen as a family with some grandsons whose occupations are
hackers, and some grandons that are not.  If the grandson is a hacker, we have sub-directory
that tells us what programming language the grandson has hacked, and the files of the programs with
an extension .ext.  If the grandson is not a hacker, we only care about his occupation, file with .ext .

	While you're in the "Grandpa_ma" directory, I need to find out the *full path* of all
programming languages (i.e. prog_PERL, prog_C) for grandson_hackers, along with the number of program files.
Also I need the *full path* of all the occupations of grandson_non_hackers.

I will then store them as such:

	$family_tree{"/Grandpa_ma/son_one/grandson_hacker/PERL"} = 4;

and:

	$family_tree{"/Grandpa_ma/son_one/grandson_non_hacker/doctor"} = 1;



----------------
Right now, I have a routine that first does:

	$son_name = "son_one";

	foreach $dir (sort (`find Grandpa_ma/$son_name \\( -name 'prog_*' -o -name 'grandson_non_hacker' \\)` ) ) {
	    chomp $dir;
	    if ($dir =~ m|.*/grandson_non_hacker$|) {
		foreach $non_hacker (sort (`find $dir -name \'\*.occup\'`) ) {
		    $family_tree{$non_hacker} = "1\n";
		}
	    }
	    else {
		$num_programs = `ls -l $dir/*.ext 2>/dev/null | wc -l 2>/dev/null`;
		$family_tree{$dir} = $num_programs;
	    }
	}
----------------------

The problem is that I have about 600 prog_* and grandson_non_hacker directories and total up about
8000 files and it take up to 3-5 minutes to run.  Unfortunatly, this is only a small part of a
script and it is not acceptable unless this routine take at most a 5 - 10 seconds.

	I know there has to be a better way to retrieve data than the "find" routine that
I have above, expecially the part where I make the system calls.  I suspect that's what's killing
me.  But this is the best one I have so far. If you can come up with a more efficient
way to doing it, that would be great!  Thanks.

--Eric


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

Date: Thu, 20 Aug 1998 00:24:07 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: system call "find" in PERL
Message-Id: <slrn6tmur0.4m.alastair@calliope.demon.co.uk>

Eric Sheng <shenge@ece.ucdavis.edu> wrote:
>
>The problem is that I have about 600 prog_* and grandson_non_hacker directories and total up about
>8000 files and it take up to 3-5 minutes to run.  Unfortunatly, this is only a small part of a
>script and it is not acceptable unless this routine take at most a 5 - 10 seconds.
>
>	I know there has to be a better way to retrieve data than the "find" routine that
>I have above, expecially the part where I make the system calls.  I suspect that's what's killing
>me.  But this is the best one I have so far. If you can come up with a more efficient
>way to doing it, that would be great!  Thanks.
>
>--Eric

I don't know if I can help with the performance/efficiency here other than
suggest some form of file/path database. I don't know how static the data is.

As for usage - I tend to use the 'File::Find' module (I believe it comes with
Perl) i.e.

use File::Find;

perldoc File::Find

This will certainly clean up the code but might not increase the speed.

HTH,

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Wed, 19 Aug 1998 16:47:08 -0700
From: Joel Rosenberg <jhr@best.com>
Subject: Webpage sourcecode
Message-Id: <35DB63FC.C51B28E0@best.com>

I am seeking to read webpage sourcecode via a cgi script. I am able to
set up an automated viewer, but would like to add the ability to copy
the source code if I see something on the page that I like.

Any suggestions: I tried the normal   open(WEBPAGE, "$file") || die
"Can't open $file\n";
I didn't think it would work but if fooled around for a while and got
nowhere.

Joel Rosenberg
jhr@best.com
650-941-8990




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

Date: Wed, 19 Aug 1998 14:15:19 -0700
From: "Nitin Gupta" <niting@raleigh.ibm.com>
Subject: Re: Writing text to another server
Message-Id: <6rfmc1$14i6$1@ausnews.austin.ibm.com>

The answer to your question is in PERL modules. Use the telnet and ftp
modules to open remote sessions and transfer the files, all from within your
cgi script. You can look for these modules at http://www.cpan.org

-Nitin

Genie Stasko wrote in message ...
>Does anyone know how to create a CGI script that writes a webpage's
>input to a text file on a different server than the one the script
>resides on? I have an existing script on a unix server which emails the
>user's input via the unix 'sendmail'. I'd like to have the script
>additionally place the input in a text file on a separate LAN shared
>server. Does this require manipulating sockets, perhaps?
>
>If anyone has advice, please contact me at rhydon.jackson@mci.com
>
>Thanks




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

Date: 19 Aug 1998 17:05:16 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: wtf is the obsession with "foo" and "bar"
Message-Id: <m3vhnozfer.fsf@windlord.Stanford.EDU>

Guus Zijlstra <guus.zijlstra@pi.net> writes:

> Excuse my newbie question, but what is the Jargon File and soforth, and
> where can I get it (or them)?

<URL:http://www.earthspace.net/jargon/>

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3487
**************************************

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