[11670] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5270 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 31 16:17:39 1999

Date: Wed, 31 Mar 99 13:00:22 -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           Wed, 31 Mar 1999     Volume: 8 Number: 5270

Today's topics:
    Re: @INC Problem <biwillia@cisco.com>
        CGI help. mircea@earthlink.net
    Re: changing to numeric month (John Stanley)
    Re: changing to numeric month (Larry Rosler)
        compilin perl hpux 11.0 problem <mblackburn@glenraven.com>
    Re: Debugger has problems with forking programs. <Wm.Blasius@ks.sel.alcatel.de>
    Re: Debugger has problems with forking programs. (Ilya Zakharevich)
    Re: dumping db header row before display <ddelikat@protix.com>
    Re: dumping db header row before display (Larry Rosler)
    Re: dumping db header row before display <ddelikat@protix.com>
    Re: flat file query <cassell@mail.cor.epa.gov>
        Help with MSQL REAL inserts <cliff@scs.uiuc.edu>
        HELP! Can't figure out matching $a and /$[b]/ pkuhar@my-dejanews.com
    Re: Help... Running Perl on NT <gregm@well.com>
    Re: my random doesn't return number!! <ddelikat@protix.com>
    Re: my random doesn't return number!! (Larry Rosler)
    Re: netCDF - Perl (I R A Aggie)
    Re: Newbie ques. re cgi script testing <gregm@well.com>
        Perlshop <N.Oosterwijk@neveru.nl>
        print MAIL command. p_wilver@gsvms2.cc.gasou.edu
    Re: Problem... <charles@atheist.com>
    Re: Regex with lookahead help <Allan@due.net>
    Re: Regex with lookahead help <Wm.Blasius@ks.sel.alcatel.de>
    Re: Running a perl script as a daemon.... (Larry Rosler)
    Re: Running a perl script as a daemon.... (Greg Bacon)
    Re: Script produced no output... <fvdm@dds.nl>
    Re: Sorting lines. (Larry Rosler)
    Re: Uninstalling modules???? <zenin@bawdycaste.org>
        Why won't this work? <tdc@haengineers.com>
    Re: Why won't this work? <mamster@mamster.net>
    Re: Win32::Internet FTP question <adwats@spaceweb.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 31 Mar 1999 15:04:52 -0500
From: Bill Williams <biwillia@cisco.com>
To: redaktion@dachs.de
Subject: Re: @INC Problem
Message-Id: <37027FE3.E7D0A520@cisco.com>

use the following syntax:

use lib '/usr/lib/perl5/site_perl/LWP';

-b


Jens Engelbrecht wrote:

> Hello,
>
> I wrote a cgi script using the modul LWP::Simple.
> By running the script on the server I get the following error:
>
> "Can't locate LWP/simple.pm in @INC (@INC contains:
> /usr/lib/perl5/i586-linux/5.00404 /usr/lib/perl5
> /usr/lib/perl5/site_perl/i586-linux /usr/lib/perl5/site_perl .) at
> crawler.pl line 9.
> BEGIN failed--compilation aborted at crawler.pl line 9."
>
> The correct path to LWP::Simple is " /usr/lib/perl5/site_perl/LWP " .
> How do I get the script to look in this directory ?
> Thanks for helping.
>
> Jens Engelbrecht

--
Thanks,
__________________________
Bill Williams
ERP Systems Administrator
Cisco Systems - RTP-IS





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

Date: Wed, 31 Mar 1999 19:05:41 GMT
From: mircea@earthlink.net
Subject: CGI help.
Message-Id: <7dtrlv$ak9$1@nnrp1.dejanews.com>

I created a script in CGI and a form in html. The server gave me an "absolut
path" which is home2/yourdomainname/webdocs  and also they gave me  a "send
mail dir" which is usr/sbin/sendmail  and they told me that these should be
placed in my html form.  I don't know where exactly I should place them and
what the tags will be. They should send the form to the cgi script in cgi-bin
folder.
If this is not the apropriate forum discussion, please kindly direct me there.

Thank you very much, Mitch

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


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

Date: 31 Mar 1999 19:24:19 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: changing to numeric month
Message-Id: <7dtsp3$76$1@news.NERO.NET>

In article <MPG.116b25487b2ce29897f6@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>Congratulations on the slowest hash initialization yet.  Only about 67 
>times slower than the hash access itself.
>
>Hash access:  0 wallclock secs ( 0.63 usr +  0.00 sys =  0.63 CPU)
>Stanley    : 23 wallclock secs (22.13 usr +  0.00 sys = 22.13 CPU)
>Abigail    : 43 wallclock secs (42.44 usr +  0.00 sys = 42.44 CPU)
>Guttman qw : 17 wallclock secs (17.84 usr +  0.00 sys = 17.84 CPU)
>Guttman '' :  9 wallclock secs ( 8.75 usr +  0.00 sys =  8.75 CPU)
>
>As I indicated in the other subthread, a hash lookup is an awfully poor 
>way to address this problem.

You are right. The fastest way to achieve exactly what the original
author wrote is not a hash, it is not an array index, it is to simply
set the variable $monthNumber to 11 (or 12). After all, the only thing
the code he included did was set the name to 'Dec' and then look up
the number to go with it. Much faster to avoid all lookups and to 
code the number directly.



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

Date: Wed, 31 Mar 1999 12:08:46 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: changing to numeric month
Message-Id: <MPG.116c20a698a17abc9897fd@nntp.hpl.hp.com>

In article <7dtsp3$76$1@news.NERO.NET> on 31 Mar 1999 19:24:19 GMT, John 
Stanley <stanley@skyking.OCE.ORST.EDU> says...
> In article <MPG.116b25487b2ce29897f6@nntp.hpl.hp.com>,
> Larry Rosler <lr@hpl.hp.com> wrote:
 ...
> >As I indicated in the other subthread, a hash lookup is an awfully poor 
> >way to address this problem.
> 
> You are right. The fastest way to achieve exactly what the original
> author wrote is not a hash, it is not an array index, it is to simply
> set the variable $monthNumber to 11 (or 12). After all, the only thing
> the code he included did was set the name to 'Dec' and then look up
> the number to go with it. Much faster to avoid all lookups and to 
> code the number directly.

Ho, ho.  I'll add the smiley you left out, so others won't be misled.  

:-)

There!

I'll use this opportunity to quote from the famously misapplied FAQ in 
perlfaq4:  "How can I tell whether a list or array contains a certain 
element?"

<QUOTE>
Hearing the word ``in'' is an indication that you probably should have 
used a hash, not a list or array, to store your data. Hashes are 
designed to answer this question quickly and efficiently.  Arrays 
aren't. 

That being said, there are several ways to approach this. If you are 
going to make this query many times over arbitrary string values, the 
fastest way is probably to invert the original array and keep an 
associative array lying about whose keys are the first array's values.
</QUOTE>

Note the 'probably' and 'many times' and 'probably'.

The idea of using a string to store the data instead of a hash or a list 
isn't even mentioned in the first sentence.  I showed another approach 
that works rapidly and simply for matching a fixed-length string against 
a set of fixed-length strings, where false overlapping of matches isn't 
an issue.  I prefaced it with this:

"Here is my favorite among many ways of doing this:"

It's still my favorite.
 
-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 31 Mar 1999 14:40:31 -0500
From: Marvin Blackburn <mblackburn@glenraven.com>
Subject: compilin perl hpux 11.0 problem
Message-Id: <37027A2F.13C09634@glenraven.com>

I am trying to compile perl 5.004 on HPUX 11.0 with HP's ansi/c
compiler.
I get the following message when I do a make test:

> comp/cpp..........syntax error at comp/cpp.aux line 28, near "print"
> Scalar found where operator expected at comp/cpp.aux line 37, at end
of
> line
>         (Missing semicolon on previous line?)
> syntax error at comp/cpp.aux line 37, near "$x "
> Execution of comp/cpp.aux aborted due to compilation errors.
> FAILED at test 0

Is this significant?
If so, how do I fix it.
We need it for running majordomo.

--
Marvin Blackburn
Systems Administrator
Glen Raven Mills, Inc.
"He's no failure. He's not dead yet"  -- William Lloyd George




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

Date: Wed, 31 Mar 1999 20:16:26 +0200
From: William Blasius #42722 <Wm.Blasius@ks.sel.alcatel.de>
To: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: Debugger has problems with forking programs.
Message-Id: <3702667A.167EB0E7@ks.sel.alcatel.de>

Ilya Zakharevich wrote:
> 
> [A complimentary Cc of this posting was sent to William Blasius #42722
> <Wm.Blasius@ks.sel.alcatel.de>],
> who wrote in article <370245E5.41C67EA6@ks.sel.alcatel.de>:
> > Greetings,
> >
> > I am working on a program that does a bunch of fork/execs of shell
> > processes. The forked process execs almost immediately waits a few
> > seconds and dies. This is expected.
> >
> > I've set some breakpoints later in the parent program, but there's
> > no stopping this thing. Worse than that (I think) is that when all
> > the zombies have been reaped the debugger exits back to the shell!
> >
> > Is this normal behaviour? Is there any way around it? I have tried
> > closing the pipes to the children (from both ends) but that didn't
> > seem to help.
> 
> Posting a message from which one can understand *what* you see and
> *what* you want to see may lead to better results.
> 
> Ilya

I thought that was fairly clear, but I'll try again.

I have a program which spawns a bunch of background shell commands. A
test harness replaces these shell commands with a little script which
writes to STDOUT and STDERR and then exits. The shells are spawned by
 $pid=open(FD, "-|") or error();
 if ($pid==0) {eval {exec "script"} or die "$$: exec failed!\n$@\n";
 exit(0); } else { ...

I set several breakpoints along the exexcution path where the inputs
are evaluated and processed. I type c for continue. If there are any
breakpoints before the forks the debugger behaves normally: it stops
and prints the current line then waits for input. For breakpoints in
the code after the fork, the debugger prints the current line and it
continues executing - ignoring the keyboard. It must catch ^C, and I
have to kill it from another window to stop it. If the breakpoint is
in a loop, that source line gets printed every time around. Finally,
when the program ends, the debugger exits back to the shell prompt.

If the fork is replaced by an assignment to the pid but doesn't fork
the debugger behaves in the documented fashion (for the usual values
of document).

All clear?

Regards,

Wm
--
 ...now I'm <wm.blasius@ks.sel.alcatel.de> - no matter what my mail
server says!


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

Date: 31 Mar 1999 19:43:04 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Debugger has problems with forking programs.
Message-Id: <7dtts8$g22$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to William Blasius #42722 
<Wm.Blasius@ks.sel.alcatel.de>],
who wrote in article <3702667A.167EB0E7@ks.sel.alcatel.de>:
> Ilya Zakharevich wrote:

A blind Cc again!  Please never Cc your postings without marking them
as such.

Anyway, it is too late - I already answered this in private mail.  My
answer was basically:  upgrade and/or learn to write proper bug reports.

Ilya


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

Date: Wed, 31 Mar 1999 13:05:03 -0600
From: David Delikat <ddelikat@protix.com>
Subject: Re: dumping db header row before display
Message-Id: <370271DF.7DE1@protix.com>

tlcora wrote:
> 
> I have a flat text data file.  The first row is the header row and I want to
> remove it before displaying the entries.  Everything else works fine, but I
> can't figure out which perl function to use to remove only the header row
> prior to displaying.  I've looked through the faq several times and also
> searched dejanews using several parameters, yet still can't quite figure it
> out.  Most of the postings deal with deleting a line in a file (faq5), but I
> can't seem to adapt anything to get it to work. Faq4 deals with data, but I
> couldn't find a solution here either. I don't want to edit the file at this
> point, just display the entries without the header row. Could someone point
> me in the right direction?
> 
> commented to show my understanding (or lack there of) of each line.
> 
> open (DATABASE, "$datafile");    # will add error checking later
> while (<DATABASE>)
> {
> $row = $_;      # puts all of the database file into the scalar $row
> chop $row;        # gets rid of \n at the end of the file
> @fields = split (/\|/, $row);   # splits each of the fields delimited by |
> and places them in an array
> print "...<html for @fields snipped>  # outputs the contents of @fields to
> the browser
> close (DATABASE);  # closes $datafile
> }
> 
> TIA!
> tlc-


I read all of the replies and was suppries that no one suggested:

last if $. == 1;

as the first line in the body of the loop.

-dav

-- 
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/


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

Date: Wed, 31 Mar 1999 11:51:44 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: dumping db header row before display
Message-Id: <MPG.116c1ca86b1890039897fc@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <370271DF.7DE1@protix.com> on Wed, 31 Mar 1999 13:05:03 -
0600, David Delikat <ddelikat@protix.com> says...
> tlcora wrote:
> > I have a flat text data file.  The first row is the header row and I want to
> > remove it before displaying the entries.

<SNIP> of lots of unnecessary detail, as you should have done, Dav.

> I read all of the replies and was suppries that no one suggested:
> 
> last if $. == 1;
> 
> as the first line in the body of the loop.

Surely you mean

  next if $. == 1;

because you want to continue processing the rest of the input, not 
abandon it.

David L. Cassell proposed this:

>>   print "html_chazerai" if $. > 1;
>> The $. variable tracks the record number for you.

My problem with these approaches is that it adds processing inside the 
loop, no matter how trivial.  The simple "read and discard the first 
line before entering the loop" seems cleaner logically.

By the way, I won't pick on your spelling of 'surprised' as 'suppries'.  
Then you might get the wrong impression of this newsgroup.  :-) 

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 31 Mar 1999 14:26:22 -0600
From: David Delikat <ddelikat@protix.com>
Subject: Re: dumping db header row before display
Message-Id: <370284EE.6956@protix.com>

Larry Rosler wrote:
> 
> [Posted and a courtesy copy mailed.]
> 
> In article <370271DF.7DE1@protix.com> on Wed, 31 Mar 1999 13:05:03 -
> 0600, David Delikat <ddelikat@protix.com> says...
> > tlcora wrote:
> > > I have a flat text data file.  The first row is the header row and I want to
> > > remove it before displaying the entries.
> 
> <SNIP> of lots of unnecessary detail, as you should have done, Dav.
> 
> > I read all of the replies and was suppries that no one suggested:
> >
> > last if $. == 1;
> >
> > as the first line in the body of the loop.
> 
> Surely you mean
> 
>   next if $. == 1;
> 
> because you want to continue processing the rest of the input, not
> abandon it.
> 

yes, something slipped between my brain and my fingers.  sorry.

> By the way, I won't pick on your spelling of 'surprised' as 'suppries'.
> Then you might get the wrong impression of this newsgroup.  :-)

after your fingers have typed as long as mine then you can pick on
my typos, I assume that you must be younger than I ( in spite of the
image found on your web page. ) if you don't make
mistakes.    :-)

> http://www.hpl.hp.com/personal/Larry_Rosler/

by the way your e-mail address is not working.  I tried sending you mail
directly and got it back undeliverable.

> lr@hpl.hp.com

-dav

-- 
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/


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

Date: Wed, 31 Mar 1999 11:02:28 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: flat file query
Message-Id: <37027144.F0F5C1B2@mail.cor.epa.gov>

Adolphus Harris wrote: 
> 123456789012345678;0987654321;abcdefghsjdurjeudjrues;4040404040404040404040404040404040404040;kskskskskskdjdujfjfjfjfjfkfkfkddkkddddd;wudjdjdjdjdjdjdjdjdjdjdjdjdjdjdotuyterhf;lodjdjdjdjdjdjdjdjdjdjdjdjdjdjdotuyterkt;123;321;12345;312;54321;456;67890;abc;98765;cba;29835;tee;12345.gifThis
> [more stuff snipped]

I'm sorry, but I can't read this.  When you post to this newsgroup,
please make sure your text is formatted properly.  Otherwise, it
is really asking too much of someone to devote their time to
cleaning up the formatting enough that the code can even be read,
much less debugged.

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 31 Mar 1999 13:22:01 -0600
From: Clifford Meece <cliff@scs.uiuc.edu>
Subject: Help with MSQL REAL inserts
Message-Id: <370275D9.2A09F9B8@scs.uiuc.edu>


I'm trying to insert some rows into an accounting database I'm making.
I'm reaaly banging my head against the wall now.  It seems like DBD
refuses to insert the correct values into REAL datatypes. The code
snippet is below:
=================================
    $total_cpu=$cpu_p + $cpu_n;
    $total_cpu = $total_cpu / 60;

    $sth=$dbh->prepare(qq{SELECT _seq FROM charges});
    $sth->execute;
    @rows=$sth->fetchrow_array;
    $seq=$rows[0];

    $disk=$blocks * (512/1048576);

    print "$seq $uid ($user) $date $total_cpu $disk\n";

    $sth=$dbh->prepare(qq{INSERT INTO charges
(chargeID,uid,dateCharged,cpu,disk)
     VALUES ($seq,$uid,'$date',$total_cpu,$disk)});
    $sth->execute;

====================================

I posted this message before, but the code snippet I included was incorrect.

In my attempts to debug, I had tried to surround $disk and $total_cpu with ' '

but msql will complain about wrong types(as it should).  I accidentally included

the snippit with the '' still in it.

the output of the 'print' statement gives values like:

1016,100 (staff),02-Mar-1999,0,0.1484375
1017,101 (gamess),02-Mar-1999,0,9.953125
1018,102 (mab),02-Mar-1999,0,3.26953125
1019,103 (test),02-Mar-1999,0,0.03515625
1020,104 (admin),02-Mar-1999,0,0.0078125
1021,105 (accts),02-Mar-1999,0,0.015625

So I know there are valid values for $total_cpu and $disk. The data that

gets inserted into the table, however, shows :

+----------+----------+-------------+--------------+----------+--------------+----------+
 | chargeID | uid      | dateCharged | cpu          | pages    | disk         | gcg      |
 +----------+----------+-------------+--------------+----------+--------------+----------+

| 1021     | 105      | 02-Mar-1999 | 0            | NULL     | 0.000000     | NULL     |
 | 1020     | 104      | 02-Mar-1999 | 0            | NULL     | 0.0000000    | NULL     |
 | 1019     | 103      | 02-Mar-1999 | 0            | NULL     | 0.00000000   | NULL     |
 | 1018     | 102      | 02-Mar-1999 | 0            | NULL     | 0.00000000   | NULL     |
 | 1017     | 101      | 02-Mar-1999 | 0            | NULL     | 0.000000     | NULL     |
 | 1016     | 100      | 02-Mar-1999 | 0            | NULL     | 0.0000000    | NULL     |

Why all the zeros for disk and cpu?

finally, a relshow of the table:

 +-----------------+----------+--------+----------+--------------+
 |     Field       |   Type   | Length | Not Null | Unique Index |
 +-----------------+----------+--------+----------+--------------+
 | chargeID        | uint     | 4      | Y        | N/A          |
 | uid             | uint     | 4      | Y        | N/A          |
 | dateCharged     | date     | 4      | Y        | N/A          |
 | cpu             | real     | 8      | N        | N/A          |
 | pages           | uint     | 4      | N        | N/A          |
 | disk            | real     | 8      | N        | N/A          |
 | gcg             | uint     | 4      | N        | N/A          |
 | uiddateChargedI | index    | N/A    | N/A      | N            |
 +-----------------+----------+--------+----------+--------------+

It seems to me it has something to do with cpu and disk being reals, but I don't know

how to fix it.  Any ideas?

--
===============================================================
Cliff Meece                      \\ Phone: (217) 333-1728
Unix Systems Administrator       \\ Email: cliff@scs.uiuc.edu
School of Chemical Sciences      \\ 153 Noyes Lab
===============================================================







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

Date: Wed, 31 Mar 1999 20:38:58 GMT
From: pkuhar@my-dejanews.com
Subject: HELP! Can't figure out matching $a and /$[b]/
Message-Id: <7du151$ftr$1@nnrp1.dejanews.com>

Help please! I will really be grateful!
I am having a LOT of trouble, I just started
programming Perl recently.

I think this line is my problem:

if ($input{'userid'} =~ /[$reguser]/){
print "thanks.";
}
else {
print "go away";
}

The problem is, when $input{'userid'} is
flo, and imho $reguser is florence, it prints
thanks. I ONLY WANT IT TO PRINT THANKS IF THERE'S
AN EXACT MATCH!

Help extremely welcome
Patrick

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


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

Date: Wed, 31 Mar 1999 12:09:27 -0800
From: Greg McCann <gregm@well.com>
Subject: Re: Help... Running Perl on NT
Message-Id: <370280F7.9207BF2B@well.com>

You also need to configure your web server so that it knows to *execute* .pl
files - not serve them as text files.  You need to define either a certain file
extension - such as "pl" or "cgi" - or a certain directory - like
"myhome/cgi-bin" as containing cgi programs.

Greg

F. wrote:

> Open regedit and follow this path:
> HKEY_LOCAL_MACHINE, System, CurrentControlSet, Services, W3svc, Parameters,
> ScriptMap
>
> Then add this string value in your register:
> .pl
>
> With this value:
> path/to/perl.exe "%s" "%s"
>
> Restart your PC.
>
> I hope this helps,
>
> Frank.
>
> H.A. wrote in message <7dfta0$hgd$1@News.Dal.Ca>...
> >I've been having so many trouble getting Perl script to run on my NT server
> 4.0
> >that about to quite :-(  I configured everything right according to the
> >instructions and the help I got from the newsgroup.
> >
> >The error I'm getting lately is simply when I click on Submit in one of my
> HTML
> >forms to run the .PL file, it opens a Save As window instead of executing
> the
> >script?  Does anyone out there know why I'm getting that?
> >
> >
> >Any help or hints will greatly be appreciated.
> >Thanks
> >



--

======================
Gregory McCann
http://www.calypteanna.com

"Be kind, for everyone you meet is fighting a great battle."  Saint Philo of
Alexandria




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

Date: Wed, 31 Mar 1999 13:29:20 -0600
From: David Delikat <ddelikat@protix.com>
Subject: Re: my random doesn't return number!!
Message-Id: <37027790.4487@protix.com>

Yannick Girard wrote:
> 
> Hi,
> 
> I'm giving you my code of random generation ...
> 
> CAn you tell me why it's doesn't return any number??
> -------------------------------------------------------
> srand();
> @keys = keys %hash;
> $rand_key = $keys[int rand @keys];
> $numero = $hash{$rand_key};
> --------------------------------------------------------
> 
> Thanks i need a Urgent REsponse!

try this:

$rand_key = $keys[int rand $#keys];

-dav

-- 
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/


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

Date: Wed, 31 Mar 1999 12:16:57 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: my random doesn't return number!!
Message-Id: <MPG.116c2290e85572239897fe@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <37027790.4487@protix.com> on Wed, 31 Mar 1999 13:29:20 -
0600, David Delikat <ddelikat@protix.com> says...
> Yannick Girard wrote:
 ...
> > $rand_key = $keys[int rand @keys];
 ...
> 
> try this:
> 
> $rand_key = $keys[int rand $#keys];

Sorry, dav.  That never gets to the last element in the array.  Ever.  
`perldoc -f rand`:

Returns a random fractional number greater than or equal to 0 and less 
than the value of EXPR. ...

Please season your responses with a pinch of documentation and 
experimentation!

To add a tiny bit of value to this thread:  Putting 'int' into array 
indexes is overkill, because the truncation to int takes place 
automatically (DWIM).

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 31 Mar 1999 20:23:54 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: netCDF - Perl
Message-Id: <slrn7g51lj.2fp.fl_aggie@stat.fsu.edu>

On Wed, 31 Mar 1999 18:28:11 GMT, krish_v@my-dejanews.com
<krish_v@my-dejanews.com> wrote:

+ Is there anyone who can provide sample Perl code
+ for reading files in netCDF format?

<url:http://www.unidata.ucar.edu/packages/netcdf-perl/>

The test program is rather hard to look at (I thought so), but
it covers everything, AFAICT.

James


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

Date: Wed, 31 Mar 1999 11:07:18 -0800
From: Greg McCann <gregm@well.com>
To: wedrawforyou@my-dejanews.com
Subject: Re: Newbie ques. re cgi script testing
Message-Id: <37027266.6F16BB78@well.com>

You can find detailed instructions for doing this at Steve Litt's PERLs of
Wisdom, http://www.troubleshooters.com/codecorn/littperl/perlcgi.htm.

Although he does use a web server to construct the original STD.IN, it's not
absolutely necessary.  You can put together the STDIN text yourself like...
Param1=foo&Param2=goo&AnotherParam=hoo, etc.  Be sure to use proper HTML escape
sequences where needed.

Greg

wedrawforyou@my-dejanews.com wrote:

> Hi,
> Apologies for what might be a real dumb ques. that maybe I should have
> found
> the answer to without wasting bandwidth here but the reading that I
> have done
> so far leaves me unclear. So here's whats tormenting me:
>
> I am
> about to begin learning Perl with the intention of writing scripts to process
> forms that I want to put up at my web site. Once I have a script how do I
> test
> it with forms in a realistic manner. From what I have read so far I need
> access
> to a server, the cgi-bin directory etc. But I plan to develop at home
> on my
> Win 95 PC with no server software on it. So what do I do after I have a
> Perl
> script (assuming I get that far) to see if it would work if someone
> actually filled
> out my form and pressed submit, without having access to a
> web server
> (I still havent rented space from an ISP).
>
> Many many thanks in
> advance,
> Sam G.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own



--

======================
Gregory McCann
http://www.calypteanna.com

"Be kind, for everyone you meet is fighting a great battle."  Saint Philo of
Alexandria




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

Date: 31 Mar 1999 19:03:39 GMT
From: "Nico Oosterwijk" <N.Oosterwijk@neveru.nl>
Subject: Perlshop
Message-Id: <7dtrib$5q1@news3.euro.net>

Is there anyone out there who can help me with the perlshop.cgi file from
Arpanet? I'm new to perl and need help to resolve an error message.
tia,,

Nico Oosterwijk




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

Date: Wed, 31 Mar 1999 15:51:10 -0500
From: p_wilver@gsvms2.cc.gasou.edu
Subject: print MAIL command.
Message-Id: <37028ABE.C69E7D81@gsvms2.cc.gasou.edu>

   Can anyone tell me if it's possible to embed a line feed into a field
that is going to be emailed. I'm submitting an html form with a textarea
field to a perl cgi script which uses the print MAIL command to email it
to me. I want to be able to preserve the line feeds in the textarea
field. I'm using Eudora Light. I've tried /n, and ^M, but, that is
exactly what the email shows (/n or ^M>. I tried typing the keys Ctrl/M
and it did place line feeds in the email, but, it deleted everything
afterward. I'm assuming because it considered it an end of line
character (\n).

Paul Wilver
p_wilver@gsvms2.cc.gasou.edu



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

Date: 31 Mar 1999 19:53:38 GMT
From: "Charles F. Radley" <charles@atheist.com>
Subject: Re: Problem...
Message-Id: <01be7baf$0d927d70$83352293@galileo>


$counter=0;
$string = <>;
@words = split / /,$string;
foreach $word (@words)
{
$counter++ if ($word eq "Perl");
}
print "$string" if ($counter == 2);

You could also do it in fewer lines with an appropriate regular expression.

Frank de Bot <debot@xs4all.nl> wrote in article
<36FFFF46.4EEAACA8@xs4all.nl>...
> I've started to build my own searchengine.
> I have this Keyword: "Perl"
> I have this string to look for matches:  "Free Perl scripts, Get your
> Perl Scripts here" .
> 
> Perl exist 2 times in that string. How can I make the script that it
> count the number of "Perl" (in this case). This should be 2. How can I
> do that automatic?
> Thanks,
> 
> 
> --
> My Email  : debot@xs4all.nl
> Homepages : - http://www.debot.nl/ppi/
>             - More coming up....
> 
> 
> 


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

Date: Wed, 31 Mar 1999 14:35:14 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Regex with lookahead help
Message-Id: <7dtt6o$gln$1@camel25.mindspring.com>

Arthur Newhall wrote in message <7dtlc0$nu42@dilbert.whoi.edu>...
:Hi all,
:    I am having trouble creating a regex to do this
:"match everything up to the first  %  that isn't preceded by a \"
:I seem to be able to do this with a loop, split,... but I would
:rather use a regular expression.
:This is my problem and what I have come up with so far:
:
: $a = 'aa\%bbb%ccc';
:
: ($good) = $a =~ /^(.*)(?!\\)%/;
: print "found: $good \n\n";

I believe this will do what you are after:

($good) = $a =~ /^(.*?[^\\])%/;


HTH

AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
The beginning of wisdom is the definitions of terms.
 - Socrates





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

Date: Wed, 31 Mar 1999 21:43:14 +0200
From: William Blasius #42722 <Wm.Blasius@ks.sel.alcatel.de>
To: Arthur Newhall <anewhall@whoi.edu>
Subject: Re: Regex with lookahead help
Message-Id: <37027AD2.2781E494@ks.sel.alcatel.de>

Arthur Newhall wrote:
> 
> Hi all,
> 
>     I am having trouble creating a regex to do this
> "match everything up to the first  %  that isn't preceded by a \"
> 
> I seem to be able to do this with a loop, split,... but I would
> rather use a regular expression.
> 
> This is my problem and what I have come up with so far:
> 
>         $a = 'aa\%bbb%ccc';
> 
>         ($good) = $a =~ /^(.*)(?!\\)%/;
>         print "found: $good \n\n";
> 
> It works correctly for such things as:
> 
>         aaa%bbb --> aaa
> 
>         %aaa --> nul
> 
>         aaa\%bbb%ccc --> aaa\%bbb
> 
> However, it doesn't work correctly for:
> 
>         aaa%bbb%ccc --> aaa%bbb
> 
>         aaa\%bbb --> aaa\
> 
> It seems like this should be an easy problem to solve but I am
> running into a brick wall. Any suggestions on how to do this
> would be greatly appreciated!
> 
> Thanks,
> Arthur

Try this:

use strict;

my @a = qw(aa\%bbb%ccc aaa%bbb %aaa aaa\%bbb%ccc aaa%bbb%ccc aaa\%bbb);
foreach $a (@a) {
    (my $good) = $a =~ /^(.*?[^\\])%/;
    printf "had: '%s' found: '%s'\n", $a, defined $good ? $good :
"undef";
};

Regards,
Wm Blasius
Stuttgart
-- 
 ...now I'm <wm.blasius@ks.sel.alcatel.de> - no matter what my mail
server says!


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

Date: Wed, 31 Mar 1999 11:43:52 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Running a perl script as a daemon....
Message-Id: <MPG.116c1ad22b91b6879897fb@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <37026B6C.2F1C@protix.com> on Wed, 31 Mar 1999 12:37:32 -
0600, David Delikat <ddelikat@protix.com> says...
> Tad McClellan wrote:
> > Diggy Tim (tim@diggy.com) wrote:
> > : Subject: Re: Running a perl script as a daemon....
> >                                           ^^^^^^
> >                                           ^^^^^^
> > 
> > : How do I go about running a perl script from the command line and have it
> > : sit in the background and not die when I log out.
> > 
> >    What happened when you did a word search in the Perl FAQs
> >    before posting?
> 
> oh for crying out loud, I just joined this group and the first thing I 
> see is some bonehead picking on spelling, and it isn't even wrong.
> it just isn;t the spelling he likes.  I might just as well turn around
> and go home.

Cool it, Dav, and hang around for a while.  Tad is not a bonehead 
(though he isn't *always* right), and he was not picking on spelling -- 
he was simply (too simply, I guess :-) trying to point out to the 
submitter the word to search for.

(Though why my old friends in Unix-land chose to use a Late Latin 
variant spelling of a common English word escapes me.  As an ex-
physicist, I always found "Maxwell's Demon" completely acceptable 
spelling.)

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 31 Mar 1999 20:57:16 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Running a perl script as a daemon....
Message-Id: <7du27c$nof$1@info2.uah.edu>

In article <37026B6C.2F1C@protix.com>,
	David Delikat <ddelikat@protix.com> writes:
: oh for crying out loud, I just joined this group and the first thing I 
: see is some bonehead picking on spelling, and it isn't even wrong.

Oh, for crying out loud!  I've been reading this newsgroup for a long
time, and I constantly see boneheads delurking before they ought to.
Those boneheads are invariably wrong. :-(

Greg
-- 
Artifical insemination is when the farmer does it to the cow instead of the
bull. 
    -- Funny Answers to Science Test Questions


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

Date: Wed, 31 Mar 1999 21:12:56 +0200
From: "Frank" <fvdm@dds.nl>
Subject: Re: Script produced no output...
Message-Id: <7dtrp1$rh$1@news2.xs4all.nl>

Well, SSI works as far as I can see. So let me be more specific.

I'm using NT4, IIS 4 and ActivePerl (or whatever the folks at ActiveState
call it). I've been running several SSI scripts with no problem using
perl.exe.

For the usual reasons, I'd like to convert my SSI scripts so that they run
under perlis.dll. I figured that I'd simply rename the scripts to *.plx and
be done with it. Didn't work.

Interestingly, if I run the scripts directly from the URL (as in
http://www.mysite.com/cgi-bin/myscript.plx) they execute as they are
intended. But if I try to run them inside an HTML page as a SSI, then I get
the following output:

HTTP/1.0 200 OK Date: Mon, 15 Mar 1999 20:08:51 GMT Server:
Microsoft-IIS/4.0
Content-type: text/html 'c:\webroot\www.mysite.com\web\scriptpage.html'
script produced no output"

Why would it work from the URL, but not from the SSI? As I mentioned, I'm
already running several SSI scripts using perl.exe already without a
problem.

You would make my day if you got the answer...

Frank

Steve Linberg wrote in message ...
>In article <7dt86q$4if$1@news2.xs4all.nl>, "frank" <fvdm@dds.nl> wrote:
>
>> I'm trying to use the perlis.dll with SSI.
>> When I run the script from an URL it works fine, but when I'm trying to
call
>> it with SSI it produces no output...
>>
>> What am I doing wrong ?
>
>Your server may not be configured to properly handle SSI, for a start.
>Begin with your server's documentation and get a simple SSI working; after
>that you know it's a code problem.
>
>--
>Steve Linberg, Systems Programmer &c.
>National Center on Adult Literacy, University of Pennsylvania
>email: <linberg@literacy.upenn.edu>
>WWW: <http://www.literacyonline.org>




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

Date: Wed, 31 Mar 1999 11:34:10 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting lines.
Message-Id: <MPG.116c188bf3f585979897fa@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7dtnub$74j$1@nnrp1.dejanews.com> on Wed, 31 Mar 1999 
18:01:52 GMT, jambutter@my-dejanews.com <jambutter@my-dejanews.com> 
says...
> I want to sort the lines of a file, is there anyway to do this without using
> an array?

Somewhere there has to be a list to sort.  It may be the original data, 
or keys derived from the data, or indexes or seek positions to the data.  
But there must be a complete list.  (One can do it with several lists, 
and then merge the results, but that is beyond the scope of the Perl 
'sort' function.)

> I've assumed so and am trying to use an array. Each element of the array will
> be something like "abc.def". I want to sort on everything after the '.' (if
> equal, ideally, I'd like to then search on everything before the '.').

No problemo.  Why 'ideally'?  This is a typical use of sorting.

> This is what I've tried so far:
> 
> @array = sort by_afterdot @array.
> 
> sub by_afterdot
> {
> 	$a =~ /\./;
> 	$a = $';
> 	$aa = $`;
> 
> 	$b =~ /\./;
> 	$b = $';
> 	$bb = $`;
> 
> 	($a cmp $b) || ($aa cmp $bb);
> }
> 
> Unfortunately, I do not seem to get anywhere near the result I want when I do
> a print.
> 
> What am I doing wrong?

There are lots of things you could be doing *better*.  But what you are 
doing wrong specifically is overlooking that $a and $b are not copies of 
the sort operands -- they are aliases to the sort operands.  So your 
assignments to $a and $b change the data you print out.

Here is the relevant excerpt from `perldoc -f sort`:

"... the two elements to be compared are passed into the subroutine not 
via @_ but as the package global variables $a and $b (see example 
below). They are passed by reference, so don't modify $a and $b."

> Also, if I am trying to get everything after the . of a string, is the method
> I've used best?  Or should I use split?

It is best not to use $' and $` at all, for reasons detailed in perlvar.  
Use capturing parentheses instead.  To get everything after the *first* 
'.' of a string:

   my ($before, $after) = $string =~ /^([^.]*)\.(.*)/s;

With split:

   my ($before, $after) = split /\./, $string, 2;

It could also be done with 'index' and 'substr'.

Benchmarks could decide between them.  However, benchmarking an 
inherently slow approach is not fruitful.  You should learn more about 
how to sort efficiently (i.e., not repeating the processing of each 
operand every time it is compared to another operand, but once each 
only).  After you have devoured the documentation at `perldoc -f sort`, 
continue with perlfaq4:  "How do I sort an array by (anything)?"

Oh, by the way, also add '-w' to your perl invocation, and 'use strict;' 
as the first line of your program.  Then you won't be blithely creating 
global variables like the $aa and $bb in your sort subroutine.  And all 
other kinds of goodness will ensue.

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 31 Mar 1999 20:35:05 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Uninstalling modules????
Message-Id: <922912561.459039@thrush.omix.com>

In comp.lang.perl.moderated Craig Hobbs <craigh@visio.com> wrote:
: Seems that there's volumes of information on installing modules.  What about
: uninstalling a module?  Is there any reliable way to do this?  Or does one
: just have to start deleting files?

	MakeMaker creates a deinstall (uninstall?) target, but I don't think
	it's stable.  I normally just find the .packlist for the
	distribution and use that:

	rm `cat /usr/local/lib/perl5/site_perl/5.005/i386-freebsd/auto/Tk/.packlist`

	This won't delete the directories however.  You'll have to find and
	remove them yourself.

	I've been thinking of working out a registry system into MakeMaker
	similar to FreeBSD's package management system.  One that could
	handle dependencies and such cleanly (forbid you from removing
	modules that are relied on by other modules without a 'force'
	option, etc).  If anyone else wants to pick up the idea and run
	with it, go right ahead. :-)

-- 
-Zenin (zenin@archive.rhps.org)

        Yah, Emacs is a good OS, but I prefer FreeBSD.


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

Date: Wed, 31 Mar 1999 20:01:12 GMT
From: "tc" <tdc@haengineers.com>
Subject: Why won't this work?
Message-Id: <cavM2.139$ku3.137890@client.news.psi.net>

1.     if ($FEXISTS eq "NO") {
2.         $file = 'ws_ftp.log';
3.        $dirname = "c:\\cgi\\";
4.        open(INFILE, $dirname."$file") or die "Error: $!\n";
5.        open(OUTFILE, ">$FILEDIR"."test".".html") or die "Error: $!\n";
6.        while(<INFILE>) {
7.            print OUTFILE "$_"; }
8.        close(OUTFILE);
9.        close(INFILE);  }

I am running this script on a unix server, and using a win95 station with
netscape 4.0 to run it.
It works fine if $file points to a file on the server.

I get a 'no such file or directory error' at line 4. I have tried every
slash combination I could think of, but still no luck.

Could someone help me out?

Thanks,






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

Date: Wed, 31 Mar 1999 15:12:44 -0500
From: Matthew Amster-Burton <mamster@mamster.net>
Subject: Re: Why won't this work?
Message-Id: <Pine.GSO.3.96.990331150914.10571A-100000@wired.your-site.com>

On Wed, 31 Mar 1999, tc wrote:

> 1.     if ($FEXISTS eq "NO") {
> 2.         $file = 'ws_ftp.log';
> 3.        $dirname = "c:\\cgi\\";
> 4.        open(INFILE, $dirname."$file") or die "Error: $!\n";
> 5.        open(OUTFILE, ">$FILEDIR"."test".".html") or die "Error: $!\n";
> 6.        while(<INFILE>) {
> 7.            print OUTFILE "$_"; }
> 8.        close(OUTFILE);
> 9.        close(INFILE);  }
> 
> I am running this script on a unix server, and using a win95 station with
> netscape 4.0 to run it.
> It works fine if $file points to a file on the server.

That's because the script is running on the server.  You can't have a
remote CGI script access a file on the machine the browser lives on
without some networking contortions.  Imagine the security risk if your
script were allowed to open arbitrary files on my hard drive.

Also, your quotes around $file on line 4 are irrelevant.  The usual way to
do MSDOS-style paths is one of the following:

'c:\cgi\'
"c:/cgi/"

Forward slashes work fine.

Matthew



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

Date: Wed, 31 Mar 1999 15:35:13 -0500
From: "Andy Watts" <adwats@spaceweb.com>
Subject: Re: Win32::Internet FTP question
Message-Id: <CMvM2.543$eJ.101656@news.shore.net>

Win32::Internet WAS the alternative to the Net::FTP module of which the
program started with.  Ah well.

Back to the drawing board, thanks anyway.
- Andy Watts

>
>Without delving into what you may or may not be doing wrong in your code,
>I'd suggest you take a gander at Net::FTP as an alternative module.
>It will accomplish what you desire, works well (for me, at least), and is
>documented fairly well.  I've run it on NT boxes, etc., and have gotten
>the results I wanted (cleaner cleans, fresher breath, more zip).





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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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