[10391] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3983 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 15 15:07:21 1998

Date: Thu, 15 Oct 98 12:00:26 -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           Thu, 15 Oct 1998     Volume: 8 Number: 3983

Today's topics:
    Re: a camel? <jdporter@min.net>
        Active Perl v5.0 Interpreter <PC16@cafe.ch>
        Active Perl v5.0 Interpreter <PC16@cafe.ch>
    Re: Arrays of UDTs? How to do this? <jdporter@min.net>
    Re: Arrays of UDTs? How to do this? (Fluffy)
    Re: command line regexp replace question <aqumsieh@matrox.com>
    Re: Compile Perl on As400 ? <rootbeer@teleport.com>
    Re: Cool company has Perl jobs! (William D. Reardon)
    Re: Embedding Perl into C (Ken Fox)
    Re: encryption (John Stanley)
    Re: encryption (Michael J Gebis)
    Re: encryption (John Stanley)
        Filehandle with no file? (using GD.pm) (Adam Schneider)
    Re: Filehandle with no file? (using GD.pm) <rootbeer@teleport.com>
    Re: help! trying to emulate server side includes... (Mark Leighton Fisher)
    Re: Implementing an ordered queue <ajohnson@gatewest.net>
    Re: Implementing an ordered queue (Matt Knecht)
    Re: Implementing an ordered queue <rootbeer@teleport.com>
    Re: Implementing an ordered queue (Matt Knecht)
    Re: Implementing an ordered queue (Sam Holden)
    Re: Net::Ping WON'T WORK!!!!! engen@ix.netcom.com
    Re: New to programming - New to Perl - LOST!!!! <mark@uninetwork.com>
    Re: newbie at array parsing (Matthew Bafford)
    Re: newbie at array parsing (Larry Rosler)
    Re: Newbie Loop Help (Matt Knecht)
    Re: Newbie Loop Help <dmitri@sw-systemekarlhickl.de>
    Re: Pelr book or WWW Recources (George)
    Re: Perl object - why does this fail? <dlhawley@user2.teleport.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 15 Oct 1998 14:47:22 -0400
From: John Porter <jdporter@min.net>
Subject: Re: a camel?
Message-Id: <3626433A.4DD2CF60@min.net>

Ed wrote:
> 
> Why are there camels on so many perl pages, and on my O'Rielly book. I
> would consider a mollusk like an Oyster to have more relevance.

What the history pages don't mention is that Larry originally
called the language "Camel", but had to change it when he found
out there was already another language named CAML.

(Wink, nudge, eh.)
(Hmm, what's the emoticon for "nudge"?)

-- 
John "Gashlycrumb" Porter

"A fugitive and lurid gleam
  Obliquely gilds the gliding stream." -- EG


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

Date: Thu, 15 Oct 1998 20:51:33 +0200
From: Surfstation PC16 <PC16@cafe.ch>
Subject: Active Perl v5.0 Interpreter
Message-Id: <36264435.4DBCB024@cafe.ch>

wie lade ich "Active Perl v5.0 Interpreter "hinunter?



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

Date: Thu, 15 Oct 1998 20:53:19 +0200
From: Surfstation PC16 <PC16@cafe.ch>
Subject: Active Perl v5.0 Interpreter
Message-Id: <3626449F.5F2B2BEA@cafe.ch>

wie lade ich "Active Perl v5.0 Interpreter "hinunter?



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

Date: Thu, 15 Oct 1998 14:32:43 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Arrays of UDTs? How to do this?
Message-Id: <36263FCB.2CAFAA3F@min.net>

Abigail wrote:
> 
> Sep has 31 days?

No, 1871 and counting...

-- 
John "San Francisco Earthquake" Porter

"A fugitive and lurid gleam
  Obliquely gilds the gliding stream." -- EG


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

Date: 15 Oct 1998 18:18:41 GMT
From: fluffy@meow.org (Fluffy)
Subject: Re: Arrays of UDTs? How to do this?
Message-Id: <slrn72cf41.nmo.fluffy@fluffy.meow.org>

Zrbj zrbj Abigail zrbj zrbj zrbj abigail@fnx.com zrbj Kitty?

> Sep has 31 days?

The last I checked, we were well into the 1800s.



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

Date: Thu, 15 Oct 1998 12:42:03 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
To: Tim Gray <tgray@smlny.com>
Subject: Re: command line regexp replace question
Message-Id: <Pine.SUN.3.96.981015122502.19487A-100000@newton>

On Thu, 15 Oct 1998, Tim Gray wrote:

    > Hi there
    >     I am trying to remove lines that look like the one below from a bunch of
    > html files.  The only thing that changes is the number after tsld.
    > 
    > <A HREF="tsld005.htm"><IMG SRC="text.gif" BORDER=0 ALT="Text"></A>
    > 
    > perl -pe "print if m/<A HREF=.tsld*A>/ =~ $_;" *.htm

you've got a syntax problem. From perlop:

     Binary "=~" binds a scalar expression to a pattern match.
     Certain operations search or modify the string $_ by
     default.  This operator makes that kind of operation work on
     some other string.  The right argument is a search pattern,
     substitution, or translation.  The left argument is what is
     supposed to be searched, substituted, or translated instead
     of the default $_.  The return value indicates the success
     of the operation.  (If the right argument is an expression
     rather than a search pattern, substitution, or translation,
     it is interpreted as a search pattern at run time.  This is
     less efficient than an explicit search, since the pattern
     must be compiled every time the expression is evaluated--
     unless you've used /o.)

Also, '.' matches any character (except a newline, unless you use /s). The
'*' matches zero or more occurences of the previous character which
happens to be 'd'. This will ALWAYS match zero or more of 'd'!

    > But that ends up printing every line.
    > 
    > So I would imagine that the code I wanted to run
    > 
    > perl -pe "s/<A HREF=.tsld*A>//;" *.htm

 perl -pi.bak -e "s/<A HREF=\042tsld\d+\.htm\042><IMG SRC=\042text\.gif\042 
                  BORDER=0 ALT=\042Text\042><\/A>//g;" *.htm

This will create a backup copy of each of your files and give it an
extension .bak . If you do not want that then remove the '.bak' from the
perl command options. Notice also that I have used the octal
representation of the " character (042).

    > What am I doing wrong?  Thanks.
    > 
    > Tim Gray

You should read some more on regular expressions.

Hope this helps,
--
Ala Qumsieh               email: aqumsieh@matrox.com
ASIC Design Engineer      phone: (514) 822-6000 x7581
Matrox Graphics Inc.      (old) webpage :
Montreal, Quebec          http://www.cim.mcgill.ca/~qumsieh



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

Date: Thu, 15 Oct 1998 18:16:01 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Compile Perl on As400 ?
Message-Id: <Pine.GSO.4.02A.9810151115350.26848-100000@user2.teleport.com>

On Thu, 15 Oct 1998 lars.miettunen@mandator.se wrote:

> Have anyone tried to compile Perl 5.004 or higher on an As400 ?

I'm sure someone has tried. If not, then you should. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 15 Oct 1998 18:39:51 GMT
From: wdr1@pobox.com (William D. Reardon)
Subject: Re: Cool company has Perl jobs!
Message-Id: <F0vt6F.GzF@midway.uchicago.edu>

In article <sarg1crq7n4.fsf@camel.fastserv.com>,
Uri Guttman  <uri@camel.fastserv.com> wrote:
>>>>>> "v" == versuslaw  <versuslaw@my-dejanews.com> writes:
>
>  v> We are an equal opportunity employer based in Redmond, Washington.
>
>too close to hell for me!!
>
>i wonder if they know that perl is being used in such close proximity to
>ground zero.

	According to one of the speakers at the Perl Conference (I'll
let people guess which one), several departments in Microsoft are big
Perl users.

-Bill
-- 
William Reardon	  ----   http://www.nhma.com/~wdr1/   ----   wdr1@pobox.com
    I wish I was the radio song, the one that you couldn't turn up


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

Date: 15 Oct 1998 16:32:55 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Embedding Perl into C
Message-Id: <70583n$orj1@eccws1.dearborn.ford.com>

mdefreitas@sikorsky.com writes:
>    PerlInterpreter *my_perl = perl_alloc();
>    perl_construct(my_perl);
> 
>    int argc = 3;
>    char *argv[] = {"", "-MMyExtension", "script_name"};
> 
>    perl_parse(my_perl, xs_init, argc, argv, env);
>    perl_run(my_perl);
> 
>    perl_destruct(my_perl);
>    perl_free(my_perl);

[Why do so many people like to destroy their freshly created perl
 interpreters?  Should the perlembed pod have a few examples that
 aren't using main()?]

I would try to split out the initialization tasks from the user
script execution tasks.  There are very few reasons several scripts
can't reuse the same interpreter.

Put a helper function in your module to dynamically load and eval
a script, i.e. a wrapper around "do file".  Then you can call this
wrapper when you need to run a script.  Use one of the perl_call
variants.

Also, you can embed your entire module into your C++ program so that
it is a standalone system, i.e. you only have to distribute one
executable.  (This does NOT make the system more secure or hide the
source code.  It only makes it easier to distribute because you don't
have to worry about partial installations and search paths.  It has
the drawback of making the system harder to change because it must
be recompiled if the module changes.)

The new program would look like this:

static PerlInterpreter *my_perl;

void start_embedded_perl() {
   my_perl = perl_alloc();
   perl_construct(my_perl);

   int argc = 2;
   char *argv[] = {"my_perl", "-MMyExtension"};

   perl_parse(my_perl, xs_init, argc, argv, env);
   perl_run(my_perl);
}

void stop_embedded_perl() {
   perl_destruct(my_perl);
   perl_free(my_perl);
}

int run_script(char *filename) {
   dSP;

   char *argv[2];
   argv[0] = filename;
   argv[1] = 0;

   perl_call_argv("MyExtension::run_script", G_DISCARD|G_EVAL, argv);
}

> This works... but only the first time.  When I go through a
> second pass of this code, perl complains ...

I don't know what's causing this.  Possibly your operating system has
loaded the shared library once and fails when it loads it again?  Perl
might interpret this as a failure to load the library.  I think
restructuring your program like I suggested above will improve its
efficiency and eliminate this bug at the same time.

> I do not have constant access to the web, so please email me at:
> mdefreitas@sikorsky.com

You'll want to check DejaNews for the entire thread because lots of
people won't mail you directly.  Summarizing the mail you get is a
polite way of re-paying the people who took the time to help you.

- Ken

-- 
Ken Fox (kfox@ford.com)                  | My opinions or statements do
                                         | not represent those of, nor are
Ford Motor Company, Powertrain           | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section             | "Is this some sort of trick
                                         |  question or what?" -- Calvin


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

Date: 15 Oct 1998 17:21:33 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: encryption
Message-Id: <705aut$650$1@news.NERO.NET>

In article <703edd$1h6@mozo.cc.purdue.edu>,
Michael J Gebis <gebis@fee.ecn.purdue.edu> wrote:
>Orlando:
>Do you want to encrypt and decrypt data?  "use Crypt::DES;"

DES has been broken. 

>Do you want to perform a message digest?  "use SHA;"

I used SHA to create a message digest once. It was unreadable. I'll
stick with the code I already have to create the digest. At least you
can read the articles. (Yeah, I know, the crypt folks have picked
"message digest" even though that term was already being used. It's a
handy way to create confusion when they could have used a different term
(like "hash") that would not have.)

>All other answers are misleading, wrong, difficult, or just plain
>dangerous.  Using "crypt" to produce a message digest is so dumb it
>hurts.

I would say that using an encryption system that has recently been
broken in a new application is so dumb it hurts. But that would only be
if I wanted to insult you. 

What I will say is that "there is more than one way to do it." That used
to be a Positive Thing in this group. 



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

Date: 15 Oct 1998 17:54:29 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: encryption
Message-Id: <705csl$qgg@mozo.cc.purdue.edu>

stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
}In article <703edd$1h6@mozo.cc.purdue.edu>,
}Michael J Gebis <gebis@fee.ecn.purdue.edu> wrote:
}>Orlando:
}>Do you want to encrypt and decrypt data?  "use Crypt::DES;"
}DES has been broken. 

}>Do you want to perform a message digest?  "use SHA;"
}I used SHA to create a message digest once. It was unreadable. I'll
}stick with the code I already have to create the digest. At least you
}can read the articles. (Yeah, I know, the crypt folks have picked
}"message digest" even though that term was already being used. It's a
}handy way to create confusion when they could have used a different term
}(like "hash") that would not have.)

Ironically, I was going to use "hash" but since that term is
overloaded in this newsgroup, I opted for something else.  But this is
aside from the point.

}>All other answers are misleading, wrong, difficult, or just plain
}>dangerous.  Using "crypt" to produce a message digest is so dumb it
}>hurts.

}I would say that using an encryption system that has recently been
}broken in a new application is so dumb it hurts. But that would only be
}if I wanted to insult you. 

If you wanted to insult me, you could also delete the part where I
advised reading Schneier to evalute which cipher system to use.

DES isn't really "broken" except that it has a fatally short key
space.  But so does "crypt."  

How many 8-character passwords are there?  Let's say somewhere
around (26+26+10+10)^8, or 722204136308736.  How many keys does DES
have?  Somewhere around 2^56, aka 72057594037927936.  That's around
1:100. 

You're right, that DES is probably not as secure as it could be, but
what are the alternatives?  There's Crypt::IDEA, which may or may not
be skating on shaky legal ground in Euorpe.  There are other choices,
but they have trade-offs that really require careful evaluation.  So
let me state again: Orlando, pick up Schneier.

}What I will say is that "there is more than one way to do it." That used
}to be a Positive Thing in this group. 

Sure there is more than one way to do it.  I'd advise picking one of
proven ways, though.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: 15 Oct 1998 18:21:27 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: encryption
Message-Id: <705ef7$d24$1@news.NERO.NET>

In article <705csl$qgg@mozo.cc.purdue.edu>,
Michael J Gebis <gebis@fee.ecn.purdue.edu> wrote:
>}I would say that using an encryption system that has recently been
>}broken in a new application is so dumb it hurts. But that would only be
>}if I wanted to insult you. 
>
>If you wanted to insult me, you could also delete the part where I
>advised reading Schneier to evalute which cipher system to use.

I'm sorry that you feel insulted by the standard practice of eliding
what was not being replied to. I was replying specifically to your
instructions to use SHA or DES.

>DES isn't really "broken" except that it has a fatally short key
>space.  But so does "crypt."  

I have seen reports describing the hardware to decypher DES messages
using 56 bit key spaces. Seven hours, wasn't it? Or was it three?
That's what most people would call "breaking" a cypher. That's how
David Kahn used the term in his book "The Code Breakers".

The only "breaking" of crypt I have seen is by exhaustive searches. If
it was being done, you would expect that Crack would use it.



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

Date: Thu, 15 Oct 1998 12:26:46 -0500
From: NO_SPAM_acs@bitstream.net (Adam Schneider)
Subject: Filehandle with no file? (using GD.pm)
Message-Id: <NO_SPAM_acs-1510981226460001@port302.bitstream.net>


Can I create a filehandle that never reads from or writes to an actual file?
I need a filehandle that just contains some data that I put into it.

Why?  Because I'm using GD.pm.  To open a GIF image, I use this function:

   GD::Image::newFromGif(FILEHANDLE);

In practice, it usually looks like this:

   open (GIF,"picture.gif");
   $picture = newFromGif GD::Image(GIF);
   close (GIF);

However, the GIF I'm getting is coming from the Web, using LWP::Simple. 
So the entire contents of that GIF will be in a plain old variable, not a
filehandle.  How can I get that data into GD's routines without making a
temporary file?

Thanks in advance,

Adam


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                Adam Schneider * Minneapolis, Minnesota, USA
                      E-mail: schneider "at" pobox.com
                 WWW: http://pobox.com/~schneider/adam.html


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

Date: Thu, 15 Oct 1998 18:25:06 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Filehandle with no file? (using GD.pm)
Message-Id: <Pine.GSO.4.02A.9810151122440.26848-100000@user2.teleport.com>

On Thu, 15 Oct 1998, Adam Schneider wrote:

> Can I create a filehandle that never reads from or writes to an actual
> file?

Yeeeeesssss.... Maybe you want to open it on /dev/null? :-)

> I need a filehandle that just contains some data that I put into it.

You can do that with a tied filehandle.

> Why?  Because I'm using GD.pm.  To open a GIF image, I use this
> function:
> 
>    GD::Image::newFromGif(FILEHANDLE);
> 
> In practice, it usually looks like this:
> 
>    open (GIF,"picture.gif");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

>    $picture = newFromGif GD::Image(GIF);
>    close (GIF);
> 
> However, the GIF I'm getting is coming from the Web, using
> LWP::Simple.  So the entire contents of that GIF will be in a plain
> old variable, not a filehandle.  How can I get that data into GD's
> routines without making a temporary file?

If the most recent version of the module doesn't already provide a way to
do this, you should send a patch to the module's author implementing that
feature. :-)  Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 15 Oct 1998 13:04:54 -0500
From: fisherm@tce.com (Mark Leighton Fisher)
Subject: Re: help! trying to emulate server side includes...
Message-Id: <MPG.10900352721722f798969c@news-indy.indy.tce.com>

In article <36255b66.6367114@news.usit.net>, cstanley@SPAMSUCKSusit.net 
says...
> i am running a script that parses and displays html pages.  the only
> problem is, it doesn't emulate server side includes which i use
> heavily.

Take a look at Text::MetaText in CPAN.  It provides you all sorts of 
capabilities, enough so that I am now developing a Web where both static 
pages (incorporating all sorts of includes) and CGIs are generated (and 
kept in sync on look+feel) using Text::MetaText (thanks Andy!).

CPAN is your friend -- learn to use it. 
==========================================================
Mark Leighton Fisher          Thomson Consumer Electronics
fisherm@indy.tce.com          Indianapolis, IN
"Browser Torture Specialist, First Class"


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

Date: Thu, 15 Oct 1998 12:23:37 -0500
From: Andrew Johnson <ajohnson@gatewest.net>
Subject: Re: Implementing an ordered queue
Message-Id: <36262F99.1FB9E57B@gatewest.net>

Matt Knecht wrote:
!
! I need to create a sorted queue in real time.  I'll be sorting on Unix
! timestamps.  The data will come in arbitrary order, and I need to keep
! my queue in strict chronological order (So I can always pluck the
! oldest record off the end).
! 
! In C, I'd implement this as a doubly linked list, or perhaps a Btree.
! Trying to implement this in Perl is giving me headaches, though.  Using
! a hash for each node, and having a reference to another is pretty slow
! (I'd like this to be as fast as possible, while still keeping it in
! Perl).

You can use a heap as a basis for a priority queue, it isn't
strictly ordered, but partially ordered with the largest (or smallest
depending on how you've constructed it) element always at the top.
There is a Heap.pm module on CPAN I believe ... if not, they are not
terribly difficult to implement just using an array. Any intro
algorithm/datastructure text should cover this type of thing. I'd
recommend 'Introduction to algorithms' by Cormen, Leiserson, and
Rivest (1990) [MIT press] (see chapter 7).

hope that helps
regards
andrew


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

Date: Thu, 15 Oct 1998 17:46:21 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Implementing an ordered queue
Message-Id: <NxqV1.8929$wV1.5889624@news2.voicenet.com>

Andrew Johnson <ajohnson@gatewest.net> wrote:
>You can use a heap as a basis for a priority queue, it isn't
>strictly ordered, but partially ordered with the largest (or smallest
>depending on how you've constructed it) element always at the top.
>There is a Heap.pm module on CPAN I believe ... if not, they are not

Sounds good; I'll take a look at it.

>terribly difficult to implement just using an array. Any intro
>algorithm/datastructure text should cover this type of thing. I'd

Keeping this in an array is a poor choice.  Inserting an element would
require shuffling all array elements back a step.

I will *not* receive records in the correct order.  This is *not* a FIFO.

Using a large, sparse array is a poor choice (I think) because then I'd
have to worry about fragmentation.  I'd rather not re-invent malloc. :)

>recommend 'Introduction to algorithms' by Cormen, Leiserson, and
>Rivest (1990) [MIT press] (see chapter 7).

This just makes me wish I had a proper library at work. :(

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: Thu, 15 Oct 1998 18:15:04 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Implementing an ordered queue
Message-Id: <Pine.GSO.4.02A.9810151113570.26848-100000@user2.teleport.com>

On Thu, 15 Oct 1998, Matt Knecht wrote:

> Keeping this in an array is a poor choice.  Inserting an element would
> require shuffling all array elements back a step.

splice() is pretty efficiently implemented. You may be right, that this
would be a poor choice for your problem. But how can you be sure until you
see how long it takes to run?

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 15 Oct 1998 18:18:52 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Implementing an ordered queue
Message-Id: <g0rV1.8938$wV1.5911769@news2.voicenet.com>

Tom Phoenix <rootbeer@teleport.com> wrote:
>On Thu, 15 Oct 1998, Matt Knecht wrote:
>
>> Keeping this in an array is a poor choice.  Inserting an element would
>> require shuffling all array elements back a step.
>
>splice() is pretty efficiently implemented. You may be right, that this
>would be a poor choice for your problem. But how can you be sure until you
>see how long it takes to run?

I can't be.  I'm trying to narrow down the many choices I seem to have
before I start testing.  The more answers I get here, the less (unpaid)
overtime I have to put in over the weekend. :)

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: 15 Oct 1998 18:51:13 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Implementing an ordered queue
Message-Id: <slrn72ch10.re8.sholden@pgrad.cs.usyd.edu.au>

On Thu, 15 Oct 1998 17:46:21 GMT, Matt Knecht <hex@voicenet.com> wrote:
>Andrew Johnson <ajohnson@gatewest.net> wrote:
>>You can use a heap as a basis for a priority queue, it isn't
>>strictly ordered, but partially ordered with the largest (or smallest
>>depending on how you've constructed it) element always at the top.
>>There is a Heap.pm module on CPAN I believe ... if not, they are not
>
>Sounds good; I'll take a look at it.
>
>>terribly difficult to implement just using an array. Any intro
>>algorithm/datastructure text should cover this type of thing. I'd
>
>Keeping this in an array is a poor choice.  Inserting an element would
>require shuffling all array elements back a step.

A heap is partially ordered so inserting an element requires O(log n) swaps
of elements in the array, there is no shuffling of all the array elements.

-- 
Sam

comments on data are usually much more helpful than on algorithms
	--Rob Pike


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

Date: Thu, 15 Oct 1998 18:15:13 GMT
From: engen@ix.netcom.com
To: ratner@vaix.net
Subject: Re: Net::Ping WON'T WORK!!!!!
Message-Id: <705e3h$d9q$1@nnrp1.dejanews.com>

I am having a similar problem with the Net::Ping module. I am using version
5.004_04 on a Linux system. It does not work when trying to ping Linux or
Windows systems from a Linux machine. It does work, however, when pinging
Solaris X86 and HP/UX machines. Very strang indeed. I tried various timeouts
without success. All of these machines are actually up and pingable from the
command line. Any help would be greatly appreciated.

Here is my short script:

#!/usr/local/bin/perl -w use Net::Ping; $timeout = 10; @hosts = qw(  cyssr2 
ipe2  mustang  firebird  ); foreach $hosts (@hosts) {  if (pingecho($hosts,
$timeout)) {  print "$hosts is alive\n";  }else{  print "$hosts is down\n"; 
open MAIL, '|mail -s "WARNING, system is not responding" matt';  print MAIL
"$hosts is down";  close MAIL;	}; };


In article <3624E90E.BB29B7F7@tiuk.ti.com>,
  Alex Davies <Alex.Davies@tiuk.ti.com> wrote:
>
> Peter,
>
>    I've never had any problems with this module... i presume from your mention
> of protocols that you are using the most recent version of Net::Ping. Can you
not
> just use
> the (old) pingecho method...? Some thing like this should work fine:
>
> use Net::Ping;
> my $node = 'xyz';
> if (pingecho($node, 2)) {
>   print "$node is responding\n";
> }
> else {
>   print "$node is NOT responding...\n";
> }
>
>      What was the exact error message you were getting, also which version of
perl
>
> are you running?
>
> alex.
> _________________________________________________________________________
>
> Alex Davies, MOS Design,               Email:  Alex.Davies@tiuk.ti.com
> Texas Instruments Limited,
> 800 Pavillion Drive,                   Tel (work):  01604 663450
> Brackmills Industrial Estate,              (home):  01604 764961
> Northampton, NN4 7YL.
> U.K.
>
> Peter J Ratner wrote:
>
> > I've tried to use Net::Ping in my programs, but I can't seem to get it
> > to work right! For some reason, no matter what protocol I use, the
> > server never responds (yes, I've tried MANY different servers) . I am
> > using the sample script given in the module itself, not one of my own
> > design, so there's no reason why it shouldn't work. I tried running it
> > on both MacPerl and Unix. On MacPerl, no response from server, on Unix,
> > it gives an error regarding Socket.pm and how some arguement should have
> > the value 16 rather than 0.
> >
> > If anyone has had success with this module, I'd greatly appreciate
> > seeing the source or getting some input as to how to get it to work.
> >
> > You can contact me at ratner@vaix.net .
>
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 15 Oct 1998 13:55:09 -0400
From: Mark Cain <mark@uninetwork.com>
Subject: Re: New to programming - New to Perl - LOST!!!!
Message-Id: <362636FD.AB350249@uninetwork.com>

There is a more recent version of Active State than 502.

Mark Cain

Michal Rutka wrote:

> "Tim Hicks" <tim.hicks@lineone.net> writes:
> [...]
> > To conclude, all I really want to do is install perl under win 95 and play
> > around and see what I can do.  If anyone could point me in the right
> > direction I'd really appreciate it.
>
> point your browser on http://www.ActiveState.com/ActivePerl/ and try to
> get APi502e.exe. This will install you perl on a win32 system.
>
> Michal



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

Date: Thu, 15 Oct 1998 13:11:31 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: newbie at array parsing
Message-Id: <MPG.108ff6d14c6158469896db@news.scescape.net>

[This followup was posted to comp.lang.perl.misc and a copy was sent 
to the cited author.]

In article <<MPG.108fc76a82b35b069898bb@nntp.hpl.hp.com>>, 
lr@hpl.hp.com (Larry Rosler) pounded the following:
=> In article <u7ly197xm.fsf@vansel.alcatel.com> on 15 Oct 1998 08:11:17 -
=> 0700, Brad Murray <murrayb@vansel.alcatel.com> says...
=> ! "Marcus J. Foody" <marx@idiom.com> writes:
=> ! > |BUSINESS UNIT #709|REC BATCH|19980707|709|HPC INVOICE
=> ! > MEMOS|INVOICE|3|USD|5500.00
=> ! 
=> ! I think you want to look at the man page for split.  I would, for 
=> example,
=> ! use this (assuming $line is set to the above):
=> ! 
=> ! @record = split /\|/, $line;
=> ! $field = "|$record[5]|";
=>                      ^
=>                      3
                        ^
                        4

We'll get there eventually. ;-)

Notice the leading |...

--Matthew :)


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

Date: Thu, 15 Oct 1998 11:19:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie at array parsing
Message-Id: <MPG.108fdc7eed90cd0c98980f@nntp.hpl.hp.com>

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

In article <MPG.108ff6d14c6158469896db@news.scescape.net> on Thu, 15 Oct 
1998 13:11:31 -0400, Matthew Bafford <dragons@scescape.net> says...
! lr@hpl.hp.com (Larry Rosler) pounded the following:
! => Brad Murray <murrayb@vansel.alcatel.com> says...
! => ! "Marcus J. Foody" <marx@idiom.com> writes:
! => ! > |BUSINESS UNIT #709|REC BATCH|19980707|709|HPC INVOICE
! => ! > MEMOS|INVOICE|3|USD|5500.00
! => ! 
! => ! I think you want to look at the man page for split.  I would, for
! => ! example, use this (assuming $line is set to the above):
! => ! 
! => ! @record = split /\|/, $line;
! => ! $field = "|$record[5]|";
! =>                      ^
! =>                      3
!                         ^
!                         4
! 
! We'll get there eventually. ;-)
!
! Notice the leading |...

Oops.  My shortest posting ever (two characters plus white space) and I 
didn't test it!  <SOUND>slap on self wrist</SOUND>

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


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

Date: Thu, 15 Oct 1998 17:16:22 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Newbie Loop Help
Message-Id: <G5qV1.8927$wV1.5884692@news2.voicenet.com>

Erik A Belknap <ebelknap@runet.edu> wrote:
> if ($valid) {
>   open (INFILE, $infile) || die ("You Suck");

Perhaps your die would be more useful as 'die "$0: open $infile: $!"'.

>   chop($line = <INFILE>);

Use chomp, not chop.

>   while ($line =~ /[#^]/ || $line eq "") {

This is only working one a single line.  No need for a while.

>    chop($line = <INFILE>);
>   }
>   @data = split(/ /, $line);
>   @ip = split(/\./, $data[0]);
>    if ($ip[2] eq $input{subnetnumber}) {
>     print "$data[0]<BR>";
>    }

Try this instead:

# NOT TESTED
if ($vaild) {
    local @ARGV = qw/ $infile /;

    # Magic open :)
    while (<>) {
	chomp;
	next if /^[\s#]*$/; # Skip comment and blanks

	my @data = split;
	my @ip   = split /\./, $data[0];

	print "$data[0]<BR>" if $ip[2] eq $input{subnetnumber};
    }
}

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: Thu, 15 Oct 1998 19:26:05 +0200
From: Dmitri Levitin <dmitri@sw-systemekarlhickl.de>
Subject: Re: Newbie Loop Help
Message-Id: <3626302D.2A3B2F9D@sw-systemekarlhickl.de>

Erik A Belknap wrote:

> Hi I have a problem getting this program to read the entire data file:
> I took out the loop it runs but the it needs to read the 9500 lines of a
> data file.  The lines consist of comments and blank lines.  How do I get
> it to loop until end of file.  I tried the eof and didnt get it to work.
> I tried the $line eq "" and that exits the loop when it finds a blank
> line.  Please help I am just getting started with perl and this doesnt
> seem that hard of a task but I cant find any other resources.  Here is the
> code I have that works:
>
>  if ($valid) {
>    open (INFILE, $infile) || die ("You Suck");
>    chop($line = <INFILE>);
>    while ($line =~ /[#^]/ || $line eq "") {
>     chop($line = <INFILE>);
>    }

Everything what you need to read a file line by line till the end
is:open(INFILE, $infile) || die "cannot open: $!";
while($line = <INFILE>) {
    chop $line;
    ... # what you ever wanted to do
}

>    @data = split(/ /, $line);
>    @ip = split(/\./, $data[0]);
>     if ($ip[2] eq $input{subnetnumber}) {
>      print "$data[0]<BR>";
>     }
>
> thanks in advance!
> Erik ebelknap@runet.edu

  see perldoc perlop, perlfunc

Dmitri



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

Date: Thu, 15 Oct 1998 17:34:27 GMT
From: george9684@my-dejanews.com (George)
Subject: Re: Pelr book or WWW Recources
Message-Id: <36263213.11993197@news.uniserve.com>

On 11 Oct 1998 22:11:05 -0500, "Ben Prater" <bprater@jipes.com> wrote:

>I certainly enjoyed 'Perl 5 Interactive'. I think it's definately simple
>enough for a beginner.
>
>Ben
>
>
>George wrote in message <3621619d.22548613@news.uniserve.com>...
>>I have read books from our local library about perl. They are geared
>>for people who have experience in programming in other languages and
>>certain assumptions are made.
>>Could someone please suggest a good book that explains from the ground
>>up OR are there recources on the www that I could access and study?
>>Thank you
>>george9684@my-dejanews.com
>
>
Thanks for the help :)
Thank you 
george9684@my-dejanews.com


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

Date: Thu, 15 Oct 1998 18:50:36 GMT
From: "David L. Hawley" <dlhawley@user2.teleport.com>
Subject: Re: Perl object - why does this fail?
Message-Id: <0urV1.1676$es1.891223@news.teleport.com>

Larry Wall <larry@kiev.wall.org> wrote:
: In article <701c3g$637$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> wrote:
: >The other way to solve the `strict' problem is to write this:
: >
: >	use vars '@ISA';
: >
: >That tells `strict' that `@ISA' is exceptional and that you mean to
: >use it as a global variable.

: Another way is to set @ISA before declaring 'use strict'.

: In 5.006 we're planning to support

:     our @ISA = qw(bb);

: to do the same thing as 'use vars', only with a syntax like "my".

After reviewing this thread I don't feel so bad about making this mistake
- just loosing a bunch of time. Hopefully some of the nits will be more
clearly documented in future OO examples.

-- 
David L. Hawley       D.L. Hawley and Associates    1(503)274-2242
Software Engineer                            dlhawley@teleport.com 


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

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

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