[7714] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1340 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 18 21:18:17 1997

Date: Tue, 18 Nov 97 18:00:40 -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           Tue, 18 Nov 1997     Volume: 8 Number: 1340

Today's topics:
     Re: @ARGV not read on NT. (Troy Denkinger)
     Accept ("Interrupted system call") <m738@truman.edu>
     Re: Chomp vs Chop (I R A Aggie)
     Re: Chomp vs Chop (Bryan D Howard)
     correct URL for a redirected website? <rowanfan@algonet.se>
     Re: Creating a histogram.... (Jeremy D. Zawodny)
     Re: exclusive file rights (Steve)
     Re: HELP - Perl CGI script stops working after SQL quer <u2537@shurflo.com>
     Re: HELP - Perl CGI script stops working after SQL quer (Jeremy D. Zawodny)
     Re: help: debugging perl scripts... (Jeremy D. Zawodny)
     Re: how do i append todays date to the end of a filenam (Martien Verbruggen)
     Re: How to determine absolute file path on UNIX (Alfred von Campe)
     Re: how to invoke sendmail for mailing list? (Mike Stok)
     Re: how to reference index into array by it's value (E.None Archibald)
     Re: how to reference index into array by it's value (Abigail)
     How to retrieve a .gif-file from a website? <rowanfan@algonet.se>
     I want to count the number of same items on a list! <jetumele@microtec.net>
     Re: I want to count the number of same items on a list! (Abigail)
     Re: launch, monitor and kill forked processes <stagda@ncs.com>
     Re: max size of cookie? (Jeremy D. Zawodny)
     Re: modules, ignoring Tom Phoenix (Jeremy D. Zawodny)
     Re: Newbie Q. How to flush print output mid-script? <webmaster@visionary-western.co.uk>
     Re: Newbie question regarding DNS (Michael Fuhr)
     Re: Q: How many elements in a %HASH ? (Greg Bacon)
     Re: Q: How many elements in a %HASH ? (Andrew M. Langmead)
     Re: Q: will perlis.dll work w/5.004_02 dist from Gurusa (Jeremy D. Zawodny)
     question on perl runtime (Allan Manayan)
     Re: question on perl runtime (Mike King)
     Regex hell(p) (Blake Swensen)
     Re: Regex hell(p) (Abigail)
     Returning a hash from an XSUB? (Bob Rogers)
     Re: Returning a hash from an XSUB? (Bob Rogers)
     Returning information from an nslookup ?? (Burt Lewis)
     Re: Returning information from an nslookup ?? (brian d foy)
     returning value of executed program <ptrainor@bbnplanet.net>
     Re: returning value of executed program (brian d foy)
     Searching a WORD 6 DOC by line line number <mhfarris@pangea.ca>
     Re: Searching a WORD 6 DOC by line line number (Mike King)
     spellchecking? , snailgem@aol.com
     Re: spellchecking? (Jeremy D. Zawodny)
     Re: system vs. backtics.  What difference? (E.None Archibald)
     Re: Taint checking problem - insecure PATH Part 2 <71022.3700@CompuServe.COM>
     Text to html perl script jeremy@lightningweb.com
     Why does this regex not work? <rsavoie@lsil.com>
     Re: Why does this regex not work? (brian d foy)
     xforms problems <froboz@cif.rochester.edu>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 19 Nov 1997 00:53:00 GMT
From: troy@whadda.com (Troy Denkinger)
Subject: Re: @ARGV not read on NT.
Message-Id: <64tdjp$114$1@nntp3.interaccess.com>

Also emailed to original poster.

In article <01bcf375$95498d80$121ad192@kii-197990>, "Koch" 
<rajagopm@kochind.com> wrote:
>When I execute a Perl program from the command line, the arguments
>following the command name are not being read into the @ARGV array, unless
>I source the script in explicitly to Perl.  Here's an example:
>The script argtest.pl reads:

[snip]

In your registry, edit the default value for:

\HKEY_CLASSES_ROOT\pl_auto_file\shell\open\command

to read:

c:\perl\bin\perl.exe "%1" %*

Or wherever perl.exe is located.  Right not it probably is missing the 
%* part.

Note that

\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\pl_auto_file\shell\open\command 
will also change automagically without you having to get involved.

This is all assuming you're using the 5.004 distribution and not the 
Activeware distribution.  If you're using the latter, you'll have to 
search through the registry for the entry to edit.  This ought to at 
least point you in the correct direction.

Regards,

Troy Denkinger



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

Date: Tue, 18 Nov 1997 18:45:09 -0600
From: Jason Oesterly <m738@truman.edu>
Subject: Accept ("Interrupted system call")
Message-Id: <34723695.789E@truman.edu>

Hello-

I am working on a AIX 3.2 machine w/ Perl 5.000.

I am in the process of learning sockets (and signal handling) and have
encountered a problem with handling a 'kill -HUP'.  The error I receive
is "Interrupted system call line ##" where accept() is present on line
##.

I have tried following the explanation in Prog Perl 2nd Edition (p.
340), but I am having difficulties understanding the details; the
section refers to the sigaction(2) function, of which I am unfamiliar.

So my question is, how can I handle a -HUP and other signals which may
cause a similar situation?

I encounter the same problem on AIX 4.2 w/ Perl 5.002.

Thanks for your help,

Jason Oesterly
m738@truman.edu


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

Date: Tue, 18 Nov 1997 18:45:20 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Chomp vs Chop
Message-Id: <-1811971845210001@aggie.coaps.fsu.edu>

In article <3471B9F0.2781@link.com>, Matt Pezzuto <mpezzuto@link.com> wrote:

+ (but this is a simplistic example).  So, since we know an eol must be
+ the delimiter between entries, why can't I just non-discriminantly chop
+ off the last character?"

Ummm...because not every computer uses a single EOR character?

James - I believe peecee's use CRLF as the end of record...

-- 
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 18 Nov 1997 16:42:03 -0800
From: bryan@solstice.jpl.nasa.gov (Bryan D Howard)
Subject: Re: Chomp vs Chop
Message-Id: <7c200dhfz8.fsf@solstice.jpl.nasa.gov>

fl_aggie@thepentagon.com (I R A Aggie) writes:

> In article <3471B9F0.2781@link.com>, Matt Pezzuto <mpezzuto@link.com> wrote:
> 
> + (but this is a simplistic example).  So, since we know an eol must be
> + the delimiter between entries, why can't I just non-discriminantly chop
> + off the last character?"
> 
> Ummm...because not every computer uses a single EOR character?
> 
> James - I believe peecee's use CRLF as the end of record...

And because there is no guarantee that the last record has the EOR
sequence on the end.

Best not to chop with your eyes closed.
-- 
{Bryan}

Bryan Howard, U*ix & VMS System Mangler
JPL Section 393, Pasadena, CA, USA            <bryan@solstice.jpl.nasa.gov>


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

Date: Tue, 18 Nov 1997 23:03:58 +0100
From: Calle <rowanfan@algonet.se>
Subject: correct URL for a redirected website?
Message-Id: <347210CE.25BD@algonet.se>

I was wondering if it4s possibly to get the correct URL for an
adress that is redirected.
e.g. like the adress
http://www.webwombat.com.au/intercom/newsprs/usalpa-c.htm

where the links is redirected (check the htmlcode for the links and then
click one and you'll see what I mean)

how can I found out the correct URLs?
e.g. I want it to work something like

%arnold>check.pl
"http://www.webwombat.com.au/intercom/newsprs/usalpa-c.htm"
the correct urls are:
---and then all the correct urls are printed
---like: http://www.dnn.com/aanewss.html
%arnold>

anyone knows?


/calle


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

Date: Wed, 19 Nov 1997 01:45:43 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Creating a histogram....
Message-Id: <34784498.80498130@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Tue, 18 Nov 1997 17:38:02 +0000, Stephan Nagy
<rzjj60@email.sps.mot.com> wrote:

>Is it possible to sort a hash by the values of the keys rather then the
>keys themselves?

Yes. In fact, the code appears in the perlfunc manpage under the
sort() function:

  # this sorts the %age hash by value instead of key
  # using an in-line function
  @eldest = sort { $age{$b} <=> $age{$a} } keys %age;

It pays to read the docs.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Wed, 19 Nov 1997 01:33:06 GMT
From: syarbrou@ais.net (Steve)
Subject: Re: exclusive file rights
Message-Id: <347240ee.3926858@news.ais.net>

On 18 Nov 1997 16:02:42 GMT, "James Richardson" <jamesr@aethos.co.uk>
wrote:

>Matt Dowell <mdowell@mmm.com> wrote in article <34707CF0.F50@mmm.com>...
>> We are running HP-UX and for some reason flock is not in the OS. So here
>> is what I did to get around this. I think it's better anyways.
>> 
>> I first lock the file, and I do that by creating a file with the same
>> name, just a .LOCK on the end.
>> 
>
>OK, your method is NOT better then kernal implemented file locking.
>(Otherwise why would they bother to put it in the kernal?)
>
>Main Reason:
>
>	The test for the file, and the subsequent creation of the file is not an
>atomic action. This is undergrad 1st year stuff...
>	The problem occurs because under a preemptive multitasking system, you
>never know when your prcess will be interrupted. The problem becomes more &
>more acute when the system is under load....
>
>	Process A						Process B
>
>								Start
>								---Switch
>	Start
>	Check for lock file
>	Not there....					
>	-Switch				
>								Check for lock
>								not there
>								Create file (I think i have a lock)
>								-Switch
>	-Create File (I think i have a lock)
>
>Now process A and B both think they have a lock. Problem time....
>
>> 
>> Works for me.
>> 
>
>Hmm... maybe, but it is NOT infallible. In fact getting file locking to
>work right is quite a difficult thing to do.
>
>Under HPUX there is lockf which can enforce mandatory record/file locking..
>and I think that this also exists under Solaris...(but theres no Perl
>interface to this... unless somebody writes one!)
>
>
>> When someone tried to access the file, i check for the filname.LOCK
>> first, if there then loop. Contantly checking.
>
>Busy wait!!!!!
>
>
>I havent had to do this... but maybe if you were to check that the file
>exists, then yield (i.e. sleep or something), then check again, you might
>have more reliable results. Thats a bit of guess but it seems reasonable.
>
>
>James Richardson
>

So where are we at here.  Will flock(fileheader, #) work?  In my
implementations of it on a Sun machine, it does not seem to work.  My
site gets about 30,000+ hits a day.  If I set flock(DATA,2) || print
DATA2 "Error";, it never prints error to the file.  This would make me
assume the file lock is never working.  Does the above logic hold?  I
still end up with empty logs and stuff using flock(), so I have to
assume if a local copy of the script works, but a live one will clear
itself in a matter of minutes to an hour, that I am still getting
collisions.

Steve


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

Date: Tue, 18 Nov 1997 15:17:04 -0800
From: Thomas Beardshear <u2537@shurflo.com>
Subject: Re: HELP - Perl CGI script stops working after SQL query
Message-Id: <347221F0.EA9734A7@shurflo.com>

The permissions ARE set correctly. The FIRST TWO print statements work
fine on the browser. It's only the last 6 print statements that don't
work.

Something in PERL or MSQL is preventing (or timeing out before) the last
print statements output.

Jared Evans wrote:
> 
> Make sure you have permissions set correctly and you are printing out
> Content-type: html/text\n\n   before you are printing out any HTML code to
> STDOUT.
> 
> ---------
>


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

Date: Wed, 19 Nov 1997 01:42:21 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: HELP - Perl CGI script stops working after SQL query
Message-Id: <347643c5.80287857@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Tue, 18 Nov 1997 07:23:27 -0800, Thomas Beardshear
<u2537@shurflo.com> wrote:

>I'm trying to write a few simple programs to access data through our
>intranet. The script works fine from the bash shell but does not print
>anything after the query statement when run on a browser. Anyone have
>any ideas?

The query probably bombs and takes the CGI process with it.

Check your server logs. Check your permissions. Add debugging code.
Use CGI.pm. Exercise regularly. Stay healthy. :-)

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Wed, 19 Nov 1997 01:36:22 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: help: debugging perl scripts...
Message-Id: <3472428a.79972103@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Mon, 17 Nov 1997 19:11:06 -0500, MrPc <tjbiuso@redrose.net> wrote:

>i am sort of a newbie to perl.  i have winnt 4.0 and redhat linux on my
>machine.  i prefer to use windows.  are there any debuggers out there
>for me?

Just the one that comes with Perl.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: 19 Nov 1997 01:36:24 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: how do i append todays date to the end of a filename?
Message-Id: <64tfqo$jn2$1@comdyn.comdyn.com.au>

In article <64sis3$sc7$1@en1.engelschall.com>,
	sb@en.muc.de (Steffen Beyer) writes:

> A much simpler way goes as follows:
> 
> $date = `/bin/date +%y%m%d`;

This is not exactly portable to non-unix operating systems.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd.       | excuse - Lazarus Long
NSW, Australia                      | 


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

Date: 18 Nov 1997 22:10:33 GMT
From: alfred@hw.stratus.com (Alfred von Campe)
Subject: Re: How to determine absolute file path on UNIX
Message-Id: <64t3op$ppr@transfer.stratus.com>

Eli the Bearded (usenet-tag@qz.little-neck.ny.us) wrote:
|>Accept $PWD, and don't worry about normalizing the path.

Well, below is what I ended up using.  It works for all my
test cases.  One thing I didn't have to worry about was
taking care of "~", since the shell does that for me.

    $script = cwd() . "/$script" if ($script =~ m#^[^/]#);
    $script =~ s|^/tmp_mnt||;
    $script =~ s|/[^/]*/\.\.||g;
    $script =~ s|/[.]/|/|g;
    $script =~ s|//|/|g;

|>/bin/pwd (as opposed to shell builtins) uses, I believe, the
|>following algorithm:

Thanks for posting that; it's very interesting.

Alfred
-- 
+------------------------------------------------------------+
| Phone: H: 978.448.6214, W: 508.490.6306, fax: 508.460.2888  \
|  Mail: Alfred von Campe, 402 Lowell Road, Groton, MA 01450   \
| Email: alfred@hw.stratus.com                                  \
+----------------------------------+-----------------------------+
| Why is common sense so uncommon? | I'd rather be flying N4381Q |
+----------------------------------+-----------------------------+


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

Date: 18 Nov 1997 21:54:45 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: how to invoke sendmail for mailing list?
Message-Id: <64t2r5$p28@news-central.tiac.net>

In article <3471aa3e.93088312@news.mit.edu>,
Kevin Kelleher <kevink@NOSPAM-mit.edu> wrote:
>
>Premise: I can't create mail aliases on my ISP, yet I want to
>run a group of email discussion lists.
>
>So, I wrote a small knockoff of majordomo that works pretty
>well, but it takes a long time (minutes) to send all the
>mail.

>Can anyone suggest a quicker/better way?

You might want to check the -t flag to sendmail, my linux docs say

     -t          Read message for recipients.  To:, Cc:, and Bcc: lines will
                 be scanned for recipient addresses.  The Bcc: line will be
                 deleted before transmission.  Any addresses in the argument
                 list will be suppressed, that is, they will not receive
                 copies even if listed in the message header.

so you can use the Bcc: heaser to have lots of recipients who don't all
see each other's names and maybe chunk up a number of recipients per
sendmail invocation.  If you can get your ISP to install perl 5 modules
then the libnet distribution includes Nrt::SMTP which lets you send mail
without directly invoking sendmail.

These probably aren't the best way to do things, but I've used both in the
past.

Hope these vague hints help,

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: 18 Nov 1997 23:21:28 GMT
From: yevgene@xochi.tezcat.com (E.None Archibald)
Subject: Re: how to reference index into array by it's value
Message-Id: <64t7to$662$2@tepe.tezcat.com>

: @array=('zero', 'one', 'two', 'three', 'four', 'five');

: I want to be able to retrieve 2 when I apply "two"; I could make a hash
: to do the same thing, I know, but is there an easier way?;

a hash -is- the easier way.

you can easily build your hash with map():

$a = 0;
%hash = map { $a++ => $_ } qw (zero one two three four five);

qw() is just a simpler way of saying:
 ("zero","one","two","three","four","five")

HTH!

-e.


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

Date: 19 Nov 1997 00:31:30 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: how to reference index into array by it's value
Message-Id: <slrn674cuk.kcu.abigail@betelgeuse.wayne.fnx.com>

E.None Archibald (yevgene@xochi.tezcat.com) wrote on 1540 September 1993
in <URL: news:64t7to$662$2@tepe.tezcat.com>:
++ : @array=('zero', 'one', 'two', 'three', 'four', 'five');
++ 
++ : I want to be able to retrieve 2 when I apply "two"; I could make a hash
++ : to do the same thing, I know, but is there an easier way?;
++ 
++ a hash -is- the easier way.
++ 
++ you can easily build your hash with map():
++ 
++ $a = 0;
++ %hash = map { $a++ => $_ } qw (zero one two three four five);

I guess you mean:

%hash = map {($_ => $a ++)} qw (zero one two three four five);




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


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

Date: Tue, 18 Nov 1997 22:49:43 +0100
From: Calle <rowanfan@algonet.se>
Subject: How to retrieve a .gif-file from a website?
Message-Id: <34720D77.54FF@algonet.se>

Hi, I wonder if it's possibly with the libwww to retrieve binaryfiles,
for example a gif-image?
how is it done?

/calle


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

Date: Tue, 18 Nov 1997 18:09:52 -0500
From: Jetumele <jetumele@microtec.net>
Subject: I want to count the number of same items on a list!
Message-Id: <3472203F.CC53E02@microtec.net>

Hello, PLEASE HELP ME!!! :)

    I want to count the number of same items on a list!  exemple:


I have a list like:

apple
banana
orange
apple
appel
orange
banana
apple
 ...


And I want to say How many apple I have...

Thank you!





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

Date: 19 Nov 1997 00:32:03 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: I want to count the number of same items on a list!
Message-Id: <slrn674cvm.kcu.abigail@betelgeuse.wayne.fnx.com>

Jetumele (jetumele@microtec.net) wrote on 1540 September 1993 in
<URL: news:3472203F.CC53E02@microtec.net>:
++ Hello, PLEASE HELP ME!!! :)
++ 
++     I want to count the number of same items on a list!  exemple:


perldoc -f grep


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


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

Date: Tue, 18 Nov 1997 16:59:50 -0600
From: "David Stagner" <stagda@ncs.com>
Subject: Re: launch, monitor and kill forked processes
Message-Id: <64t6os$r4n$1@excalibur.avalon.net>


James Richardson wrote in message
<01bcf36e$034f1dc0$26c0a4c1@kitkat.aethos.co.uk>...
>
>
>mathias@linux.ek79.uni-koeln.de wrote in article
><64mrp4$fn0@news.rrz.Uni-Koeln.DE>...
>> Hi,
>>
>> I am trying to build a loop that
>> starts a binary, waits a predefined
>> amount of time, and then either kills
>> the launched process if it is still
>> running, or does something with its
>> output if it has successfully completed.
>>


Okay, I think you're modeling the problem wrong already.  How about this...
IF the child returns, process its output.  If it times out before returning,
kill it.  In other words, waiting on the timer isn't the primary task...
waiting on the child is.

Here's how to do it: First, set up SIGCHLD and SIGALRM signal handlers.  The
SIGCHLD handler cleans up the child zombie (wait() or some variety thereof),
and kicks you back out to do the data processing (never hang around too long
in a signal handler). The SIGALRM handler kills the child.  The child should
have different return values, depending on whether it exited normally, or
was killed (or died abnormally on its own).

Now, fork and exec the child. Then, set the timer with alarm(). Then
pause(), which will put the parent to sleep until a signal is received.
This should be either a SIGCHLD (if the child finished) or a SIGALRM (if the
timer runs out). The signal handlers will clean up and take care of the
child.  Now, presumably the child put the data in a file somewhere.  Check
the return value of the child with wait() in the SIGCHLD handler. If the
return value says it completed successfully, then process the data.  If the
return value says it failed (timed out or died abnormally), trash the data.





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

Date: Wed, 19 Nov 1997 01:39:18 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: max size of cookie?
Message-Id: <3474432a.80132214@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On 18 Nov 97 14:34:33 GMT, kas5670@vaxb.isc.rit.edu (kim slack) wrote:

>How much data can you fit in a cookie?  Geoff

That has nothing to do with Perl.

It is documented in the HTTP spec, I believe.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Wed, 19 Nov 1997 01:48:55 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: modules, ignoring Tom Phoenix
Message-Id: <347944da.80564345@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On 18 Nov 1997 18:54:25 GMT, Tom.Grydeland@phys.uit.no (Tom Grydeland)
wrote:

>On 18 Nov 1997 18:02:01 GMT,
>Darwin O.V. Alonso <dalonso@u.washington.edu> wrote:
>
>> [...] it's not wise to ignore Tom Phoenix.
>
>True.

Unless you can predict his reply before you read it.

You see, some believe that Tom isn't actually a person, but he is in
fact a very smart Perl script that is able to recognize and answer
commonly asker Perl questions[1].

If that's the case, it's fun to see how many you can answer before he
does. By my count, there are roughly 12 people who engage in this game
on a semi-regular basis.

In the end, though, it's probably a losing battle. "Tom" is very
persistent.

Jeremy

[1] Actually, I met Tom at the Perl conference this Summer. :-)
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Mon, 17 Nov 1997 13:35:38 +0000
From: John <webmaster@visionary-western.co.uk>
To: philipm@nafohq.hp.com
Subject: Re: Newbie Q. How to flush print output mid-script?
Message-Id: <3470482A.BF1@visionary-western.co.uk>

Philip Mikal wrote:
> 
> Hello:
> 
> How about have your script start a cron job so your system will do it later...
> even though I don't know why you'd want to do such a thing.
> 
> Regards.
> 
> Philip M.

Hi Phil! 

I had a long talk with the client tonight, in which I raised all the
issues that had come up from my post, and which ended, 'Okay, do it
whatever way you think best.'
 
Tom has also e-mailed me a basic code fix tonight which I think will fit
the new brief nicely. 
I'm going to junk the sleep function in favour of some more basic i/o
stuff, called as and when required, this time. 

But thanks for the help! This was my first post in comp.lang.perl.misc,
but I
think it's a great newsgroup.
 
I also do real programming, by the way, but mainly in other languages.
Most of the stuff available at
 
http://www.visionary-western.co.uk
 
is mine.
 
All the best!
 
John L


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

Date: 18 Nov 1997 18:16:17 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Newbie question regarding DNS
Message-Id: <64tel1$c0u@flatland.dimensional.com>

chrisr@cheese.org (Chris Raettig) writes:

> I have seen on various Internet sites DNS checkers which can search through the
> DNS for a domain name supplied via a form and reply whether or not it has been
> registered. I would be enormously grateful if anybody could point me towards
> where I could obtain a Perl script for performing this task, or supply me with
> any appropriate information.

Check out the gethostbyname and gethostbyaddr functions -- see the
perlfunc and Socket manual pages for details.  For other DNS queries,
you could use the Net::DNS module, available on the Comprehensive Perl
Archive Network (CPAN):

    http://www.perl.com/CPAN/modules/by-module/Net/

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


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

Date: 18 Nov 1997 22:23:36 GMT
From: gbacon@adtran.com (Greg Bacon)
To: mcravit@best.com (Matthew Cravit)
Subject: Re: Q: How many elements in a %HASH ?
Message-Id: <64t4h8$dc2$1@info.uah.edu>

[Posted and mailed]

In article <64sr7u$r2g$1@shell3.ba.best.com>,
	mcravit@best.com (Matthew Cravit) writes:
: In article <EJuvzw.69u@nonexistent.com>,
: Jozsef Hollosi  <hollosi@sbcm.com> wrote:
: >is there a simple way to tell how many elements a hash holds?
: 
:     %foo = ( a => 1, b => 1, c => 1 );
:     
:     print "Number of keys in hash is: ", do { map {$i++} (keys %foo); $i; };
:     print "\n";

An efficient solution would be

    my $k;
    my $count = 0;
    $count++ while ($k, undef) = each %hash;

: As an aside, does anyone know if there are memory or performance issues
: associated with the use of "do" in a context like this? Is this a bad idea
: for any other reason I haven't thought of?

Well, people are likely to grumble about the map in void context (since
you're building up a temporary array and then throwing it away).  There's
also your temporary list of keys (which has substantial impact for a large
hash).  Using each, you keep at most two scalars at a time.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Tue, 18 Nov 1997 22:43:48 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Q: How many elements in a %HASH ?
Message-Id: <EJv5t0.GA1@world.std.com>

Jozsef Hollosi <hollosi@sbcm.com> writes:

>is there a simple way to tell how many elements a hash holds?

According to the perlfunc man page:

       keys HASH
               Returns a normal array consisting of all the keys
               of the named hash.  (In a scalar context, returns
               the number of keys.)

So in your example:

$n = keys %TEST;

As for which is faster or slower:

use Benchmark;

%TEST = map { $_, $_ } 'a' .. 'z';
timethese (100000, {
  use_keys => q($n = keys %TEST;),
  use_loop => q($n=0;while(($k,$v) = each %TEST) {$n++}),
  use_array => q(@TEST=%TEST; $n=@TEST/2)
});
-- 
Andrew Langmead


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

Date: Wed, 19 Nov 1997 01:40:40 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Q: will perlis.dll work w/5.004_02 dist from Gurusamy Sarathy?
Message-Id: <34754355.80175696@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On 18 Nov 1997 15:08:24 GMT, "John Emmerling"
<jemmerli@cscmail.csc.com> wrote:

>I downloaded the Perl 5.004_02 distribution from Gurusamy Sarathy,
>because I understand it makes installation of CPAN modules easier.
>
>I had been using perlis.dll, I am wondering will this still work if I
>install
>the new Perl distribution?

It will not. Perlis.dll is specific to ActiveState's version of Perl
(based on the 5.003_07 build).

Work is underway to merge the ActiveState stuff into the Perl 5.005
core so that it will be more similar across NT/95/Unix/etc.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Tue, 18 Nov 1997 12:55:51 -0800
From: am026@fritz.com (Allan Manayan)
Subject: question on perl runtime
Message-Id: <01BCF421.4D669D80@atis.fritz.com>

hello,

	i need an explation on how perl codes are run under a unix environment.  our
sys admin keeps saying that scripting languages like perl just take too much memory
to run.  does shell script have the same memory requirements as perl.

	any response would be appreciated and please email your response to
amanayan@fritz.com.

thanks,
al manayan
fritz companies
san franciso, ca 94112
415 538-0393




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

Date: Wed, 19 Nov 1997 01:09:02 GMT
From: m.king.garbage@praxa.garbage.com.au (Mike King)
Subject: Re: question on perl runtime
Message-Id: <34723b80.93945957@news.ozemail.com.au>

On Tue, 18 Nov 1997 12:55:51 -0800, am026@fritz.com (Allan Manayan)
wrote:

>hello,
>
>	i need an explation on how perl codes are run under a unix environment.  our
>sys admin keeps saying that scripting languages like perl just take too much memory
>to run.  does shell script have the same memory requirements as perl.

I think that your sysadmin just does not want you to be writing perl
scripts on the system. I find it hard to believe that any real
sysadmin would say that, because they would not be able to do their
jobs without them.

Scripting languages are less efficient than compiled programs, but
then again, they take much less CPU in the development, as there is no
compile phase. Compilers are very good at draining system resources
too !

Good luck

Mike


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

Date: Tue, 18 Nov 1997 22:20:35 GMT
From: blake@pyramus.com (Blake Swensen)
Subject: Regex hell(p)
Message-Id: <64t4b2$uu$1@news.transport.com>

Ok.. I have read the perlop and perlre man pages.  I have looked at the FAQ, 
and studied regex stuff since 5:30 this morning.  I just can't seem to make 
this one task work.

I am trying to parse HTML and obtain ONLY the <TAG>s.  Don't want anything 
between the tags... the inverse of s/<([^>]|\n)*>//g .... any help?

FreeBSD 2.02 and Perl 5.
Blake


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

Date: 18 Nov 1997 23:07:10 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Regex hell(p)
Message-Id: <slrn67480g.kcu.abigail@betelgeuse.wayne.fnx.com>

Blake Swensen (blake@pyramus.com) wrote on 1540 September 1993 in
<URL: news:64t4b2$uu$1@news.transport.com>:
++ Ok.. I have read the perlop and perlre man pages.  I have looked at the FAQ, 
++ and studied regex stuff since 5:30 this morning.  I just can't seem to make 
++ this one task work.
++ 
++ I am trying to parse HTML and obtain ONLY the <TAG>s.  Don't want anything 
++ between the tags... the inverse of s/<([^>]|\n)*>//g .... any help?

You can't use a single regex for it; perl regex aren't powerful
enough. You would need a parser. There is HTML::Parser, but
that doesn't seem to be able to deal with marked sections.


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


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

Date: 18 Nov 1997 23:36:57 GMT
From: rogers@zephyr.instrumental.com (Bob Rogers)
Subject: Returning a hash from an XSUB?
Message-Id: <64t8qp$e5r$1@darla.visi.com>
Keywords: XSUB Perl hash

I've managed to write an XSUB that returns a hash reference, but would
like to know if it's possible to return a hash.  In other words I'd
like an XSUB that can be used like this subroutine:

	# the subroutine:
	sub dogs {
    	local(%doglist);
	    %doglist = (
       		'lassie', 'smart dog',   
			'rintintin', 'brave dog',
        	'benji', 'stupid dog',
    	);
	}

	# the subroutine can be used like this:
	%dog_hash = &dogs;
	print '%dog_hash{\'lassie\'}', $dog_hash{'lassie'}, "\n";

	
My XSUB looks like this:

	void
	ret_hash()
    	PPCODE:
	    HV *myhash;
    	myhash = newHV();
	    hv_store(myhash, "bozo", strlen("bozo"), newSVpv("good clown", 0), 0);
    	hv_store(myhash, "krusty", strlen("krusty"), newSVpv("showbiz clown", 0), 0$
	    hv_store(myhash, "ronald", strlen("ronald"), newSVpv("evil clown", 0), 0);
    	XPUSHs(sv_2mortal(newRV_noinc((SV *)myhash)));

And can be used like this:

	$clowns = &Circus::ret_hash();
	print "krusty: $clowns->{'krusty'}\n";

But I want to be able to say:

	%clowns = &Circus::ret_hash();
	print "krusty: $clowns{'krusty'}\n";

Any advice appreciated (perlxstut is silent on the subject of hashs),
either:
	- how to write the XSUB to return a hash
	- how to convert or assign the XSUB hash reference to a plain old hash

Thanks!


	
-- 
Bob Rogers          (rogers@instrumental.com) (612-603-0292) 
Instrumental, Inc.  (www.instrumental.com) 
St. Paul, MN USA                          



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

Date: 19 Nov 1997 00:17:36 GMT
From: rogers@zephyr.instrumental.com (Bob Rogers)
Subject: Re: Returning a hash from an XSUB?
Message-Id: <64tb70$g86$1@darla.visi.com>
Keywords: XSUB Perl hash

I'm following up myself (following myself up?) but, since I answered
one of my own questions it seems appropriate...

In article <64t8qp$e5r$1@darla.visi.com>,
I <rogers@zephyr.instrumental.com> wrote:

>	$clowns = &Circus::ret_hash();
>	print "krusty: $clowns->{'krusty'}\n";
>
>But I want to be able to say:
>
>	%clowns = &Circus::ret_hash();
>	print "krusty: $clowns{'krusty'}\n";

The way to do this is:

	%clowns = %{&Circus::ret_hash};
	print "bozo: $clowns{'bozo'}\n";

Which creates a new hash (%clowns) and copies the XSUB's hash into
it.  What happens to the XSUB hash?  Is there a possible memory leak?

(I'd still like to know about an XSUB returning a hash rather than a
hash reference.)
-- 
Bob Rogers          (rogers@instrumental.com) (612-603-0292) 
Instrumental, Inc.  (www.instrumental.com) 
St. Paul, MN USA                          



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

Date: 19 Nov 1997 01:01:09 GMT
From: burt@ici.net (Burt Lewis)
Subject: Returning information from an nslookup ??
Message-Id: <64tdol$1u5$1@bashir.ici.net>

Hi,

I'm capturing IP's using "$ENV{'REMOTE_HOST'} from an SSI page. 

I want to then do an nslookup to capture the domain as a variable that I can read back to the 
webpage and write to file.

I have this but I don't know how to return the answer.

print "Content-type: text/html\n\n";


system "nslookup 207.180.0.20";

Appreciate any help on this.


Burt Lewis



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

Date: Tue, 18 Nov 1997 20:50:57 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Returning information from an nslookup ??
Message-Id: <comdog-ya02408000R1811972050570001@news.panix.com>

In article <64tdol$1u5$1@bashir.ici.net>, burt@ici.net (Burt Lewis) wrote:

>I want to then do an nslookup to capture the domain as a variable that I can read back to the 
>webpage and write to file.
>
>I have this but I don't know how to return the answer.
>
>print "Content-type: text/html\n\n";

>system "nslookup 207.180.0.20";

does your script work from the command line?
does the webserver UID know where to find nslookup?

did you check the resources in the CGI Meta FAQ?

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Tue, 18 Nov 1997 19:18:09 -0500
From: Pat Trainor <ptrainor@bbnplanet.net>
Subject: returning value of executed program
Message-Id: <Pine.LNX.3.95.971118190826.30311A-100000@aura>


	Here's a poser:

how to execute a perl script that calls a unix command, and have the
output, not return vaalue, returned as a scalar, an array, hash, whatever.

	For example, execute a who and conduct a regex match on the
output, doing something if a certain user is on-line.

tia...




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

Date: Tue, 18 Nov 1997 20:52:48 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: returning value of executed program
Message-Id: <comdog-ya02408000R1811972052480001@news.panix.com>

In article <Pine.LNX.3.95.971118190826.30311A-100000@aura>, Pat Trainor <ptrainor@bbnplanet.net> wrote:

>        Here's a poser:
>
>how to execute a perl script that calls a unix command, and have the
>output, not return vaalue, returned as a scalar, an array, hash, whatever.

what's a poser?

what happened when you tried using backticks? (`)

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Tue, 18 Nov 1997 17:37:17 -0600
From: Michael Farris <mhfarris@pangea.ca>
Subject: Searching a WORD 6 DOC by line line number
Message-Id: <347226AC.D2083E36@pangea.ca>

I want to write a PERL script to read through a MS Word document and
return a line number where a match occurs.

The problem is the binary line breaks. How can I open the file into an
array that can be read line by line.  I've tried out splitting on \m and
a few others but I'm not sure what WORD uses for its line breaks.

Any help?

Thanks



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

Date: Wed, 19 Nov 1997 01:01:58 GMT
From: m.king.garbage@praxa.garbage.com.au (Mike King)
Subject: Re: Searching a WORD 6 DOC by line line number
Message-Id: <34723a02.93564068@news.ozemail.com.au>

On Tue, 18 Nov 1997 17:37:17 -0600, Michael Farris
<mhfarris@pangea.ca> wrote:

>I want to write a PERL script to read through a MS Word document and
>return a line number where a match occurs.
>
>The problem is the binary line breaks. How can I open the file into an
>array that can be read line by line.  I've tried out splitting on \m and
>a few others but I'm not sure what WORD uses for its line breaks.

They say "a little knowledge is a dangerous thing", and I think they
are right.

Don't try and treat a Word document like a text file, because its not.
Save as text, then run through it, or look at the LAOLA docs for some
more info.

Mike


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

Date: Mon, 17 Nov 1997 22:54:17 -0500
From: , snailgem@aol.com
Subject: spellchecking?
Message-Id: <34711169.5AD1@aol.com>

Is it possible to open a file, spellcheck a portion of it and write the
results to another file using Perl?
If not, what would you recommend?

Thanks.


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

Date: Wed, 19 Nov 1997 01:37:41 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: spellchecking?
Message-Id: <347342bd.80023167@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Mon, 17 Nov 1997 22:54:17 -0500, , snailgem@aol.com wrote:

>Is it possible to open a file, spellcheck a portion of it and write the
>results to another file using Perl?

Sure is.

If someone has written a module which does this, you'll probably find
it on CPAN.

If you write one, please consider submitting it.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: 18 Nov 1997 23:09:11 GMT
From: yevgene@xochi.tezcat.com (E.None Archibald)
Subject: Re: system vs. backtics.  What difference?
Message-Id: <64t76n$662$1@tepe.tezcat.com>

Creede Lambard <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print> wrote:
: Is there a particular reason you have to use that forward slash? If so (like
: if you have to run the same script under both Windows and Unix), why not

: my $a="foo/bar.exe";
: $a =~ s/\//\\/g;

Ouch.

YM,

$a =~ s"/"\\"g; # or someone like him

-e.

: $p = `$a`;
: print $p;

: If not, I'd just use the backslashes and be done with it. Many times it's
: much easier to work your way around a problem than to work your way through
: it. :D


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

Date: Tue, 18 Nov 1997 20:17:48 -0500
From: Mr James <71022.3700@CompuServe.COM>
Subject: Re: Taint checking problem - insecure PATH Part 2
Message-Id: <u14qzjI98GA.352@nih2naac.prod2.compuserve.com>

You're right, CGI.pm does not do taint-checkin

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