[10317] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3910 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 6 21:07:33 1998

Date: Tue, 6 Oct 98 18:00:24 -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           Tue, 6 Oct 1998     Volume: 8 Number: 3910

Today's topics:
        (PERL vs VisualBasic) and (PERL with VisualBasic) Can i <gdoucet@ait.acl.ca>
        A numbering issue <isafold@worldnet.att.net>
        Any clues for dealing with serial lines (timeouts)?? <twatson@metricom.com>
    Re: Are there any "perl.newbie" group or forum? <mp@mkt2mkt.com>
    Re: Are there any "perl.newbie" group or forum? (Marc Bissonnette)
    Re: Are there any "perl.newbie" group or forum? <eashton@bbnplanet.com>
    Re: Are there any "perl.newbie" group or forum? (Craig Berry)
    Re: Are there any "perl.newbie" group or forum? (Abigail)
        Can't send mail via telnet programmatically (John W. Fierke)
    Re: CGI.pm - forms within tables - How to? (John Edstrom)
    Re: comp.lang.perl.win32?? (Craig Berry)
        Grab few lines into the buffer in a while loop matching <vsripada@ca.oracle.com>
        hash key creation <miloj@bigfoot.com>
    Re: hash key creation <uri@sysarch.com>
    Re: hash key creation (Craig Berry)
    Re: hash key creation (Larry Rosler)
    Re: How do I generate a GIF <slug@labyrinth.net.au>
    Re: How to pass a hash array to a sub program (Brand Hilton)
    Re: How to pass an array in AND out of a subroutine? <raj.subramani@citicorp.com>
    Re: How to pass an array in AND out of a subroutine? (Larry Rosler)
        Illegal seek from system call <non-spammers_asa.c.martin@boeing.com>
    Re: Illegal seek from system call <eashton@bbnplanet.com>
    Re: Keeping a running list of the top n values retrieve (Sam Holden)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 06 Oct 1998 21:21:37 -0300
From: Guy Doucet <gdoucet@ait.acl.ca>
Subject: (PERL vs VisualBasic) and (PERL with VisualBasic) Can it be done??
Message-Id: <361AB410.BFA47AC5@ait.acl.ca>

I wrote a few Web applications with PERL 5. My apps sit on our Novell
Web Server, in our office network.

>From the HTML documents on our web site, our employees submit info that
is posted to my Perl scripts. The Perl scripts modify databases and
return HTML documents. (By the way: The databases are simply tabulated
text files).

This is great for our remote employees. But for our employees in our
office, I wrote a VisualBasic app that deals with the same databases.
With VB I can write more powerful apps with grids, etc... (this maybe
because I'm new with PERL?)

I basically learned PERL from one book (Using Perl5 for web
programming), and also  from examples.

I don't know much about PERL itself, but... Is there a way to submit
data to a PERL app from an EXE, and can it return data back to the EXE.
Or could a DLL be written with PERL. Basically I am wondering what the
limits are as far as a Win95 environment. I like PERL a lot with its
foreach, push, and tr/// commands. I would like to be able to use it
more than just on our web site, but I don't imagine its a compilable
language that can run on a Win95 PC. If it can, what software is needed
to do so?

Anybody with thoughts on this? All replies appreciated.
Guy Doucet



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

Date: 7 Oct 1998 00:59:54 GMT
From: "Chavez" <isafold@worldnet.att.net>
Subject: A numbering issue
Message-Id: <01bdf18d$51775620$7d794e0c@default>

I am fairly new to Perl and would appreciate any help the list has to
offer.  

sub descend { $b <=> $a};
@actual = sort descend keys %data;
foreach $count (0..6) {
	$list = $count + 1;
	$first = $data{$actual{$count]} [0];
	($one,$two) = split / /,$first;
	print $list\t$actual[$count]\t$names{$one}\t$names{$two}\n";
	$place=1;
	while ($wreh = $data{$actual[$count]}[$place]) {
		($foo,$bar) = split / /,$wreh;
		print "=\t$actual[$count]\t$names{$foo}\t$names{$bar}\n";
		$place++;
	}
}

What this part of the script does is read the keys from %data and print
them out in descending order.  If some of the keys are of equal value the
script will print out an equal sign instead of the next number
ie..1,2,3,=,=,=,4,5....  What I would like to happen is for each individual
key to get a number ie..1,2,3,4,5,6,...and so on.

Thanks in advance for any help. 
Michael


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

Date: Tue, 06 Oct 1998 16:47:20 -0700
From: Tom Watson <twatson@metricom.com>
Subject: Any clues for dealing with serial lines (timeouts)??
Message-Id: <361AAC08.2202D5F8@metricom.com>

In using the POSIX module I'm trying to get some (yuck) Windoze module
converted to unix.  Everything is going along quite well, except for the
timeouts.  Basically what I desire to do is read the serial port (I'm
dealing with a modem) until a specific response comes along, or a
timeout happens.

POSIX has timeouts in Termios, but not as convient as I'd like them.  Is
there a solution for my tale of woe??


Thanks.
-- 
Tom Watson             I'm at work now (Generic short signature)
twatson@metricom.com   (Home:tsw@johana.com)


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

Date: Tue, 06 Oct 1998 16:11:11 -0800
From: madame philosophe <mp@mkt2mkt.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <361AB178.19EDD3C4@mkt2mkt.com>

I am a person who has spent a very very long time looking at Perl
documentation. I have spent a LOT of money and time on Perl Books (name one I
proabably have it). I have trawled newsgroups, as well as the webpages at
perl.com, .org etc.

These do not help newbies, unless a person spends DAYS looking for the
anwser. In the mean time, it marches on.

I've emailed Lincoln Stein, who was much more helpful than this list, so much
so it shocked me.  But even he is very busy and has a patience quotient.

People seek the newsgroups because they need help, not because they are
stupid.

If the people at this group are tired of hearing the same questions.. why
doesn't someone start a newbie perl newsgroup? Or why don't you
"professionals" migrate to another more stylin' hangout? As the web grows
there will be more newbies. GET USED TO IT. And don't shoot me for saying so.

I myself ended up here because clpm is listed in the O Reilly Books.
(Actually the address they put in the book no longer exists and when I
emailed them about it they sent me here, much to my dismay.) Then I ended up
back here because someone in another group recommended I come here for CGI.pm
help. This is what WE go through.

So if we newbies are such a pain in the ass, you can look to elements that
are not just the blame of we who are in search of know-how. Granted there are
some very lazy people out there, but then this is trait is supposed to make a
good Perl programmer according to Father Wall...

I would love to write a decent Perl book or publish a Perl Faq. When I have a
free moment I may do it.  I've read such crap I can't believe it.  It's as
though one is supposed to know Perl already in order to know about it. I'm
certain this is NOT what any of the "true blue Perl ancient scribers" had in
mind.

I realize I am opening myself up for flaming, but I'm ready for you kind of
cowards. Just go ahead and knock the battery off my shoulder!!!

However, what I'm more interested in is solutions than combat.  If this is a
FAQ then let it be one.  If it is some sort of clique, get over yourselves!
It doesn't take a lot of brains to take pot shots to well meaning people.
And I'm sure you are all much more intelligent than that.

What will you do?? The newbies cometh...



John Porter wrote:

> Hauk Langlo wrote:
> >
> > I'm sure there are a lot of people reluctant to post questions here
> > afraid of having "RTFM" yelled in their face each time. I'm not an
> > expert myselfe and I would really like to know if there are any
> > discussion forums etc where it is actually legal to ask questions that
> > might be of a basic nature to some. If you know about something like
> > that, please let me know and me and probably a lot of other will go away
> > and leave you guys alone.
>
> You will not be happy, then, to learn that this is actually a FAQ
> itself.  It has been beaten to death, over and over again.
> It's a bad idea.  If you want to know why, I suggest you do a
> simple search of comp.lang.perl.misc at Deja News.
>
> If the effect of yelling RTFM is to make people reluctant to post
> Frequently Asked Questions, then that is a Good Thing.
> Perhaps they'll be more likely to try to find the answer somewhere
> else, such as in the copious documentation that comes with every
> installation of Perl.
>
> Maybe you should read this newsgroup for a week, and get
> an idea for what kinds of things we like to talk about.
>
> --
> John "Many Jars" Porter
> baby mother hospital scissors creature judgment butcher engineer





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

Date: 6 Oct 1998 23:15:36 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <6ve8ao$fiq$2@news.interlog.com>

In article <6vcvrs$3ks$1@penthesilea.Materna.DE>, Juergen.Puenter@materna.de 
says...
>
>AFAIK, it was never a problem to ask 'basic questions'
>in this group.
>
>However, what you might mean is 'questions that have been 
>asked and answered 1000s of times already' - in short FAQs.

<snip>

>Now, if you still insist on using clpm as your personal 
>helpdesk, asking FAQs etc., you should expect to be treated 
>to a lot of RTFM, use perldoc, read the FAQ...

I'll add my .02 here, too :)

I agree with all the responses to this thread: RTFM is definitely the best way 
to go about it before posting to clpm. Personally, my order of searching for 
answers is the following:

1) Is it in Learning Perl? if no then =>
2) Is it in Programming Perl? if no then =>
3) Is it retrievable via DejaNews? (And 75% of them are :) if no then =>
5) Is it being discussed in CLPM? if no then =>
6) Is it being discussed in comp.infosystems.www.authoring.cgi? if no then =>
7) Can I find samples of code from other scripts via the web? if no then =>
8) Post to CLPM

If this seams time consuming, it's really much shorter than posting to Usenet 
then waiting for your ISP (especially if you have a crummy newsfeed) to post 
any asnwers. Best of all, the above eight steps have led me to learn a ton of 
Perl tricks along the way :) :) :)

So there's my .02 (Though it's in canadian funds, so only about .01 american)

-- 
Marc Bissonnette
InternAlysis
Corporate Internet Research and Results!
http://www.internalysis.com



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

Date: Tue, 06 Oct 1998 23:48:21 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <361AA9CC.BD88893D@bbnplanet.com>

madame philosophe wrote:

> These do not help newbies, unless a person spends DAYS looking for the
> anwser. In the mean time, it marches on.

I would disagree with this statement. Everyone learns differently and
each must in turn find the best way to educate themselves. Sadly, there
is no magic cream or pill one can take to accomplish this. I tried
osmosis in college with O-chem and it didn't quite work as advertised. 

Usenet has been around for a bit and its true that it used to be a
quiter, smaller more techie kind of place, it is still much the same.
Newbies, flaming, personalities. We sometimes tend to forget that there
are people behind the keyboard and all that comes with it. So, my best
advice would be to keep reading and post away. No pain, no gain. Get out
the asbestos suit and c'mon in. With a will, there is a way and with
desire, no goal is unattainable.

> It doesn't take a lot of brains to take pot shots to well meaning people.
> And I'm sure you are all much more intelligent than that.

Abigail makes some of the most delicious 'pot shots' sometimes and she
is pretty bright from what I gather. Brains rarely guarantees patience
and humility.

e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


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

Date: 7 Oct 1998 00:14:32 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <6vebp8$g86$2@marina.cinenet.net>

madame philosophe (mp@mkt2mkt.com) wrote:
: I am a person who has spent a very very long time looking at Perl
: documentation. I have spent a LOT of money and time on Perl Books (name one I
: proabably have it). I have trawled newsgroups, as well as the webpages at
: perl.com, .org etc.

And nobody who can show they've made intelligent use of such references
ever gets flamed.

: These do not help newbies, unless a person spends DAYS looking for the
: anwser. In the mean time, it marches on.

If it's taking you days to find answers to simple questions in the Perl
doc and (good) Perl books, then one or more of these statements is true:

1) You're not cut out for this field.  Not everyone has the mutant brain
   chemistry required to grok programming.
2) By sheer random (bad) luck, you have all the wrong books.  Toss 'em and
   get the Llama, the Camel, and other books generally recommended on
   clpm.
3) You haven't learned how to use reference materials well.  Get familiar
   with the indices of your paper books, and grep (or another search tool)
   for your electronic doc.

: I've emailed Lincoln Stein, who was much more helpful than this list, so much
: so it shocked me.  But even he is very busy and has a patience quotient.
: 
: People seek the newsgroups because they need help, not because they are
: stupid.

I'm sorry, but people who ask FAQs are either stupid or rude; on the
whole, I have more sympathy for the stupid ones, as rudeness is a choice. 

: If the people at this group are tired of hearing the same questions.. why
: doesn't someone start a newbie perl newsgroup?

This has been discussed to death.  Feel free to launch alt.perl.newbies,
but it'll almost certainly devolve into a stew of newbies giving each
other incorrect information and horrible advice. 

: Or why don't you
: "professionals" migrate to another more stylin' hangout?

Why?  We welcome newbies through gurus here -- so long as everyone does
their homework.  I can assure you that those times I've posted something
stupid (broken code, an incorrect statement about Perl), I've been flamed
just like any FAQ-asking newbie.  Well, perhaps a bit less intensely
flamed, but that's because (I hope) I've built up some clpm positive karma
by *not* doing dumb things most of the time. 

: As the web grows there will be more newbies. GET USED TO IT. And don't shoot me for saying so.

Great!  And the door is open.  But just as the question "What's two plus
two?" would be unwelcome in an algebra class, the question "How do I split
a line on whitespace?" is unwelcome in clpm.  You're expected to bring
*some* (easily available, distributed-with-Perl) knowledge to this table.

: I myself ended up here because clpm is listed in the O Reilly Books.
: (Actually the address they put in the book no longer exists and when I
: emailed them about it they sent me here, much to my dismay.) Then I ended up
: back here because someone in another group recommended I come here for CGI.pm
: help. This is what WE go through.

I'm not sure I follow.  What did you want to find out, that the CGI.pm doc
(combined with basic Perl literacy) didn't cover, which we were unwilling
to answer?

: So if we newbies are such a pain in the ass, you can look to elements that
: are not just the blame of we who are in search of know-how. Granted there are
: some very lazy people out there, but then this is trait is supposed to make a
: good Perl programmer according to Father Wall...

Yes, but you'll note that he uses the term in a very special way.  Is it
lazier to look for an answer in a book already on your shelf, or a doc
already on your hardrive, and have the answer in five minutes, or to ask
on clpm, risking your good name in the Perl community for an answer that
might take hours or days to arrive, and might be wrong?

: I would love to write a decent Perl book or publish a Perl Faq.

Do!!

: When I have a free moment I may do it.

 ...but I imagine it'll take more than a moment. :)

: I've read such crap I can't believe it.  It's as
: though one is supposed to know Perl already in order to know about it. I'm
: certain this is NOT what any of the "true blue Perl ancient scribers" had in
: mind.

Have you read the Llama?  That's the 'onramp' to Perl, IMHO.  The other
doc doesn't waste your time re-explaining every element of the language
everywhere it's used.  I consider this a feature.

: I realize I am opening myself up for flaming, but I'm ready for you kind of
: cowards. Just go ahead and knock the battery off my shoulder!!!

Hope you don't consider this a flame; it's not.  I'm attempting to
reorient your worldview.

: However, what I'm more interested in is solutions than combat.  If this is a
: FAQ then let it be one.

Well, more of a meta-FAQ, I guess.

: If it is some sort of clique, get over yourselves!

Nah, we're far too power-mad to do that.

: It doesn't take a lot of brains to take pot shots to well meaning people.
: And I'm sure you are all much more intelligent than that.
: 
: What will you do?? The newbies cometh...

I'm hoping they'll all become good Netizens, and productive members of the
Perl community.  I'll do what I can to help them on the path.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: 7 Oct 1998 00:28:23 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <6vecj7$bqc$1@client3.news.psi.net>

madame philosophe (mp@mkt2mkt.com) wrote on MDCCCLXIII September MCMXCIII
in <URL:news:361AB178.19EDD3C4@mkt2mkt.com>:
++ 
++ If the people at this group are tired of hearing the same questions.. why
++ doesn't someone start a newbie perl newsgroup? Or why don't you
++ "professionals" migrate to another more stylin' hangout? As the web grows
++ there will be more newbies. GET USED TO IT. And don't shoot me for saying so.


*PLONK*


Start a newsgroup yourself.



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: Tue, 6 Oct 1998 18:16:09 -0500
From: John.Fierke@Avnet.com (John W. Fierke)
Subject: Can't send mail via telnet programmatically
Message-Id: <MPG.108460b7febb21ee989681@news.avnet.com>

   I'm putting together some error-checking Unix scripts on a DEC-Alpha 
machine for our EDI group.  Now that we have moved to MS Exchange/ 
Outlook, they aren't having any luck sending mail from the Unix box. 

   I'd like to use 'telnet [mailserver] 25', along with the proper mail 
syntax, to notify the EDI team with email messages and/or paging them via 

email....but it looks like I've got a problem when it comes to trying to 
send the mail commands once I've initiated the telnet!!  

   Anybody know how to get this done?  I'm writing the script in perl and 
it's fairly straight-forward : 

    $sender="Fred.Flinstone@stone.com";
    $recipient="George.Jetson@space.com";
    open(MAIL, "| telnet dev.mail.com 25")
        || die "\nERROR - Unable to open Mail process, stopped";
    # sleep 60;  # had been sleeping long enough for the server to      
    #            # respond
    print MAIL "mail from: $sender\n";
    print MAIL "rcpt to: $sender\n";
    print MAIL "data\n";
    print MAIL "from: $sender\n";
    print MAIL "to: $recipient\n";
    print MAIL "subject: $subject\n";
    print MAIL "$message\n";
    print MAIL ".\n";
    close(MAIL);


   also, all that exists is the perl binary which is 5.004_01.  How much 
trouble would it be to replace that with a FULLY EQUIPPED version of perl 
(compiled with all its features)?  Currently it's size is 942,080...how 
much space would I need to have?  I'm just thinking that I won't be able 
to copy the Net::SMTP module and its constituants onto the box and 'use' 
them, without recompiling.  OK...I just DON'T KNOW!  This isn't really my 
machine to 'experiment' with.

thx,
John Fierke

               Anyone Without a Sense of Humor 
              is at the Mercy of the Rest of Us!
================================================================
|  John Fierke                            11333 Pagemill Road  |
|  Programmer Analyst                     Dallas, TX  75243    |
|  Open Systems Development               (V)214.553.4086      |
|                                         (P)214.581.1564      |
|  John.Fierke@Avnet.com                  (F)214.553.4004      |
================================================================


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

Date: 6 Oct 1998 23:51:09 GMT
From: edstrom@hmsc.orst.edu (John Edstrom)
Subject: Re: CGI.pm - forms within tables - How to?
Message-Id: <6veadd$3le$1@news.NERO.NET>

In article <6ur3q8$2fm$3@marina.cinenet.net>,
	cberry@cinenet.net (Craig Berry) writes:
> Steven D Jones (Steve_D_Jones@hp.com) wrote:
>: I would like to create a form which is formated by placing the input fields 
>: inside of a table.  Here's an html example:
>: 
 ...
> 
> Note that since you want the radio buttons in separate cells, you can't
> use CGI.pm's radio_group function; hence the literal HTML for these.
> 

read the notes about radio- and checkbox groups:

radio button group:
       6.      HTML3-compatible browsers (such as Netscape) can
               take advantage of the optional parameters -rows,
               and -columns.  These parameters cause
               radio_group() to return an HTML3 compatible table
               containing the radio group formatted with the
               specified number of rows and columns.  You can
               provide just the -columns parameter if you wish;
               radio_group will calculate the correct number of
               rows
         
If you want to do something fancy with the table run the output of the
$cgi->radio_group() call through a filter to borders, BGCOLOR & etc.

	je


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

Date: 6 Oct 1998 23:24:32 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: comp.lang.perl.win32??
Message-Id: <6ve8rg$g86$1@marina.cinenet.net>

thom_co@my-dejanews.com wrote:
: Has there been any discussion of creating an additional newsgroup for
: discusssion of win32 related perl issues?
: 
: There are several perl issues that would be of interest only to those doing
: win32 perl programming and not to the rest of the perl community.

Examples?  And why win32 as opposed to any other particular architecture
or OS? 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Tue, 06 Oct 1998 18:48:53 -0400
From: Venu Sripada <vsripada@ca.oracle.com>
Subject: Grab few lines into the buffer in a while loop matching a pattern
Message-Id: <361A9E55.424D921A@ca.oracle.com>

Please help a Perl new-bie,

I have a large file which has variable length records which contain a
record_layout pattern at the beginning of  each line. The sample data
file would look like:

1AZ12345543219876512345098765
1AY123987234237948749592938433432
2BC768709234-2048438492dshfk29834-09234
3DE34lkj23984lksdoiuwe9823kjd0f98werkj23423k4j
1AZ2384-n2322930920390292df094
1AY123423423437948749592938433432
2BC769368034-2048438492dshfk29834-09234
3DE34lkjabcdefghijklmnopqrstuvwxyz8werkj23423k4j
4TXlskdjf34252435234k23k42l3k4l2k3j4l2k34lk23ll2k34skjf

I would like to grab the lines which start with 1AZ till the next 1AZ
put in a buffer (to manipulate as each line) and go on the next set of
lines till the next 1AZ. I am thinking of  "change the input record
separator, start a  while loop  till the next pattern (1AZ) and go into
subroutines where I want to change the record separator back to \n   ".
Can someone help me with some solution?




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

Date: Tue, 6 Oct 1998 16:57:07 -0700
From: "Milo Juenemann" <miloj@bigfoot.com>
Subject: hash key creation
Message-Id: <6vebhi$ssu@news.or.intel.com>

Running the following code results in "3" being printed:

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

print "1\n" if exists $foo{A};
print "2\n" if exists $foo{A}{B};
print "3\n" if exists $foo{A};
exit;

Is the creation of key "A" on the second "if" (where %foo is not being
assigned to) a bug or a feature?

Puzzled,
-Milo




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

Date: 06 Oct 1998 20:29:35 -0400
From: Uri Guttman <uri@sysarch.com>
To: "Milo Juenemann" <miloj@bigfoot.com>
Subject: Re: hash key creation
Message-Id: <x7pvc5tdsg.fsf@sysarch.com>

>>>>> "MJ" == Milo Juenemann <miloj@bigfoot.com> writes:

  MJ> Running the following code results in "3" being printed:
  MJ> #!/usr/local/bin/perl -w

  MJ> print "1\n" if exists $foo{A}; print "2\n" if exists $foo{A}{B};
  MJ> print "3\n" if exists $foo{A}; exit;

  MJ> Is the creation of key "A" on the second "if" (where %foo is not
  MJ> being assigned to) a bug or a feature?

it is a feature. it is called autovivication. some have argued against
it but too many programs depend on it.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 7 Oct 1998 00:20:46 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: hash key creation
Message-Id: <6vec4u$g86$3@marina.cinenet.net>

Milo Juenemann (miloj@bigfoot.com) wrote:
: Running the following code results in "3" being printed:
: 
: #!/usr/local/bin/perl -w
: 
: print "1\n" if exists $foo{A};
: print "2\n" if exists $foo{A}{B};
: print "3\n" if exists $foo{A};
: exit;
: 
: Is the creation of key "A" on the second "if" (where %foo is not being
: assigned to) a bug or a feature?

A feature or misfeature called 'autovivification'.  There was a thread
about this last week.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Tue, 6 Oct 1998 17:32:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: hash key creation
Message-Id: <MPG.10845689533e69f99897f0@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <6vebhi$ssu@news.or.intel.com> on Tue, 6 Oct 1998 16:57:07 -
0700, Milo Juenemann <miloj@bigfoot.com> says...
 ...
> print "1\n" if exists $foo{A};
> print "2\n" if exists $foo{A}{B};
> print "3\n" if exists $foo{A};
> exit;
> 
> Is the creation of key "A" on the second "if" (where %foo is not being
> assigned to) a bug or a feature?

Search this newsgroup in DejaNews for 'autovivification'.  The following 
is the most recent entry of many (September 23):

<URL:http://x2.dejanews.com/getdoc.xp?AN=393844425&CONTEXT=907720148.1132
527681&hitnum=0>

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 07 Oct 1998 10:07:04 +1000
From: Reiner <slug@labyrinth.net.au>
Subject: Re: How do I generate a GIF
Message-Id: <361AB0A8.A76D15A0@labyrinth.net.au>

Yes, I am aware of the existence of the GD but it is overkill. I do not want
to use any of:
a.  lines, polygons, rectangles and arcs, both filled and unfilled
b.  flood fills
c.  the use of arbitrary images as brushes and as tiled fill patterns
d.  line styling (dashed lines and the like)
e.  horizontal and vertical text rendering
f.  support for transparency and interlacing

All I want to do is plot pixels sequentially, just like Jeffrey Friedl's
gif.pl only with color.

GD is a behemoth!

-Reiner


Justin Harvey wrote:

> Try the GD library, find it at CPAN
> ftp://ftp.digital.com/pub/plan/perl/CPAN/modules/by-module/GD/
>
> A snippet from the readme:
> > GD.pm A perl5 interface to Thomas Boutell's gd library.
> >
> <snip>





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

Date: 6 Oct 1998 23:27:05 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: How to pass a hash array to a sub program
Message-Id: <6ve909$7p113@mercury.adc.com>

In article <MPG.108416927c46a36b9897e5@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>[Posted to comp.lang.perl.misc and a copy mailed.]
>
>In article <6vdfag$7p15@mercury.adc.com> on 6 Oct 1998 16:08:48 GMT, 
>Brand Hilton <bhilton@tsg.adc.com> says...
>! That's why I labeled it a kludge.  Your way, of course, is the more
>! proper way.  But, since Douglas is currently at the stage in his Perl
>! learning where he's confusing @_ with %_, I thought it a little
>! premature to educate him on references.
>
>Then you should say so.  Many people (including me) at all stages of Perl 
>learning read this newsgroup looking for ideas and tips, and might be 
>misled.

Good point.  Thanks for the tip.

-- 
 _____ 
|///  |   Brand Hilton  bhilton@adc.com
|  ADC|   ADC Telecommunications, ATM Transport Division
|_____|   Richardson, Texas


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

Date: Tue, 06 Oct 1998 12:34:07 +0100
From: Raj Subramani <raj.subramani@citicorp.com>
Subject: Re: How to pass an array in AND out of a subroutine?
Message-Id: <361A002F.B302EA58@citicorp.com>

Refer to the FAQ (or a good Perl book) on references.

> $num_items = 0;
> &read_data ($file1, $num_items, @items);

&read_data (\$file1, \$num_items, \@items);


> sub read_data{
   my($f1, $numItm, $itm) = @_;

   #
   #use the local variables by dereferencing them
   #
   open(FH, "<$ {$f1}") or die("Failed to open $ {$f1}, stopped");
   #
   #each element of an array can be got at also be dereferencing
   #
   $ {$itm[0]} = "Something";
   #
   # ... and so on
   #
> }

-- 
Raj Subramani


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

Date: Tue, 6 Oct 1998 17:27:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to pass an array in AND out of a subroutine?
Message-Id: <MPG.10845561fa5235a29897ef@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <361A002F.B302EA58@citicorp.com> on Tue, 06 Oct 1998 12:34:07 
+0100, Raj Subramani <raj.subramani@citicorp.com> says...
> Refer to the FAQ (or a good Perl book) on references.
> 
> > $num_items = 0;
> > &read_data ($file1, $num_items, @items);
> 
> &read_data (\$file1, \$num_items, \@items);

There is no point whatever to passing references to scalars, as they are 
already passed by reference.

   read_data ($file1, $num_items, \@items);

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 6 Oct 1998 23:22:24 GMT
From: "Asa C. Martin" <non-spammers_asa.c.martin@boeing.com>
Subject: Illegal seek from system call
Message-Id: <361AA630.5B54AADB@boeing.com>

Hi all,

I've been taught that it's a good idea to check the return on all system
functions. But one of my programs dies when I do. Here are the lines
(for example):

$file = "some_file.Z";
system("uncompress $file") || die "can't uncompress $file: $!\n";

When I run this I get
% can't uncompress some_file.Z: Illegal seek

(BTW, it works the same when written system("uncompress", "$file"))

If I take away the "|| die" it runs fine. What am I missing? Am I in
danger by not testing the return of the uncompress?

- Asa Martin


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

Date: Wed, 07 Oct 1998 00:38:50 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Illegal seek from system call
Message-Id: <361AB5A2.C7E8C9AD@bbnplanet.com>

Asa C. Martin wrote:

> $file = "some_file.Z";
> system("uncompress $file") || die "can't uncompress $file: $!\n";

system forks and exec doesn't.

system ( "uncompress $file") == 0 or die "can't uncompress $file: $?\n";

works.

e.

Existiria a verdade 
 Verdade que ninguem ve 
  Se todos fossem no mundo iguais a voce  - Jobim -


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

Date: 7 Oct 1998 00:49:42 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Keeping a running list of the top n values retrieved
Message-Id: <slrn71lel6.mjt.sholden@pgrad.cs.usyd.edu.au>

On 6 Oct 1998 16:42:20 GMT, Abigail <abigail@fnx.com> wrote:
>Sam Holden (sholden@pgrad.cs.usyd.edu.au) wrote on MDCCCLXII September
>MCMXCIII in <URL:news:slrn71jn1r.7c5.sholden@pgrad.cs.usyd.edu.au>:
>++ On Tue, 6 Oct 1998 07:59:00 GMT, Gareth Rees <garethr@cre.canon.co.uk> wrote:
>++ >Nick Tonkin <nick@valueclick.com> wrote:
>++ >> Is there a standard way to keep a running list of the top 20 scoring
>++ >> variables?
>++ >
>++ >Yes.  It's a data structure called a "heap".  Look in any algorithms
>++ >book (for example, "Introduction to Algorithms" by Cormen, Leiserson and
>++ >Rivest, chapter 7).
>++ 
>++ How does a heap help... good for priority queues I admit... but for keeping 
>++ track of the top n values surely a bit excessive... especially since perl
>++ does arrays for you...and sorting for that matter...
>++ 
>++ If you have numbers being retrieved and you just want the to record the
>++ top n values at any given time then why not :
>++ 
>++ @top_20 = (sort {$b <=> $a} @top_20,$new_value)[0..19];
>
>If we have n values, and want to get the top m, sorting takes O (n log n).

And looses on space in a big way for n >> m.

>Using a sorted array of size m, and splice each new element in, takes O (n m).

Which is basically what the above does the sort is O(n log (m+1)) the
assignment is O(n m) so we have O(n m) all up. (Though there a _much_ more
efficient ways of doing it then that one liner...).  We'll ignore the fact that
sort isn't really O(x log x) but O(x x) with quicksort for the moment..

>
>Using a heap gives a running time of O (n log m).
>
>If m is small compared to n, the heap clearly wins.

The smaller m gets the closer O(n m) gets to being as good as O(n log m)...
Since a smaller m has a bigger impact on (n m) than (n log m)

If n is 1000000 and m is 16 then we have
n*m = 16000000
n*log m = 4000000
So it's only 4 times slower. With m = 1024 n*m is over 100 times slower.

Though log m is better than m especially since a heap has little overhead.

>Just because Perl has nice arrays and build in sorting doesn't mean they
>are the best tools for all jobs.

Agreed but as I said I would do the simple, short, easy to type, brain-dead,
slow solution first and see if it was good enough for the job. Until I've
looked at the whole thing, I don't know where the slow down is so I'll use
better code where it's needed... And surely keeping your code inside perl's
C internals is a good thing speed wise.

I agree the heap is probably the best solution, though displaying the
top m elements in decreasing order takes O(m) with the sorted array and 
O(m log m) with the heap (though once sorted it can stay sorted until the
next insertion). Unless someone knows a way of getting at the elements in a heap
in sored order in less than O(m log m)?

So a skip list would actually give O(n log m) insertions and O(m) displays, but
would be a lot more work to implement than a heap.

Anyway we may have left the realms of perl a little while ago.

-- 
Sam

testing? What's that? If it compiles, it is good, if it boots up it is
perfect.
	--Linus Torvalds


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

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

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