[8442] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2059 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 9 17:28:34 1998

Date: Mon, 9 Mar 98 14:00:29 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 9 Mar 1998     Volume: 8 Number: 2059

Today's topics:
        Are There Any Snazzy Perl Editors for Windows? <rkturner@us.ibm.com>
    Re: Are There Any Snazzy Perl Editors for Windows? (Mark Watson)
        Arrays and system hangups <rajarmb@indy.tce.com>
    Re: Arrays and system hangups <zenin@best.com>
    Re: c.l.p.mod and TPI (Chip Salzenberg)
        comp.lang.perl.moderated (was Re: Tom, grow up [Re: The <merlyn@stonehenge.com>
    Re: csh builtin - limit <zenin@best.com>
    Re: Help: avoiding eval() on a grep() function. (Andrew M. Langmead)
        How bad is the performance of local() vs passing refere Gerben_Wierda@RnA.nl
    Re: How bad is the performance of local() vs passing re <zenin@best.com>
    Re: HTML::Element/Parser/Tree help <dgoyette@NoMoreSPAMpcisys.net>
    Re: OUT OF MEMORY??? <zenin@best.com>
    Re: overreached my grasp of references (Kevin B Cohen)
    Re: Parsing environment variables <jdf@pobox.com>
        perl and cpio <keford@ingr.com>
    Re: Perl Hash question <jdporter@min.net>
        pod2man and solaris catman <cgilmore@research.att.com>
    Re: Problem with "goto" in Perl (Andrew M. Langmead)
    Re: Problem with "goto" in Perl <zenin@best.com>
    Re: Relational arrays (Mike Stok)
    Re: Relational arrays <jdf@pobox.com>
    Re: Relational arrays <jdporter@min.net>
    Re: Stupid Perl file handler limitation! (Paul Buder)
    Re: SWIG, Perl5, valloc() and char * return (John R. Jackson)
    Re: Tom, grow up [Re: The -w switch (was Re: better way <friedman@uci.edu>
        Win32::Internet fails to retrieve files (Markus Laker)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 9 Mar 1998 13:54:43 -0600
From: "Keith Turner" <rkturner@us.ibm.com>
Subject: Are There Any Snazzy Perl Editors for Windows?
Message-Id: <6e1hdh$1lgo$1@ausnews.austin.ibm.com>

Are there any text editors for windows  that can recognize perl syntax and
color code and such?




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

Date: Mon, 09 Mar 1998 21:48:59 GMT
From: markw@markwatson.com (Mark Watson)
Subject: Re: Are There Any Snazzy Perl Editors for Windows?
Message-Id: <35056362.10836702@news.sedona.net>

Hello Keith,
re:
>Are there any text editors for windows  that can recognize perl syntax and
>color code and such?
Try Emacs for Windows 95 or NT.  It is great for Perl, Java, etc.
-- Mark



*********************************************
*   Mark Watson, author (10 books on AI,    *
*   Java, and C++) and a Java consultant    *
* See www.markwatson.com for Java shareware *
*********************************************


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

Date: 9 Mar 1998 20:54:32 GMT
From: "Bindhu Rajaram" <rajarmb@indy.tce.com>
Subject: Arrays and system hangups
Message-Id: <01bd4b9d$89ab5e60$630afe9d@rajaramb_h.indy.tce.com>

I am having difficulty using perl and arrays. I have a file of approx 2meg
size. I wish to split the data then store the data into arrays. My system
hangs up. Is there a limitation to the array feature??


cavdmc
cavdmc@rocketmail.com


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

Date: 9 Mar 1998 21:36:52 GMT
From: Zenin <zenin@best.com>
Subject: Re: Arrays and system hangups
Message-Id: <889479790.137504@thrush.omix.com>

Bindhu Rajaram <rajarmb@indy.tce.com> wrote:
: I am having difficulty using perl and arrays. I have a file of approx 2meg
: size. I wish to split the data then store the data into arrays.

	Are you sure you need to pull the entire 2megs into memory at once?

	This is a fair amount of memory and possible CPU time (depending
	on just what you do with it as you pull it in and the stucture
	you put it into.

: My system hangs up.

	It does?  Are you sure it isn't just slowing down as your script
	trys to parse 2megs of data?  Have you done a ps (and whatever
	options your ps uses) or top to see what it's state is?

: Is there a limitation to the array feature??

	The amount of memory your system has or is willing to let you
	use, whichever is less.

-- 
-Zenin
 zenin@best.com


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

Date: Mon, 09 Mar 1998 21:12:28 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: c.l.p.mod and TPI
Message-Id: <6e1m2r$565$1@cyprus.atlantic.net>

According to "Eric D. Friedman" <friedman@uci.edu>:
> Chip Salzenberg <chip@pobox.com> wrote:
> > According to "Eric D. Friedman" <friedman@uci.edu>:
> > > It reserves a specific exclusion for the Perl Institute that allows
> > > its board (of which Tom is surely a member) to post unmoderated
> > > "stuff of possible interest to Perl people."
> > 
> > Yes.  But Tom isn't a special individual here, he's a member of a
> > special group (TPI's board).  If the board as a whole disagrees with
> > Tom's (or any other individual's) ideas of what's appropriate to post
> > in clpmod, the board prevails.
>
> Why can't the independent moderation board be trusted to perform this
> function?  Why does TPI's board need a special dispensation to trump an
> otherwise straightforward policy forbidding "advertisement or commercial
> solicitation of any sort"?

Well, obviously this is a judgement call.  But the idea is for the
moderation panel to have authority to leave out "hi hire me I know how
to spel PERL" postings while leaving things like the conferences that
are of interest to all Perlers but which actually involve making
someone money (gasp!).

Consider some of Perl's history.  Larry could have just used the GPL,
but he added the Artistic License which has the effect of allowing
Perl to be used to further the development of commercial and
non-free-source software far more than the GPL does.  Obvious Larry
doesn't mind that his software isn't remaining unstained by that petty
moneymaking (and not just his own, either).

Therefore, it's consistent with the real Perl (as opposed to the
oversimplified version of Perl that some seem to imagine) to allow
things that are commercial in nature if they are of benefit or
interest to the Perl community in general.  And that dovetails
precisely with the mission of The Perl Institute: advancing Perl
through commercial activity *and* volunteerism.  Coincidence?  I don't
think so.

> ... if something better comes along that isn't affiliated with TPI,
> I'd like it to be just as easy to hear about that something as about
> TPI services.

Perhaps you imagine that just because things are vetted by TPI that
therefore non-TPI ads will automatically be excluded.  Nothing could
be further from the truth.  But of course you'll have to see that to
believe it, unless my (and Tom's and Randal's and ...) word is enough.

> As to Tom's specific involvement: he, his two co-authors, and his
> publisher (who *obviously* has a commercial stake in promoting the
> "non-profit" TPI-endorsed Perl Conference & O'Reilly books) form a
> majority of the TPI board.  I'd be very surprised if any of these
> folks voted against posting something that would be in their
> financial best interests.

Get used to be being surprised.

> ... the distinction Chip describes should be enforced by including
> language in the charter that specifically forbids members of TPI's
> board from simultaneously serving as moderators for c.l.p.mod.

I don't see it would help, but it wouldn't hurt -- TPI's board are all
too busy to be moderators anyway.
-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: 09 Mar 1998 13:32:53 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Eric D. Friedman" <friedman@uci.edu>
Subject: comp.lang.perl.moderated (was Re: Tom, grow up [Re: The -w switch (was Re: better way to do this?)])
Message-Id: <8cra4bwqoa.fsf_-_@gadget.cscaper.com>

>>>>> "Eric" == Eric D Friedman <friedman@uci.edu> writes:

Eric> That's not what the charter says.  It reserves a specific exclusion
Eric> for the Perl Institute that allows its board (of which Tom is
Eric> surely a member) to post unmoderated "stuff of possible interest to
Eric> Perl people."  Amazingly, the charter openly acknowledges that TPI
Eric> may have a commercial interest in making such announcements,

A "non-profit" corporation with "commercial interests"?  Where did you
get your dictionary?

Eric>  and yet
Eric> guarantees that, should a TPI-competitor someday emerge,

Straw-man.  Straw-man.  TPI cannot have a "competitor".  TPI occupies
a unique position being the embodiment of Larry's philosophies of perl
development and support.  If Larry ever pulls out of TPI from
dissatisfaction to create a different organization, *I* will
personally make sure that TPI folds the same day.

TPI = Larry, and friends.  Larry owns the copyright to Perl.  Still.

Eric>  it would
Eric> be moderated out of existence.  It's positively Microsoftian!

Perhaps your drugs haven't kicked in completely. :)

You are raising Fear, Uncertainty, and Doubt, looking for things where
they aren't.

TPI is dedicated to keeping Perl Free, Available, and Useful, by
helping people to help Perl help people.  Very simple mission.

By providing the labor and coordination for clp.moderated, we enhance
Usenet Perl support, and therefore the value of Perl to *you*.  Please
don't read evil in there somewhere.  No one is planning that,
individually, or collectively.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 175 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 9 Mar 1998 21:12:58 GMT
From: Zenin <zenin@best.com>
Subject: Re: csh builtin - limit
Message-Id: <889478355.649726@thrush.omix.com>

[ posted & mailed ]

Jonathan Nichols <Jonathan.O.Nichols@lmco.com> wrote:
: I want to set the stacksize to unlimited for a child process called from
: a perl script.
	>snip<
: system("limit stacksize unlimited")  

	If this is sent though a shell at all (because it might have
	to be expanded) it's going to be passed to sh -c, so you'd
	want to be using ulimit not limit.

: and then
: system("command argument")
: then of course, the limit only gets set for the shell spawned for the
: limit command, and the value does not get propogated to the next
: system() call.

	You can't make it "hold" for all system calls, at least not
	without use of the BSD::Resource module and/or some kluges.

	You can do it per call with little overhead (it's not an extra
	fork() because it's a shellbuiltin) by doing something like:

	$ulimit = 'ulimit -s unlimited';

	system ("$ulimit && command argument");
	system ("$ulimit && something else");

-- 
-Zenin
 zenin@best.com


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

Date: Mon, 9 Mar 1998 21:04:50 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Help: avoiding eval() on a grep() function.
Message-Id: <EpKL82.15D@world.std.com>

schwern@starmedia.net writes:

>$pattern = join '&&', map { "m/$_/" } @Pattern;
>$matchSub = eval "sub { $pattern }";

>@matches = grep {&$matchSub} @Array;

>This avoids doing the eval at each iteration of the grep.

Subroutine dereferencing and calling is fairly expensive too, and
should probably also be avoided inside of grep. Trading an eval for a
sub de-reference probably isn't that big of a win.

#!/usr/bin/perl -w

use Benchmark;

my @Array = `cat  /usr/dict/words`;
chomp(@Array);

use vars qw($STR1 $STR2);
$STR1 = 'a';
$STR2 = 'q';

timethese ( 10_000, {
     loop_eval => q(grep { eval "/$STR1/i && /$STR2/i" } @Array),
     one_eval => q(eval "grep { /$STR1/i && /$STR2/i } \@Array"),
     sub_match => q(
       my $matchSub = eval "sub { /$STR1/i && /$STR2/i }";
       grep {&$matchSub} @Array;
     )
});




-- 
Andrew Langmead


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

Date: Mon, 9 Mar 1998 20:40:32 GMT
From: Gerben_Wierda@RnA.nl
Subject: How bad is the performance of local() vs passing references?
Message-Id: <EpKK3L.9C3@RnA.NL>

I have a program that passes explicit references a lot. I could rewrite this 
using local(), the setup is very suited for this as we are talking more or 
less about routines, not functions on objects. But I wondered if there are 
any disadvantages doing this, like speed penalties.

Can anyone enlighten me?

-- 
Gerben_Wierda@RnA.nl (Gerben Wierda)
"If you don't know where you're going, any road will take you there"
Paraphrased in Alice in Wonderland, originally from the Talmud.

Dass man fuer die Philosophie ein Interesse zeigt, bezeugt noch keine
Bereitschaft zum Denken -- Martin Heidegger


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

Date: 9 Mar 1998 21:38:45 GMT
From: Zenin <zenin@best.com>
Subject: Re: How bad is the performance of local() vs passing references?
Message-Id: <889479902.40975@thrush.omix.com>

Gerben_Wierda@RnA.nl wrote:
: Can anyone enlighten me?
	>snip<

	perldoc Benchmark

-- 
-Zenin
 zenin@best.com


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

Date: 9 Mar 1998 20:26:29 GMT
From: "Don" <dgoyette@NoMoreSPAMpcisys.net>
Subject: Re: HTML::Element/Parser/Tree help
Message-Id: <01bd4b99$5d8ad120$b6664ccf@586win95>

Hello John,

Thanks for your reply!

 > What was your understanding of the
   $h->content() description?

Pretty much the same as yours, which results in the same kind of list
address, ie. "ARRAY(0x25ac5c)" being displayed instead of the actual text
and I've not been able to figure out how to convert the list address into
the actual text stored AT that address.  I'm sure it's simple, but it
elludes me <frown>.

Yes the assumption of "plain text" is a good one for starters, but I have
seen people use tags within this text to make it bold, italic, etc., so
that would be my second quest <smile>.

As an aside, over the weekend I figured out how to define a global RegExp
that extracts all HREF's with text, from a document, but am wondering how
it would compare in speed to the HTML:: modules.  Do you have any idea? 
For example, assuming the document is contained within $html...

  while ($html =~ m{<A\sHREF=(.*)</A>}ig) {
    push (@hrefs, $1);
    print "Found: $1\n";
  }

  print "\n";
  foreach $_ (@hrefs) {
    print "Ref: $_\n";
  }

>From which I would then need to parse the url, create a full_url, and parse
the text portion (probably perform an unescape on it too).  I'd think this
might be faster, due to less code being executed, but one never knows
<smile>.

Thanks again for your assistance.  It's greatly appreciated.

-Don

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

John Porter <jdporter@min.net> wrote in article <35040A3C.5ACB@min.net>...
> Don wrote:
> > 
> > The part I now need to obtain is " This is text ".  The HTML::Element
> > documentation is unclear as to where this is stored (if at all) 
> 
> What was your understanding of the $h->content() description?
> 
> How simple the solution is depends on a particular assumption:
> is the text contained within <a></a> always one string of
> plain,  un-marked-up text?  If it is, the solution is quite
> simple: the text is the first (and only) item in the content()
> of the 'a' Element, as shown below.
> If there's any markup in the text, then you'll probably need
> traverse() to get it all.
> 
> hth,
> John Porter
> 
> 
> > ------------------------( script )-----------------------
> > #!/usr/local/bin/perl
> > 
> > use LWP::Simple;
> > use HTML::Parse;
> > use HTML::Element;
> > use URI::URL;
> > 
> > print "Content-type:text/html\n\n";
> > 
> > $html        = get $ENV{'QUERY_STRING'};
> > $parsed_html = HTML::Parse::parse_html($html);
> > 
> > for ( @{ $parsed_html->extract_links(a) } ) {
>     my( $link, $node ) = @{$_};
>     my $text     = ($node->content())[0];
>     my $url      = new URI::URL $link;
>     my $full_url = $url->abs($ENV{'QUERY_STRING'});
>     print "$full_url: $text<BR>";
> > }
> > 
> > $parsed_html->delete();
> 


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

Date: 9 Mar 1998 21:18:09 GMT
From: Zenin <zenin@best.com>
Subject: Re: OUT OF MEMORY???
Message-Id: <889478667.334484@thrush.omix.com>

Aaron Hanson <aahanson@students.uiuc.edu> wrote:
: But now, when I load the page, it prints
: a little of the page, and then "Out of Memory".
	>snip<

	The user resource limits for whoever the httpd is running as
	are probably too low.  Check /etc/login.conf or whatever
	your system uses.  Also check out the BSD::Resource module
	too, as your "soft" limits may (probably) aren't going to be
	set high enough either.  I set everything to unlimited, but
	I like to play fast and loose with my big programs. :-)

-- 
-Zenin
 zenin@best.com


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

Date: 9 Mar 1998 16:06:07 -0500
From: kcohen@julius.ling.ohio-state.edu (Kevin B Cohen)
Subject: Re: overreached my grasp of references
Message-Id: <6e1ljv$84f@julius.ling.ohio-state.edu>

In article <6dnh1l$pcm@ljcqs003.cnf.com>,
Mishra, Aditya <mishra.aditya@emeryworld.com> wrote:
>Is there a question/answer here or do you like to share your exasperation
>with the perl community?

from my point of view, one of the nicest things about perl is that i'm
rarely exasperated with it.

kevin





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

Date: 09 Mar 1998 15:58:13 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Parsing environment variables
Message-Id: <67ln7fa2.fsf@news.concentric.net>

epa@datcon.co.uk (Ed Avis) writes:

> $FOO/readme.txt
> 
> would be converted to
> 
> bar/readme.txt 

Reading perlre and the faqs might give you some ideas.  Here's one
(not particularly robust) approach:

   #!/c/perl5004/bin/perl -w
   while (<DATA>) {
     s/\$(\w+)/$ENV{$1}/g;
     print;
   }
   __DATA__
   /foo/$TZ/bar/$CPU/baz.c
   /tchrist/hates/$OS

results in

   /foo/EST5EDT/bar/i386/baz.c
   /tchrist/hates/Windows_NT

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Mon, 09 Mar 1998 14:20:17 -0600
From: "Keith Ford" <keford@ingr.com>
Subject: perl and cpio
Message-Id: <01bd4b9a$c1fbe6c0$35d38781@magic.b10.ingr.com>

I have a simple script that opens a filehandle that is a pipe into a 'cpio
-o' command.  I print a list of filenames into that filehandle.  When I
execute the script by hand it works fine.  When I invoke it from a web
server if dies, it actually kills the script midstream.  The web server is
running as root.  Also, if I change the cpio command to 'sort > junk', this
will work.

-- 
-- Keith Ford, Micro Magic, 205-971-9711
-- http://www.magicbbs.com



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

Date: Mon, 09 Mar 1998 16:42:50 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Perl Hash question
Message-Id: <3504625A.787F@min.net>

Gregory Propf wrote:
> 
> I recently wrote a module [...]
> It worked but I
> can't help but think there's a better way.

Why don't you post what you've got, and we'll take a look at it.

John Porter


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

Date: Mon, 9 Mar 1998 20:00:28 GMT
From: "Christian Gilmore" <cgilmore@research.att.com>
Subject: pod2man and solaris catman
Message-Id: <01bd4b9e$52113fa0$6119cf87@vesuvius>

The output of pod2man does not produce what catman expects and hence does
not allow catman to properly index the perl man pages. Those man pages that
are not portions of a module (ie, IO::Socket) are indexed but do not have
the proper section information. Those that are portions of a module have
"NAME" or Header or .IX as their names and .IX as their section according
to windex.

Has anyone found a fix for this apparent brokenness of pod2man?

Regards,
Christian


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

Date: Mon, 9 Mar 1998 20:21:11 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Problem with "goto" in Perl
Message-Id: <EpKJ7B.MBJ@world.std.com>

Uri Guttman <uri@sysarch.com> writes:

>aml@world.std.com (Andrew M. Langmead) writes:
>> 
>> Another example in perl is eval. The function "eval STRING" should be
>> avoided, but "eval BLOCK" is important and useful.

>i disagree. eval STRING is VERY useful to generate closures, fast
>multi-regex subs, and other dynamic code objects. eval BLOCK is mostly
>used for run time error handling. they are very different animals which
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>share the same name (unfortunately)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exactly the point I was trying to make. (Did you notice it was
supposed to be an analogy comparing "goto &subroutine" and 
"goto LABEL" with "eval STRING" and "eval BLOCK")

(except maybe for the "closures" comment. Why not anonymous
subroutines?)

Yes, eval STRING has its uses, (maybe less so than in perl 4, but
there still are uses) but it also has its problems. (like a huge
performance hit each time it is called.) The experienced programmer
can decide if its benefits outweigh its drawbacks. It should be
pointed out to less experienced programmers that "eval BLOCK" and
"eval STRING" are different, and these warnings only apply to 
"eval STRING".

The statement "goto LABEL" has its uses (maybe less so than in other
languages, but there are uses.) but it also has its drawbacks (like
the tendency for the programmer to create un-maintainable code.) The
experienced programmer can decide if its benefits outweigh its
drawbacks.
-- 
Andrew Langmead


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

Date: 9 Mar 1998 21:28:45 GMT
From: Zenin <zenin@best.com>
Subject: Re: Problem with "goto" in Perl
Message-Id: <889479303.359052@thrush.omix.com>

Andrew M. Langmead <aml@world.std.com> wrote:
	>snip<
: The statement "goto LABEL" has its uses (maybe less so than in other
: languages, but there are uses.)

	Show me one, please.  So far I've yet to see a valid use that
	was not brought about by bad or no design.  If there is a valid
	case for it that is not used to fix other code that should have
	been done differently anyway, I'd like to know what it is.

	My understanding is that goto is only kept at all to more easily
	support the s2p/a2p converters and for reverse compatibility with
	(blgh) bad perl3/4 code.

-- 
-Zenin
 zenin@best.com


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

Date: 9 Mar 1998 20:43:05 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Relational arrays
Message-Id: <6e1k8p$heg@news-central.tiac.net>

In article <19980309191001.OAA22333@ladder02.news.aol.com>,
Baboulen <baboulen@aol.com> wrote:
>Hi,
>
>I'm trying to 'connect' two lists.
>
>LIST1

>DISK	PHYSICAL  SIZE  ....
>
>disk1	c0t0d0	  4Go	....
>disk2	c1t0d0	  2Go	....
>disk3	c2t0d0	  2Go	....
>disk4	c3t0d0	  4Go	....
>.....	......	  ...	....

>LIST2
>
>VOL	DISK	.....
>
>name1	disk3	.....
>name2	disk2	.....
>name3	disk3	.....
>.....	.....	.....

In the old days I would have used a set of parallel hashes (associative
arrays) whose names reflected the characteristic recorded in the hash won
whose keys were the disc name.  With perl 5's introduction of references
it's possible to make data structures more complicated than arrays or
hashes.  The techniques are described in the perldsc (perl data strcuture
cookbook) perldata, perlref and perllol (lists of lists) man pages. 

One way to do it might be (without error checking or regard por possible
header lines in the file...)

  while (<LIST1>) {
    ($disk, $physical, $size) = split;

    $info{$disk}{'physical'} = $physical;
    $info{$disk}{'size'} = $size;
  }

  while (<LIST2>) {
    ($vol, $disk) = split;

    $info{$disk}{'vol'} = $vol;
  }

  foreach $disk (sort keys %info) {
    $info = $info{$disk};
     # maybe check entry has all attributes set here...
    printf "some format string\n", $disk, @{$info}{qw/vol physical size/},
  }

(untested pseudo code.)

The @{$info}{qw/vol physical size/} can be written as

  $info->{'vol'}, $info->{'physical'}, $info{'size'}

or 

  $info{$disk}{'vol'}, etc.

The scalar $info contains a copy of one of the "first level" elements of
the hash %info.  Using code similar to that above the values in %foo will
be references to anonymous hashes, so $info->{'key'} is used to retrieve
the values from the anonymous hash for a particular disk.

One way to discover what's going on is to use the debugger and type in
small examples by hand and use X to view them.  The Data::Dumper module
can also help check that what you think perl does and what perl is doing
are the same.

Some people dislike being able to have scalars and hashes with the same
name, I like it.  The manual pages mentioned above should help make this
clear.

This all assumes some reasonbaly recent perl.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 09 Mar 1998 15:44:14 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Relational arrays
Message-Id: <7m637fxd.fsf@news.concentric.net>

baboulen@aol.com (Baboulen) writes:

> I want to join LIST1 and LIST2 on DISK name.
> 
> How should i do ?

I'm going to give you a hint, and I'll suggest that you read
perldata.

   $foo{'blue'}  = 'grosse';

   $bar{'grosse'} = 'formidable';

   print $bar{$foo{'blue'}};

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Mon, 09 Mar 1998 16:52:13 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Relational arrays
Message-Id: <3504648D.7253@min.net>

It's trivially easy if the join key is a single string field.
You create a hash, whose keys are the values of the key field
from each table.  The values of the hash are hashes (by reference)
containing the other fields.

For example:

my %hash; # this will contain all the data, keyed by disk.

for ( @LIST1 ) {
  my( $disk, $physical, $size ) = split;
  $hash{ $disk }{ 'physical' } = $physical;
  $hash{ $disk }{ 'size' } = $size;
  # add the other fields as necessary.
}

for ( @LIST2 ) {
  my( $vol, $disk )= split;
  $hash{ $disk }{ 'vol' } = $vol;
  # add the other fields as necessary.
}

# now go through the hash, printing out each record:
for $disk ( keys %hash ) {
  printf("%5s %5s %6s \n",
    $hash{$disk}{'vol'},
    $hash{$disk}{'disk'},
    $hash{$disk}{'physical'} );
}

Hope this helps,
John Porter


Baboulen wrote:
> 
> I'm trying to 'connect' two lists.
> 
> LIST1
> 
> DISK    PHYSICAL  SIZE  ....
> 
> disk1   c0t0d0    4Go   ....
> disk2   c1t0d0    2Go   ....
> disk3   c2t0d0    2Go   ....
> disk4   c3t0d0    4Go   ....
> .....   ......    ...   ....
> 
> LIST2
> 
> VOL     DISK    .....
> 
> name1   disk3   .....
> name2   disk2   .....
> name3   disk3   .....
> .....   .....   .....
> 
> I want to print a line like :
> 
>         VOL     DISK    PHYSICAL   .....
> 
>         name1   disk3   c2t0d0     .....
>         name2   disk2   c1t0d0     .....
>         name3   disk3   c2t0d0     .....
> 
> I want to join LIST1 and LIST2 on DISK name.


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

Date: 9 Mar 1998 13:28:15 -0800
From: paulb@user2.teleport.com (Paul Buder)
Subject: Re: Stupid Perl file handler limitation!
Message-Id: <6e1mtf$cl3$1@user2.teleport.com>

In <6d70od$tps$1@nnrp1.dejanews.com> li_sen@yahoo.com writes:

>What's up with Perl?  I ran some tests and found that Perl hits a limit of
>about 62 files before it chokes!  That is, I open files until I can't anymore

 ...

>The relevance of this limit is that I can' open more than 60 or so DBM files
>at any one time.  I need more than that for the application I'm writing!

Since no one else mentioned it you need to get BSD::Resource from
CPAN.  It is possible to up the number of descriptors (to 1024 I
think) on Solaris via syscall() and accessing C's setrlimit but the
module is a nice clean way to do it.



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

Date: 9 Mar 1998 15:02:51 -0500
From: jrj@gandalf.cc.purdue.edu (John R. Jackson)
Subject: Re: SWIG, Perl5, valloc() and char * return
Message-Id: <6e1htb$6p6@gandalf.cc.purdue.edu>

With the much appreciated help of a couple of the SWIG folks, I've got
my perl problem under control.

The first thing was my confusion about a %typemap to return a simple
character string.  It's just not needed.

The second was perl dropping core.  That turned out to be fixed by
rebuilding perl **without** the perl provided malloc functions, i.e.
configure it to use the system routines.  Once I did that, the test case
worked fine.

John R. Jackson, Technical Software Specialist, jrj@purdue.edu


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

Date: 9 Mar 1998 20:23:36 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Tom, grow up [Re: The -w switch (was Re: better way to do this?)]
Message-Id: <6e1j48$hmc@news.service.uci.edu>

[mailed, posted]

In article <6e17m9$4kh$1@cyprus.atlantic.net>,
Chip Salzenberg <chip@pobox.com> wrote:
<According to "Eric D. Friedman" <friedman@uci.edu>:
<>Chip Salzenberg <chip@pobox.com> wrote:
<> > I don't expect Tom to get much special treatment in the moderated group.
<>
<> That's not what the charter says.
<
<Sorta.  No individual get special treatment, though one group does.
<
<> It reserves a specific exclusion for the Perl Institute that allows
<> its board (of which Tom is surely a member) to post unmoderated
<> "stuff of possible interest to Perl people."
<
<Yes.  But Tom isn't a special individual here, he's a member of a
<special group (TPI's board).  If the board as a whole disagrees with
<Tom's (or any other individual's) ideas of what's appropriate to post
<in clpmod, the board prevails.

Why can't the independent moderation board be trusted to perform this
function?  Why does TPI's board need a special dispensation to trump an
otherwise straightforward policy forbidding "advertisement or
commercial solicitation of any sort"?

<TPI is a not-for-profit corporation.  It cannot have competitors in
<the traditional sense.  And while TPI's board has special dispensation
<to post articles otherwise not permitted, it does not have editorial
<control over what should be rejected.

A couple of important points here:

1) TPI may be non-profit, but it exists, in part, to circulate
information about the revenue-generating activities of its members
(conferences, publications (books, the journal), and training).  As it
stands, the charter allows the TPI board unfettered and unparalleled
access to consumers of such services, while excluding anyone else
who might like to offer something similar w/o paying TPI dues.

Just to be clear: I like the books and the journal, and I'm sure
all TPI folks are excellent trainers, but if something better
comes along that isn't affiliated with TPI, I'd like it to be
just as easy to hear about that something as about TPI services.

As to Tom's specific involvement: he, his two co-authors, and his
publisher (who *obviously* has a commercial stake in promoting
the "non-profit" TPI-endorsed Perl Conference & O'Reilly books)
form a majority of the TPI board.  I'd be very surprised if any of
these folks voted against posting something that would be in
their financial best interests.

Imagine that Dave Till (just to pick on somebody), his publisher, and a
couple of other SAMS-advocates got majority control of TPI's board.
Would you really want unmoderated "commercials" (that's a quote)
advocating TYP in 21 days/minutes/seconds?

To be perfectly frank, I don't see why TPI has to have this
special dispensation.  Surely comp.lang.perl.announce is a better
forum for announcements, commercial and otherwise.

2) If TPI is to have special status, the distinction Chip describes
should be enforced by including language in the charter that
specifically forbids members of TPI's board from simultaneously serving
as moderators for c.l.p.mod.  Otherwise, you'll be setting the
unfortunate precedent of allowing a person (or persons) with an
interest in one commercial product to overrule the circulation
of news about another.
-- 
Eric D. Friedman
friedman@uci.edu


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

Date: Mon, 09 Mar 1998 20:41:22 GMT
From: sneezy@contax.co.uk (Markus Laker)
Subject: Win32::Internet fails to retrieve files
Message-Id: <35065141.7618985@news.tcp.co.uk>

I'm getting unexpected errors using Aldo Calpini's Win32::Internet
module (version 0.08) with Gurusamy Sarathy's Perl 5.004_02 port under
NT4 SP3.  If I run the following script --

use strict;
use Win32::Internet;

my $Inet = new Win32::Internet;
my $gif = $Inet->FetchURL
	('http://www.hellerindustries.com/images/wehearu.gif');
print $gif;

-- then, instead of a screen full of binary, I see the following error:

<body><h1>HTTP/1.0 406 No acceptable objects were found
</h1></body>

But if I type the same URL into my Web browser, I see the GIF file I'd
expect.  Four other pieces of information: First, if I try to load HTML
files from the same site, they generally work, even though they're often
larger than the GIF files.  Second, Heller's site is thousands of miles
away from here; if I try to load files from my local ISP, everything
works.  Third, changing ISP doesn't make any difference; I get the same
problem with both Dircon and TCP.  Fourth, I've tried using large retry
counts and timeouts and I've tried adding my own retry loops, but it
makes no difference.

So how can I make my code download files as reliably as my Web browser
does?  I'm baffled here; any help would really be appreciated.

Markus



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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.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 2059
**************************************

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