[6837] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 462 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 12 19:17:12 1997

Date: Mon, 12 May 97 16:00:27 -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           Mon, 12 May 1997     Volume: 8 Number: 462

Today's topics:
     Re: [Q] Getting the pid of an execed process. (Andrew M. Langmead)
     Re: adding to an array within a while(<>) (sdm)
     Best way to include one script in another <boris@dailyrocket.com>
     Re: Break command? (Even Holen)
     Re: Break command? (Tad McClellan)
     Re: CGI help! (Michael Fuhr)
     Re: control-M makes for very long $_ (Abigail)
     dbf database files and perl <pdenman@ims.ltd.uk>
     Re: double expansion <LRL@psuvm.psu.edu>
     Re: Dups in a array.. how to clear? <jong@mrc-lmb.cam.ac.uk>
     Re: Freelance programmers needed (Matthew Burnham)
     Re: Grep weather info. <rootbeer@teleport.com>
     Help getting Syslog.pm to work (Bernard Cosell)
     how do I get a binary representation of a number in a s <tpo9617@rit.edu>
     Re: how do I get a binary representation of a number in <tpo9617@rit.edu>
     Re: how to get a recursive file listing <billc@tibinc.com>
     Re: if (condition) always testing true (John Nolan)
     Installing Perl 5.003 <trobison@erols.com>
     Re: Learning PERL (Clay Irving)
     Memory Clearing <Torsten.Naumann@informatik.tu-chemnitz.de>
     Need help on initializing a perl array (MAY DAY) !!!!! <masroor@bga.com>
     Re: Need help on initializing a perl array (MAY DAY) !! (brian d foy)
     Network management with Perl <eric@ecrampto.async.vt.edu>
     Re: Perl auto-replier (David Combs)
     Perl Script Authors!!  Please Read!! (Steve Heintz)
     perl/cgi help - need current date function (Peter Wood)
     printer <eglamkowski@mathematica-mpr.com>
     Re: private scalar for each instance of an object? <rootbeer@teleport.com>
     problems trying to build libwww-perl-5.07 <sheadley@cyberramp.net>
     Re: program for perl? <rosie@dozyrosy.demon.co.uk>
     sendmail script <an745@traverse.lib.mi.us>
     Seraching Large Files <toml@synnet.com>
     Re: speeding up a regex <usenet-tag@qz.little-neck.ny.us>
     Re: standards (Bob Wilkinson)
     Re: STRAW POLL: RFD: comp.lang.perl reorg (Dominic Dunlop)
     Re: telnet client (Mike Stok)
     Re: winword 6/7 (Clay Irving)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 10 May 1997 11:59:06 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: [Q] Getting the pid of an execed process.
Message-Id: <E9yryJ.7GA@world.std.com>

andrew@ugh.net.au (Andrew) writes:

>I fork my perl script and have the child exec. I have the PID of the child
>but exec gives a new PID to the execed process (I want to send a kill to
>the process later).

exec(), the system call does not change the PID. It overlays a new
program over the current PID.

The problem that you may be having, is that if you say "exec SCALAR",
and the scalar contains shell metacharacters, then perl will pass it
to /bin/sh to parse. Perl then overlays /bin/sh over your forked
process, and /bin/sh calls the program you wanted to run as a child
processes.

Take out all the shell metacharacters, do any shell redirection or
stuff yourself, and the PID that the program will be run in, is the
PID which you forked.

-- 
Andrew Langmead


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

Date: 10 May 1997 03:17:26 GMT
From: sdm@red.seas.upenn.edu (sdm)
Subject: Re: adding to an array within a while(<>)
Message-Id: <5l0pc6$kuc@netnews.upenn.edu>

Devin Ben-Hur (dbenhur@egames.com) wrote:
: [mail&post]
: sdm wrote:
: > Is there a way to easily add to an @array each pass through a while() loop,
: > without the next pass obliterating what was there on the previous pass?
: > Everything I find in my books seem to bypass/overlook this.....

: I think you have some fundamental misconception about
: how arrays are manipulated or how while works.
: Look up the functions push() and unshift() for convenient
: ways to extened an array (at either end).

Hmm, a lot of people said I had a fundamental misconception to how
things work, which isn't really true, and that I should read the faq,
which I did (and my books), and to use push(), which I was doing.
Maybe I should have posted my (erroneous) code. 
Sorry for the newbie sounding question, when in fact I 
was doing everything right except one thing; I was obliterating
the whole array, each time through the while loop, so even though
I was pushing each time, I was creating a new array each time, with
splice(). oooops. Problem fixed. 
Maybe all your posts saying 'you don't understand something very basic'
got me so riled up that I tore apart the code and weeded out
mindless errors that pop up every once in a while... :)

 ..-..-..-..-..-..-..-..-..-..-..-..-..-..-..-..-..-..-..-..-..-..-..-..-..- 
steve.m.
Unix Pronounciation Guide       http://www.pobox.com./~sdm/unix/
Research Associate              Penn netnews junkie             \ /
GTELabs                         Tufts undergraduate             [o]
superpages project              engineering psychology dept.     |
http://superpages.gte.net       "That drone from sector 7g"     _|_
! Set this to false to disable the <BLINK> tag.
*blinkingEnabled:		True


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

Date: Mon, 12 May 1997 09:06:42 -0700
From: Boris Burtin <boris@dailyrocket.com>
Subject: Best way to include one script in another
Message-Id: <33774012.BB69BB7@dailyrocket.com>

I'd like to hear some suggestions about using "include files" in Perl. 
In C, you can say

#include "myfile.h"

and myfile.h will be inserted into that location, as if it was part of
the same file.  Is there a similar trick you can pull in Perl?  The
closest thing I've been able to find is to create a module, but that
seems like overkill to me.

Here's my reasoning:  I have a set of CGI scripts which share common
subs and config variables.  I'd like to place the global variables and
subs all in one place.

If this is a FAQ, please refer me to the appropriate URL.

Thanks in advance,

Boris


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

Date: 10 May 1997 11:04:54 GMT
From: evenh@bigblue.pvv.ntnu.no (Even Holen)
Subject: Re: Break command?
Message-Id: <slrn5n8lim.h8m.evenh@bigblue.pvv.ntnu.no>

In article <E9xAx1.M4n@nonexistent.com>, Jacob Salomon wrote:
>I did this all to experiment with the 'break' command, which is
>available in awk.  I could not find 'break' in the index of the perl
>book I'm using to learn.  The break command above did not incur a
>compile error but neither did it break me out of the loop; it continued
>to accept input until I entered an empty line.
>
>Am I misusing the break command?  How would I leave a loop if not with
>break? (Please don't suggest goto.)

As Paul D. Smith has already given you notice of so is 'break' a
reserverd word, but not used. In addition to the 'last' keyword which
exits the current loop, you also do have 'next' which skips to next
round of the loop...

Do test the following to see the difference:

#!/usr/bin/perl

print "Some counting: ";
for (1..10) {
   next if ($_ == 3);
   last if ($_ == 7);
   print "$_...";
}
print "\n";

Regrads,
Even Holen
-- 
<><   Even Holen, evenh@pvv.ntnu.no, http://www.pvv.ntnu.no/~evenh/   :-)


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

Date: Fri, 9 May 1997 14:22:15 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Break command?
Message-Id: <7htvk5.8n6.ln@localhost>

Jacob Salomon (jake@apparel.net) wrote:


: I did this all to experiment with the 'break' command, which is
: available in awk.  I could not find 'break' in the index of the perl
: book I'm using to learn.  The break command above did not incur a
: compile error but neither did it break me out of the loop; it continued
: to accept input until I entered an empty line.

: Am I misusing the break command?  How would I leave a loop if not with
: break? (Please don't suggest goto.)


s/break/last/;  # see 'last' in the perlfunc man page


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 12 May 1997 16:07:18 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: CGI help!
Message-Id: <5l84am$j0f@nova.dimensional.com>

Andrew Lin <lin.293@postbox.acs.ohio-state.edu> writes:

[ snip ]

> I would really appreciate it if someone here could either:
>
> A. offer a suggestion as to what the problem is
>
>          or
>
> B. redirect me to a more accurate newsgroup.  I know this is a perl
> newsgroup but I figured someone here must know something since perl is
> such a popular CGI language.

print $query->redirect("news:comp.infosystems.www.authoring.cgi");

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: Mon, 12 May 1997 21:47:00 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: control-M makes for very long $_
Message-Id: <EA38ID.D94@nonexistent.com>

On Mon, 12 May 1997 14:30:07 -0700, Tom Lewis-Flood wrote in
comp.lang.perl.misc URL: news:33778BDF.3506@elsevier.com:
++ I'm debugging someone's perl cgi script and I hardly know perl, so here
++ it goes:
++ 
++ 1. I look at a file with less and I see control-Ms where I would expect
++ to see newlines. I presume this is because the file was created with
++ DOS.
++ 
++ 2. The script is supposed to print the file between html <PRE> tags.
++ When the script says, 
++     while  (<FILEHANDLE>) {
++         print;
++     }
++ and nothing comes out, but when I change the file with the commandline,
++ 	perl -p -i -e 's#^M#\n#g' filename.txt
++ it outputs the file properly.
++ 
++ 3. I've tried things like,
++     s#\cM#\n#g;
++     while  (<FILEHANDLE>) {
++         print;
++     }
++ but it doesn't seem to change a thing.

The s#\cM#\n#g; doesn't do a thing here because you haven't put
anything in $_ yet.

What you want is change the record separator (default a newline).
Try:

   $/ = "\cM";  # Treat ^M as the record (line) separator.
   while (<FILEHANDLE>) {
       print;   # Prints ^M terminated lines.
   }


Abigail


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

Date: Mon, 12 May 1997 16:44:32 +0100
From: "Paul Denman" <pdenman@ims.ltd.uk>
Subject: dbf database files and perl
Message-Id: <01bc5eeb$2329d1c0$9d02a8c0@192.168.2.1.ims.ltd.uk>

Does anyone know how compatible Perl is with .dbf database files?
Has anyone worked with them before? Will I need a module written
especially to handle .dbf files (I think foxpro uses .dbf files).

Regards,

Paul Denman
pdenman@ims.ltd.uk


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

Date: Thu, 8 May 1997 08:53:44 EDT
From: Linda Littleton <LRL@psuvm.psu.edu>
Subject: Re: double expansion
Message-Id: <97128.085344LRL@psuvm.psu.edu>

Thanks to all of you who told me what I wanted to do does work.
Apparantly my problem is I'm using perl 4. Any way to do it there?

> I want to do something I think of as double expansion or double
> interpretation. For example, in this code snippet:

> $a = "hello";
> $b = "a";
> print ${ $b };

> I want the print to print out "hello" - so first the $b in the brackets
> would be evaluated to "a", then "print $a" would be done, resulting in
> "hello" being printed. Is there a way to do this sort of thing in perl?


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

Date: Sat, 10 May 1997 10:53:28 +0100
From: Jong <jong@mrc-lmb.cam.ac.uk>
Subject: Re: Dups in a array.. how to clear?
Message-Id: <33744598.41C6@mrc-lmb.cam.ac.uk>

Bill Cowan wrote:
> 
> Ray McVay wrote:
> >
> > Tony Reeves wrote:
> > >
> > > I have a large arrray..
> > > @ALLUSERS - about 9,000 records.
> > >
> > > I'd like to know a simple way to remove any duplicates that might be in the
> > > file. that is if the file has:
> > >
> [SNIP]
> > Well yes, grep works. ;-)  I'd just throw the lot of 'em into a hash and
> > let IT do the dirty work.
> 
> One approach is:
> 
>         my @InputArray = (0,0,1,2,0,3,4,2,5);
>         my @OutputArray = ();
>         my %TmpHash     = ();
> 
>         #-- Remove duplicate entries from an array.
>         @OutputArray = grep((++$TmpHash{$_} == 1), @InputArray);
>         print join(',', @OutputArray), "\n";
> 
> prints:   0,1,2,3,4,5
> 
> -- Bill
>

or      @nondup = grep { ! $duplicate{$_}++ } @orig;    ## NOTE -> $_

  
Jong


 -----------------------------------------------------------------------
> Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
> Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707

-- 
 I support Perl, Linux ...

With OVER SIX MILLION USERS, up from only ten or so a very few years
ago, Linux has taken it's place as the world's #3 computer operating
system overall. And Linux is breathing down the neck of #2 for very good
reasons. If growth rate to date continues, Linux will be the #1 computer
operating system by late '98 or '99. Are YOU ready?

	  ) Linux Newsletter

http://www.smli.com/people/john.ousterhout/scripting.html


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

Date: Sat, 10 May 1997 09:42:53 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: Freelance programmers needed
Message-Id: <337655c9.4179577@194.72.192.4>

"." <abc55@dial.pipex.com> wrote:

>I'm looking to make contact a.s.a.p. with expert programmers of
>Perl, C++, Java and Javascript for a variety of Internet projects.
>
>I'm particularly looking for prgrammers residing in London, U.K. but I
>would be interested to hear from anyone able to telework on a flxible
>basis.
>
>Please send details of your skills and daily rates to
>abc55@dial.pipex.com

I'm in Nottinghamshire, and willing to telework for you. I have quite a
bit of experience with Perl, although I'm still at college (doing a
computer course).


-- 
Matthew Burnham, Manager, MindWeb | danew@enterprise.net
Commercial web design and hosting, reasonable rates
UKP24/Mb/Year for DIY space | mindweb@pobox.co.uk
FTP, CGI, password protection, etc. too!
http://www.virtual-pc.com/mindweb/


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

Date: Mon, 12 May 1997 08:37:11 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Matthew Ho <hohiu@ecf.utoronto.ca>
Subject: Re: Grep weather info.
Message-Id: <Pine.GSO.3.96.970512083635.2793G-100000@kelly.teleport.com>

On Sun, 11 May 1997, Matthew Ho wrote:

> I have an assignment which requires me to grep weather information from
> the net and shows it on my web page.  How can I do that in Perl?  Is
> there any modules that I can download to make the task simpler? 

Yes, they're on CPAN. (I'd start with LWP.) Hope this helps!

    http://www.perl.com/CPAN/
    http://www.perl.org/CPAN/

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Fri, 09 May 1997 18:10:27 GMT
From: bernie@rev.net (Bernard Cosell)
Subject: Help getting Syslog.pm to work
Message-Id: <3373668c.193636859@news.rev.net>

Hi again

I've been fighting most of today to get Sys::Syslog to work
[5.003/Linux] and I'm having a terrible time of it, and I'd appreciate
a hint about what I'm doing wrong:

I tried the simple thing, just doing "use Sys::Syslog" and that gets
me:
Undefined subroutine &Sys::Syslog::hostname called at
/usr/local/lib/perl5/Sys/Syslog.pm line 92.
BEGIN failed--compilation aborted at pscript.pl line 23.

So I began trying to figure out how to get 'hostname' set up.  I tried
just doing:
     use Sys::Hostname;
     use Sys::Syslog;
but that didn't do the job.  Eventually I hit upon something that
seemed to work:

use Sys::Hostname ;
BEGIN { $Sys::Syslog::host = hostname ; }
use Sys::Syslog ;

Ugly, [and it certainly shouldn't be necessary!] but there it was.
But now I get a new oddity:

Useless use of gethostbyname in void context at
/usr/local/lib/perl5/Sys/Hostname.pm line 42.
Identifier "main::y" used only once: possible typo at (eval 27) line
2.
Identifier "main::args" used only once: possible typo at (eval 22)
line 2.

The latter two are caused by my BEGIN, but I haven't a clue how/why,
and the useless-use is caused directly by the use Sys::Hostname, but
again I don't know how/why.

Anyone have any hints about what I might be doing wrong here?
Thanks!!!
  /bernie\

-- 
Bernie Cosell                        mailto:bernie@rev.net
Roanoke Electronic Village


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

Date: Fri, 09 May 1997 21:31:00 -0400
From: Thomas Oelke <tpo9617@rit.edu>
Subject: how do I get a binary representation of a number in a string
Message-Id: <3373CFD4.216D@rit.edu>

Here's what I want to have, 

  $i = "12";   # or any number 0-15.
  $tmp = somefunc($i);
  print "$i in binary is $tmp\n";

Then get for output:
  1110

(if $i = 3, it would return 0011, etc.)

So the question is, how can I implement 'somefunc'?

I've tried doing stuff w/ unpack, but that doesn't seem to be what I
want.

I can't really find anything in the FAQ or man pages that address this
type of 
problem.  (other than doing a long if/elsif - there's got to be a better
way.)

Thanks.

Tom


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

Date: Fri, 09 May 1997 21:36:21 -0400
From: Thomas Oelke <tpo9617@rit.edu>
Subject: Re: how do I get a binary representation of a number in a string
Message-Id: <3373D115.98E@rit.edu>

Thomas Oelke wrote:
 
> Then get for output:
>   1110

Oops, I meant to say the output would be:
   12 in binary is 1100

Tom


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

Date: Fri, 09 May 1997 22:06:43 -0400
From: Bill Cowan <billc@tibinc.com>
To: Alex Krohn <akrohn@spc.ca>
Subject: Re: how to get a recursive file listing
Message-Id: <3373D833.7D8F@tibinc.com>

Alex Krohn wrote:
> 
> How can I get a listing of all .htm files in the current director as well
> as all subdirectories. I would like the list of files in an array, and the
> file names to include the relative path (i.e. if the file is two levels
> deep, I don't just want the file name, but the relative path plus the file
> name).
> 
> I've managed to get it withouth the relative path using a recursive
> function, but I'm sure their must be an easier way.
> 
> Thanks for any help!
> 
> Alex Krohn

Can also try the standard module File::Find to do directory traversal
and code the &Wanted function to select those files you want to process.

-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707


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

Date: Sat, 10 May 1997 11:47:04 GMT
From: sg94bwh5@dunx1.ocs.drexel.edu (John Nolan)
Subject: Re: if (condition) always testing true
Message-Id: <5a7cd$62f4.1d4@XAVIER>

Jacob Salomon (jake@apparel.net) wrote:
: Hi y'all.
: I am new to this newsgroup. This is  my first post here.
: I am learning perl now, using the book "Teach Yourself Perl in 21 Days".

:     if ($input_line == "end")           # Just a debugging check

: That IF condition always tests true, although the print shows that it is


With strings, you need to use "eq":

      if ($input_line eq "end")

--
###  John Nolan  
###  jpn@acm.org                               ~       __0    
###  sg94bwh5@dunx1.ocs.drexel.edu            ~      _`\<,_   
###  Drexel University, Philadelphia         ~      (_)/ (_) 

Cats don't like change without their consent. 

     -- Roger A. Caras



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

Date: 10 May 1997 11:06:50 GMT
From: "Terry Robison" <trobison@erols.com>
Subject: Installing Perl 5.003
Message-Id: <01bc5d32$0a593e20$f15faccf@trobison>

First, let me say that I am not a systems person, I am a programmer working
with the systems shop to get 5.003 installed. With that said let me explain
the problem.  We have Perl 5.001 installed on our server.  I want to
install 5.003 on the server, but systems can't upgrade the current version
because of config mgt. Would like to install in another directory.  Systems
has tar'd to a new directory. We can't find installation instructions or
readme in the directory. Are we missing something. Can someone point us to
installation/compiling guidance?

Thanks,
T. Robison


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

Date: 12 May 1997 11:07:54 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: Learning PERL
Message-Id: <5l7boa$2c9@panix.com>

In <337386E3.259A@plym.ac.uk> Darren Shilson <dshilson@plym.ac.uk> writes:

>I'm relatively new to PERL programming and would really like to find out
>as much as I can about the language. However being a poor student I
>can't fork out loads of money on books, but I've got free Internet
>Access, so if you know of any on-line tutorials, e-zines, e-books, etc,
>I'd love to hear from you.

Check the "tutorials" section of Perl Reference:

   http://www.panix.com/~clay/perl/


-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: 12 May 1997 21:38:02 GMT
From: Torsten Naumann <Torsten.Naumann@informatik.tu-chemnitz.de>
Subject: Memory Clearing
Message-Id: <5l82jq$nch$1@narses.hrz.tu-chemnitz.de>

I filling a very big hash and then deleting every entry, but the ps -u
shows me no change in the momory allocation of my perl program.
How can I check that perl is freeing the memory ?

--
bye Torsten

/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
/ Torsten Naumann  +49-177-2382319      tna@informatik.tu-chemnitz.de /
/ TU Chemnitz - Fakultaet Informatik   http://www.tu-chemnitz.de/~tna /
/        PGP-public-key available via finger on email-address         /
/---------------------------------------------------------------------/
/ Freunde kann man sich aussuchen, Feinde sammeln sich an.  -- Murphy /
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


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

Date: 10 May 1997 03:35:20 GMT
From: masroor <masroor@bga.com>
Subject: Need help on initializing a perl array (MAY DAY) !!!!!
Message-Id: <5l0qdo$bre$1@news3.realtime.net>


Problem Description ===> Say I have a array cally @myarray=(1..3) ;

Now the contents of this array will 1 thru 3. 

If I print this array, it will print from1 to 3.

Question ==> Now how can I make this array contain 

"1" and "2" and "3". That is if I print the array , it should print
the numbers with the qoutes. In other words How can I make the array print
"1" "2" and "3", instead of 1 2 3 without the qoutes.

Anyhelp would be appreciated.

Thanks
Mohammad Ahmed

My email is ===> masroor@bga.com




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

Date: 10 May 1997 05:43:12 GMT
From: comdog@computerdog.com (brian d foy)
Subject: Re: Need help on initializing a perl array (MAY DAY) !!!!!
Message-Id: <comdog-2504721526410001@nntp.netcruiser>

In article <5l0qdo$bre$1@news3.realtime.net>, masroor <masroor@bga.com> wrote:

> Problem Description ===> Say I have a array cally @myarray=(1..3) ;
> 
> Now the contents of this array will 1 thru 3. 
> 
> If I print this array, it will print from1 to 3.
> 
> Question ==> Now how can I make this array contain 
> 
> "1" and "2" and "3". That is if I print the array , it should print
> the numbers with the qoutes. In other words How can I make the array print
> "1" "2" and "3", instead of 1 2 3 without the qoutes.

you need to form the array differently or print it differently.

if you want "x" in the array, that's what you need to do something like:

foreach (1..3)
   {
   push @array, qq|"$_"|;
   }

or if you just want to print the array differently:

foreach ( @array )
   {
   print qq|"$_"\n|;
   }

-- 
brian d foy                                 <http://computerdog.com>


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

Date: 09 May 1997 21:47:01 -0400
From: Eric Crampton <eric@ecrampto.async.vt.edu>
Subject: Network management with Perl
Message-Id: <m3bu6kxfmy.fsf@ecrampto.async.vt.edu>

I'm going to write a program (in perl, I suppose) which will monitor IP
packets on our Linux system which acts as an IP masquerading/forwarding
system for our LAN of Windows and UNIX machines.

I would like to be able to display a simple "current usage" chart which
shows which hosts (by IP address) on the network are sending packets, how
many they've sent, how long since the last packet sent, etc.

The statistics part is, of course, the easy part. But I'm not quite sure how
to start to figure out who's sending what. I thought about piping the output
of "tcpdump -i ppp0" into perl, which gives me stuff like:

21:44:42.285975 ecrampto.async.vt.edu.3484 > sable.cc.vt.edu.pop-3: P \
40:42(2) ack 116 win 31744 (DF)
21:44:42.395975 sable.cc.vt.edu.pop-3 > ecrampto.async.vt.edu.3484: P \
116:125(9) ack 42 win 33580
21:44:42.415975 ecrampto.async.vt.edu.3484 > sable.cc.vt.edu.pop-3: . \
ack 125 win 31744 (DF)

I can use perl's text processing capabilities to process that output, but
knowing perl, there must be "more than one way to do it". Does anyone know
of a slicker way? (Please CC a copy to my email if possible, I sometimes
miss posts.)

Eventually, I'll probably make a graphical perl/tk version, too. When I
finish, I'll make the program available for others, too.

Thanks in advance,
-- 
Eric Crampton


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

Date: Sat, 10 May 1997 01:56:18 GMT
From: dkcombs@netcom.com (David Combs)
Subject: Re: Perl auto-replier
Message-Id: <dkcombsE9y01u.M3p@netcom.com>

You want people to read the FAQ, the book(s), the man pages,
etc -- but (maybe) you don't want to be rude, either.

Maybe this approach will make it less rude-sounding:

  Admit UP FRONT that Perl is a DIFFICULT LANGUAGE.  There's
  nothing simple about it, what with different contexts,
  LOTS of "dwim" (do what I mean) things that have to
  be memorized.  Clever, yes, but simple, not at all.

  Say to people that they have no business programming
  ("programming", not "scripting") in a language so complex,
  with so much to memorize and understand, without doing
  a LOT of mental work first, with the various docs.

I do think for these posts people are complaining about
that when there is an obvious answer in the FAQ, or 
at page so-and-so in the camel, then maybe simply
give them the page number and subject-name, and let
them go find the answer themselves.

Having a printed-out FAQ, and also a blue camel, might
be a justifiable (implicit) REQUIREMENT for posting
to the group and expecting an answer.

Of course, lots of people just read and then download
some of the stuff on the group, to make their own additional
doc, so you want to go too far in this.

Readers of the group do learn from reading the answers.
Often the answers are better laid out, explained, etc,
than what IS in the doc.  It is nice to have the same
thing explained in various ways -- gives a little stereo
vision of it.

Actually, I don't mind all the simple questions -- but
then I don't answer them (am more likely to post one
myself!)

Like I say, this Perl is no simple language -- maybe it
was years ago, but surely not now!

Just my thoughts...



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

Date: Sat, 10 May 97 05:28:04 GMT
From: heintz@nauticom.net (Steve Heintz)
Subject: Perl Script Authors!!  Please Read!!
Message-Id: <337406e0.0@pgh.nauticom.net>

If you have a web site offering any Perl scripts you have written that are 
available to the public for free, please go to my Perl Scripts page and add 
the URL to my list.  I am compiling a page of Free Perl scripts to be 
available and searchable by the public.  The address is:  
http://www.nauticom.net/www/heintz/perl/index.html

Thank you very much.

Stephen Heintz
Free Perl Scripts Webmaster
http://www.nauticom.net/www/heintz/perl/index.html


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

Date: Fri, 09 May 1997 23:53:20 -0400
From: peter.wood@axom.com (Peter Wood)
Subject: perl/cgi help - need current date function
Message-Id: <peter.wood-ya023580000905972353200001@n5.supernews.com>

Hi,

I'm trying to put a function in a cgi perl script that will print out the
current date into an html form field.  What I have now is:

sub getTheDate {
  $thedate = system("date +%D);
}

and when I am in the subroutine where I want to call it, I just:

&getTheDate;

and in the place where I want the date to appear (for example):

print &PrintHeader;
print <<TOEND;
(extra html cut...)
<input type=text name=todaysdate size=8 maxlength=8 value=$thedate>
 ...etc

When I do this, the perl script misfires and the Netscape server hangs with
the error: (some cut..)

the CGI program xxxxxxxxxxx did not produce a valid header (name without
value: got line "05/09/97")

I recognize that output as coming from my getTheDate function - but I don't
know why it's coming out, and for some reason it's screwing up the server
and the form won't be generated.

I know the small snippets of code might make it a vague problem, but if you
understand, please write me.  It would be much appreciated!

Thanks, and please use email!

Peter

Peter R. Wood, Technical Support <*--Axiom Technologies, Inc.--*>
mailto:peter.wood@axom.com http://www.axom.com/ http://www.axom.com/~pwood/


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

Date: Mon, 12 May 1997 10:37:06 -0400
From: the count <eglamkowski@mathematica-mpr.com>
Subject: printer
Message-Id: <33772B12.3DAD@mathematica-mpr.com>

how does one go about sending STDIN to the printer?
"Leraning Perl" seems to skirt about the issue, talking about
if you were to send something to the printer, be sure to do this
that or the other thing (in particular, in the chapter on formats,
but elsewhere too), but they never actually tell you *how* to send
things to the printer.
i want to believe there should be some platform indepent way, like
a special filehandle (PRN?), so that you could do something like:
print PRN "whatever";

-- 
Due to continuing problems with my hotmail account, any mail received 
from eglamkowski@hotmail.com dated after 5/9/97 should be considered 
fraudulent.  I am no longer using my hotmail account, and never will 
again;  due to the fact that I have been unable to logon for several 
days in a row, "Invalid login/password combination", I must assume my
account was hacked and the password changed.

-*-*->    Please do not send mail to, nor accept mail from    <-*-*-
-*-*->                 eglamkowski@hotmail.com                <-*-*-


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

Date: Mon, 12 May 1997 08:36:16 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: David Ishee <dmi1@ra.msstate.edu>
Subject: Re: private scalar for each instance of an object?
Message-Id: <Pine.GSO.3.96.970512082519.2793F-100000@kelly.teleport.com>

On 11 May 1997, David Ishee wrote:

> I am trying to write my first perl object. In this object, I need to
> have a private scalar variable that is global for the object, but each
> instance of this object needs to have it's own private copy. 

Most objects in Perl are simply references to blessed hashes. Inside that
hash, you can store as many scalars as you wish, each one under its own
key. You can even store references to other data structures. (This is what
you wanted, isn't it?)

    package My_Object;
    sub new { 
        my $self = { };		# an empty hash
        my $class = shift;
        $self->{DATA} = undef;	# the scalar you want to store
        $self->{MORE} = 3.141;	# another one, for fun
        $self->{STILLMORE} = [ 1..5, qw(even more data) ];
        bless $self, $class;	# Return the blessed reference
    }

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 12 May 1997 22:29:10 GMT
From: Steven Headley <sheadley@cyberramp.net>
Subject: problems trying to build libwww-perl-5.07
Message-Id: <5l85jm$408$3@newshost.cyberramp.net>

Hello ALL,
    I am having some problems trying to build this library:
libwww-perl-5.07.

>From the REAMDE it has as prereqs  IO-#.##, libnet-#.##, MD5-#.##. But WAIT! I
thought that IO was part of the BASE System. OH WELL! When I tried to build
IO-#.##,I get the following:

[root@Headley IO-1.15]# make test
cp IO/Pipe.pm ./blib/lib/IO/Pipe.pm
cp IO/File.pm ./blib/lib/IO/File.pm
cp IO/Select.pm ./blib/lib/IO/Select.pm
cp IO.pm ./blib/lib/IO.pm
cp IO/Socket.pm ./blib/lib/IO/Socket.pm
cp IO/Seekable.pm ./blib/lib/IO/Seekable.pm
cp IO/Handle.pm ./blib/lib/IO/Handle.pm
 ./../perl -I../../lib -I../../lib ../../lib/ExtUtils/xsubpp  -typemap
 ./../lib/ExtUtils/ty
pemap IO.xs >IO.tc && mv IO.tc IO.c
Please specify prototyping behavior for IO.xs (see perlxs manual)
gcc -c  -DOVR_DBL_DIG=14 -Dbool=char -DHAS_BOOL -I/usr/local/include -O2
-DVERSION=\"1.15
\" -DXS_VERSION=\"1.15\"  -I../..  IO.c
In file included from /usr/include/huge_val.h:25,
                 from /usr/include/math.h:111,
                 from ../../perl.h:803,
                 from IO.c:11:
/usr/include/endian.h:37: warning: `LITTLE_ENDIAN' redefined
/usr/include/asm/byteorder.h:10: warning: this is the location of the previous
definition
Running Mkbootstrap for IO ()
chmod 644 IO.bs
LD_RUN_PATH="" ld -o blib/arch/auto/IO/IO.none  IO.o
IO.o: Undefined symbol _Perl_croak referenced from text segment
IO.o: Undefined symbol _Perl_stack_sp referenced from text segment
IO.o: Undefined symbol _Perl_markstack_ptr referenced from text segment
IO.o: Undefined symbol _Perl_stack_base referenced from text segment
IO.o: Undefined symbol _Perl_markstack_ptr referenced from text segment
IO.o: Undefined symbol _Perl_stack_base referenced from text segment
it just keeps going, and going, and going.

Well, I thought I looked at something on this newsgroup about the same problem
on a solaris machine but I am running Linux 3.03. What was needed there is
dynamic linking. Is this what I need to solve this problem? How can I tell if
dynamic linking is set to on or off (being a newbie at best)? This looks like a
linker problem to me, but where are these libraries? If this is a linker
problem, how do I specify something else on the command line and what library
is it choking on? Any and all help would be sincerly appreciated.


      Steven Headley.



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

Date: Fri, 9 May 1997 23:16:51 +0100
From: Rosemary I H Powell <rosie@dozyrosy.demon.co.uk>
Subject: Re: program for perl?
Message-Id: <Y50BmAATJ6czEwV5@dozyrosy.demon.co.uk>

In article <5kqfp3$4i2@gargantubrain.osmre.gov>, Bill Kannawin
<kannawin@gargantubrain.osmre.gov> writes
>
>In article <5kp9kq$2tm$1@marina.cinenet.net>, cberry@cinenet.net (Craig Berry) 
>writes:
>|> Michael J Gebis (gebis@purcell.ecn.purdue.edu) wrote:
>|> : }Ah, yes, there IS a program needed to write in perl.
>|> : }It's called "perl" :)
>|> : 
>|> : Technically, that's the program needed to run perl.  You can write in
>|> : perl using almost anything, from emacs to antelope blood on a cave wall.
>|> 
>|> Wow, I thought I was the only one doing that!  Do you find gazelle blood 
>|> works as well, or do you really need antelope?  I'm experimenting with 
>|> ibexes (ibices?), too.
>|> 
>If you're just starting out, I think a LLama would right, followed by
>a camel.
Just starting out, you use blood, sweat and (a lot of) tears.
Rosemary
-------------------------------------------------------------------
| Rosemary I.H.Powell  EMail: Home: rosemary@dozyrosy.demon.co.uk |     
|                             Work: r.i.h.powell@rl.ac.uk         |
|                       http://www.netlink.co.uk/users/dozyrosy/  |
|                       http://www.dozyrosy.demon.co.uk/          | 
-------------------------------------------------------------------


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

Date: Fri, 09 May 1997 11:20:54 -0400
From: "Geoffrey V. Brown" <an745@traverse.lib.mi.us>
Subject: sendmail script
Message-Id: <337340D6.6EBD@traverse.lib.mi.us>

I am looking for a way to use perl as a mailing list script. 
What I would like to do is open a file that contains email addresses,
read each line into an array, then use foreach to send information to
each person on the list.  The function I have seems to work, but the
script for sendmail doesn't work properly and gives a ton of errors.  I
am using digital unix with perl 5.  I'd perfer not to use a module since
I am unfamiliar with this and fairly new to perl.


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

Date: Fri, 09 May 1997 08:29:41 -0400
From: Tom Lynch <toml@synnet.com>
Subject: Seraching Large Files
Message-Id: <337318B5.3364@synnet.com>

Greetings:

        I have a hash table which I need to use to search
        through a large Verilog netlist. I am doing this
        like so:

while (<VER>){
    chop;
    @y = $_;
    @y = split;
    while (($vkey,$vvalue) = each %signal) {
        if (/$vkey/){
          $vtmp = "$y[1] $vkey $vvalue";
          push(@vline, $vtmp);
        }
    }
}


        This works, but it's slow. Is there a better way to
        do this type of search? I know about $signal{$_}++
        but only the key will be in the line and it could
        be anywhere except the first three columns. Thanks
        for any help in advance!

        Tom

-- 
#--------------------------------------------------------------+
# Tom Lynch                 |  Email: toml@synnet.com          |
# Switching Division        |  Phone: (508)-264-1443           |
# 3COM Corporation          |  Fax  : (508)-264-1418           |
# 80 Central Street         |  MS   : MA#35                    |
# Boxborough, Massachusetts |  Zip  : 01719                    |
#--------------------------------------------------------------+


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

Date: 12 May 1997 16:03:32 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: speeding up a regex
Message-Id: <5l7f0k$uch$1@news.netusa.net>

Justin C Lloyd <lloyd@cs.fsu.edu> wrote:
>Just me again, responding to my own message.  After weeks of thinking about
>this, I finally post a question and then come up with something.  I changed
>
>   $_->[5] =~ /^($first|$firstinit)?\s+($middle\s+)?$last$/
>
>to
>
>   $_->[5] =~ /^$firstinit/ && /^($first|$firstinit)?\s+($middle\s+)?$last$/
>            
>             \________________/
>
>and that sped it up tremendously.

I do not know what is in your variables, but in general the change does
not produce the equivilent results. In fact, for most cases it would
not.

Consider the case

$_->[5] = "fee-fie foe fum";
$first = "fee";
$firstinit = "fee-fie";
$middle = "foe";
$last = "fum";

The your first bit of code will set $1 to "fee-fie" and $2 to "foe". The
second one will fail the /^$firstinit/ match and not set either of $1 or
$2.

And when $_->[5] = " foe fum", the first will set $1 to undef and $2
to "foe", while the second will again fail.

If you can, use the /o modifier on the regexp. This is useful in loop
situations where the variables in a regexp are constant throughout the
loop. 

Failing that, at least change your pre-test to search for the required
bit in the regexp:

$_->[5] =~ /\s\b$last$/ && /^($first|$firstinit)?\s+($middle\s+)?$last$/ ;
#             ^^ 
#   With this \b I am assuming that $last does not match m:^\s:
#   take it out if this cannot be assured.

Also if you don't want $1 or $2 set, use (?:...) instead of (...) and
that will speed things up.

Elijah
------
never saw the original post



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

Date: Fri, 09 May 1997 14:25:21 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: standards
Message-Id: <b.wilkinson-0905971425210001@ip57-york.pindar.co.uk>

In article <337141BF.7C1F@swbell.net>, walkerjl@swbell.net wrote:

> Does anyone know of a source for programming standards in Perl?
> 
> Jonnie
> walkerJL@swbell.net

perldoc perlstyle

Bob

-- 
I have become death, destroyer of the worlds.


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

Date: Mon, 12 May 1997 17:31:30 +0200
From: domo@tcp.ip.lu (Dominic Dunlop)
Subject: Re: STRAW POLL: RFD: comp.lang.perl reorg
Message-Id: <19970512173130537308@dialup20.ip.lu>

Russ Allbery <rra@stanford.edu> wrote:

> This was the umpteenth reposting of this straw poll, actually.

So it was.  Please accept my apologies.

> Although
> that probably should have been noted more clearly in the body of the
> message.

Yup.  As a blush-sparing measure, sounds good to me!
-- 
Dominic Dunlop


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

Date: 12 May 1997 15:10:58 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: telnet client
Message-Id: <5l7bu2$5b@news-central.tiac.net>

In article <Pine.SOL.3.96.970512155422.29610A-100000@ursa.cus.cam.ac.uk>,
Matthew Bernstein  <mrab100@cam.ac.uk> wrote:
>I wish to write a telnet client using perl, but am not having any success at
>connecting the socket. man perlipc has not proved helpful.
>
>Could someone provide me with the code so that I can:

You might want to look at the telnet RFC at
http://www.cis.ohio-state.edu:80/hypertext/information/rfc.html (857 and
1184 I think...) as there's some negotiation which will block unless you
respond correctly when you connect to the telnet port.  This allows you to
tell the other end of teh connection what you're prepared to or capable
of doing.  You will probably end up using sysread and select if you write
it yourself.  If you look on a CPAN site then

  .../CPAN/authors/id/JROGERS/Net-Telnet-3.00.readme

might save you some work.

There's a CPAN site multiplexor at http://www.perl.com/CPAN/

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@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 12 May 1997 11:12:11 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: winword 6/7
Message-Id: <5l7c0b$3qb@panix.com>

In <3375ebf9.0@news.uni-konstanz.de> <> writes:

>I'm looking for further information about winword filestructure. Does anybody 
>know the implementation of macro structures in .doc - files?

Try: LAOLA
     http://wwwwbs.cs.tu-berlin.de/~schwartz/pmh/laola.html
     A perl library, that gives access to OLE documents like Word and Excel 
     without Microsoft code. You can read documents, read and modify existing 
     streams and read and modify garbage. Supports a litte bit property sets. 
     A quick reference file for this library is now available. The code should 
     be rather system independent. However, at MS DOS and some Unix systems 
     it worked well.
 
ObPlug: Found in the "Windows 95 and Windows NT" section of the Perl
        Reference <http://www.panix.com/~clay/perl/>


-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

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

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