[13271] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 681 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 30 17:07:58 1999

Date: Mon, 30 Aug 1999 14:05:09 -0700 (PDT)
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, 30 Aug 1999     Volume: 9 Number: 681

Today's topics:
        Bug in Julian.pm (Bert Tijhuis)
    Re: checking return status on system() (Larry Rosler)
    Re: File listing (Larry Rosler)
    Re: File listing <gellyfish@gellyfish.com>
    Re: How to develope CGI scripts with ActivePerl for Win <zylou@altern.org>
    Re: How to do this... <makkulka@cisco.com>
    Re: How to do this... (Larry Rosler)
    Re: How to do this... (Larry Rosler)
    Re: How to do this... <rolf.raven@quantis.nl>
        how to make sort() case insensitive? <baal@c2i.net>
        How to store results of one query to use for another -  <webdev@gstockco.com>
    Re: identifying an empty line (Matthew Bafford)
    Re: Perl Y2K Bugs on the Internet <cmcurtin@interhack.net>
    Re: Perl Y2K Bugs on the Internet (Larry Rosler)
    Re: Perl Y2K Bugs on the Internet <jbc@shell2.la.best.com>
        printf rounding question (Burt Lewis)
    Re: printf rounding question (Larry Rosler)
    Re: printf rounding question <makkulka@cisco.com>
    Re: Random number (Glenn Paulsen)
    Re: Random number (Glenn Paulsen)
    Re: Random number (Larry Rosler)
    Re: Ready to get to work but... (Greg Bacon)
    Re: SHTML and PERL <Allan@due.net>
    Re: Spawn a Web process <gellyfish@gellyfish.com>
    Re: Subst text in file with variable contents <rolf.raven@quantis.nl>
    Re: Testing files on cd-rom? <laurensmith@sprynet.com>
    Re: Want to use PERL to run script on another server. <Mark.Conlin@bridge.bellsouth.com>
    Re: writing to a file within a loop <tbornhol@prioritytech.com>
    Re: writing to a file within a loop (Larry Rosler)
    Re: writing to a file within a loop <makarand_kulkarni@my-deja.com>
    Re: writing to a file within a loop (Larry Rosler)
    Re: writing to a file within a loop <rolf.raven@quantis.nl>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Mon, 30 Aug 99 18:16:16 GMT
From: B.Tijhuis@inter.NL.net (Bert Tijhuis)
Subject: Bug in Julian.pm
Message-Id: <7qei2g$9id$2@zonnetje.nl.uu.net>

Bug in Julian.pm

Since a short time a little bug is discovered in the Julian.pm 
module.
It doesn't show the date date 29 feb of a leap year.

It is solved now and the new version could be found at.

http://www.inter.NL.net/users/B.Tijhuis/perl.html


or

The module:     
http://www.inter.NL.net/users/B.Tijhuis/perl/Julian.pm 

or the complete install package

http://www.inter.NL.net/users/B.Tijhuis/perl/Julian_01.tar.gz


Users of this module should upload this newer version. 

regards, Bert Tijhuis






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

Date: Mon, 30 Aug 1999 12:11:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: checking return status on system()
Message-Id: <MPG.1234772c5e9c9e90989eda@nntp.hpl.hp.com>

In article <37CAB2BF.E154C7CF@nortelnetworks.com> on Mon, 30 Aug 1999 
09:35:11 -0700, Brandon Metcalf <bmetcalf@nortelnetworks.com> says...
> I've written a Perl job where I'm making quite a few system() calls.
> Instead of doing something like
> 
> system("exec this") && die "system() failed\n";
> 
> I've written a simple function _system() that looks like
> 
> sub _system
> {
>    my ($cmd) = @_;
>    system("$cmd") && die "system() call failed on $cmd\n";
> }
> 
> 
> Using this I don't have to use system() and check the return status for
> every system() call I want to make.  I simply say something like
> 
> _system("exec this");
> 
> 
> Is this fairly efficient or is there a better way of doing this?

Considering that system() spawns another process, the overhead of 
building it into a subroutine is negligible.  What you are attempting is 
a Good Thing.  However:

Naming a user subroutine wih a name beginning with an underscore is a 
Bad Thing.  By convention, it implies a reserved name, not to be used by 
an application.

     system("$cmd") && die "system() call failed on $cmd\n";

The quotes aroung $cmd in the argument are superfluous and misleading.

You would achieve more generality by replacing $cmd by @cmd throughout 
your subroutine (and then the quotes in the subroutine call would be 
damaging as well).

The diagnostic should include the reason for the failure, which is in 
$?, a special variable that you can learn about by reading perlvar.

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


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

Date: Mon, 30 Aug 1999 11:50:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: File listing
Message-Id: <MPG.1234725fd60ebb2989ed8@nntp.hpl.hp.com>

In article <37CAA968.C9CD86A0@quantis.nl> on Mon, 30 Aug 1999 17:55:20 
+0200, Rolf Raven <rolf.raven@quantis.nl> says...
> Abigail wrote:
> > 
> > Rolf Raven (rolf.raven@quantis.nl) wrote on MMCXC September MCMXCIII in
> > ||      opendir THISDIR, "." or die "$!";
> > ||      @allfiles = readdir THISDIR;
> > ||      closedir THISDIR;
> > ||      print "@allfiles\n";
> > 
> > And that selects the files matching a specific criteria exactly how?
> 
> Well... you know... uhm... yeah... just write "*.txt" instead of "."

That will work if the goal is to open a directory named '*.txt'.  Hardly 
likely!

What Abigail had in mind was:

            @allfiles = grep /\.txt$/i => readdir THISDIR;

> And yes, I know you should use 'glob'... 

I can't imagine why anyone would ever use 'glob', a fossil that should 
be ignored.

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


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

Date: 30 Aug 1999 19:48:34 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: File listing
Message-Id: <7qen6i$5di$1@gellyfish.btinternet.com>

On Mon, 30 Aug 1999 17:55:20 +0200 Rolf Raven wrote:
> Abigail wrote:
>> 
>> Rolf Raven (rolf.raven@quantis.nl) wrote on MMCXC September MCMXCIII in
>> ||      opendir THISDIR, "." or die "$!";
>> ||      @allfiles = readdir THISDIR;
>> ||      closedir THISDIR;
>> ||      print "@allfiles\n";
>> 
>> And that selects the files matching a specific criteria exactly how?
> 
> Well... you know... uhm... yeah... just write "*.txt" instead of "."

Ding!! Next contestant please ...

I wont offer that for a bonus point but will just refer the original
poster to the documentation for the Perl builtin grep().

> And yes, I know you should use 'glob'... 

Possibly.

/j\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Mon, 30 Aug 1999 20:53:19 +0200
From: Nathan ZYLBERSZTEJN <zylou@altern.org>
Subject: Re: How to develope CGI scripts with ActivePerl for Windows?
Message-Id: <37CAD31F.93CC2C13@altern.org>

Working on your local computer, you need to install a http server. You can
download sambar at www.sambar.com, easy to install and it works directly.

nati wrote:

> Hi!
>
> I appriciate help on simple question (or is it simple? :)
>
> I want to write CGI scripts in Perl, so I have downloaded and installed
> ActivePerl. Now I want to tryout scripts in Perl on my computer (mailing
> lists and stuff). When I install them on server, they are working without
> problems. But what do I have to do when I want that offline? Do I have to
> simulate (and how) server on my computer, or ... Anyway, when somebody makes
> webmastering and uses this, Paar of hints would be useful.
>
> Dino



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

Date: Mon, 30 Aug 1999 12:00:12 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: How to do this...
Message-Id: <37CAD4BC.4E3C6AE8@cisco.com>

[ "Eirik Johansen [netmaking.com]" wrote

> I have a file opened using a filhandle called "MAILS". I'm
> looping through the lines using a while loop. Well, this is what
> I want the script to do. When it encounters a line in the
> text-file which consists only of a newline, I want it to read the
> next four lines (excluding the line which only consists of a
> newline) into a variable for further editing.

Imagine you are reading from STDIN --
while (<>)
{
  if ( $_=~/^$/)
    {
    my    $next_four=  <>.<>.<>.<> ;
    # do your other processing here..
    }
}

There are two ways to find if a line is an empty line.

  unless (length $line) {
      # line is empty
      # this snippet is from Larry Rosler's reply to an earlier post in
this newsgroup..
  }

or

match with regexp  /^$/ as I have done.
---




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

Date: Mon, 30 Aug 1999 12:32:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to do this...
Message-Id: <MPG.12347c2f95c43570989edc@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <37CAC212.E9C2A3F3@netmaking.com> on Mon, 30 Aug 1999 
19:40:35 +0200, Eirik Johansen [netmaking.com] <eirik@netmaking.com> 
says...
> Hi,

Hi.  A more descriptive subject would be in order if you post here 
again.

 ...

> I have a file opened using a filhandle called "MAILS". I'm
> looping through the lines using a while loop. Well, this is what
> I want the script to do. When it encounters a line in the
> text-file which consists only of a newline, I want it to read the
> next four lines (excluding the line which only consists of a
> newline) into a variable for further editing. (The fifth line
> always starts with "From:" if that's of any help to you.)

There are several ways.  Here is the most straightforward:

#!/usr/local/bin/perl -w
use strict;

while (<DATA>) {
    if (/^$/) {
      my $four_lines;
      $four_lines .= <DATA> for 1 .. 4;
      print $four_lines; # or whatever you want to do
    } else {
      # do something else
    }
}
__END__
line0

line1
line2
line3
line4
From: whoever


However, there is a nicer way, using the input record separator $/.  
Replace the inner block by:

      local $/ = "\nFrom:";
      chomp(my $any_number_of_lines = <DATA>);
      print "$any_number_of_lines\n"; # or whatever you want to do

or:

      local $/ = "\nFrom:";
      my $any_number_of_lines = substr <DATA>, 0, -5;
      print $any_number_of_lines; # or whatever you want to do
 
In each case, the 'From:' is gone, but you know it was there!

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


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

Date: Mon, 30 Aug 1999 12:41:12 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to do this...
Message-Id: <MPG.12347e2e18c27e89989ede@nntp.hpl.hp.com>

In article <37CAD4BC.4E3C6AE8@cisco.com> on Mon, 30 Aug 1999 12:00:12 -
0700, Makarand Kulkarni <makkulka@cisco.com> says...
 ...
> Imagine you are reading from STDIN --
> while (<>)
> {
>   if ( $_=~/^$/)
>     {
>     my    $next_four=  <>.<>.<>.<> ;
>     # do your other processing here..
>     }
> }
> 
> There are two ways to find if a line is an empty line.
> 
>   unless (length $line) {
>       # line is empty
>       # this snippet is from Larry Rosler's reply to an earlier post in
> this newsgroup..
>   }

But it doesn't work here, because the newline hasn't been chomped away.  
You could use 'if (length == 1) {'.

> or
> 
> match with regexp  /^$/ as I have done.

Yes, as you will see when my response to this problem appears.

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


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

Date: Mon, 30 Aug 1999 22:36:51 +0200
From: Rolf Raven <rolf.raven@quantis.nl>
Subject: Re: How to do this...
Message-Id: <37CAEB63.2F71C5C2@quantis.nl>

How to do this? Ah wait, if I read the entire post, I will know what needs
to be done. Alright then...

Eirik Johansen [netmaking.com] wrote:
> 
> I have a file opened using a filhandle called "MAILS". I'm
> looping through the lines using a while loop. Well, this is what
> I want the script to do. When it encounters a line in the
> text-file which consists only of a newline, I want it to read the
> next four lines (excluding the line which only consists of a
> newline) into a variable for further editing. (The fifth line
> always starts with "From:" if that's of any help to you.)

Why not do this (there's probably a more efficient way of doing it):

open(MAILS,"mailfile");
while (<MAILS>) {
    if ($_ eq "\n") {
        for ($i=0;$i<4;$i++) { <MAILS>; }
    } else { print $_; }
}
close MAILS;


Hope this helps,
floR


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

Date: Mon, 30 Aug 1999 20:36:14 GMT
From: "[L] Vicious!" <baal@c2i.net>
Subject: how to make sort() case insensitive?
Message-Id: <2XBy3.1414$I5.142252@juliett.dax.net>

Hi, simple question, the sort() function sorts the contents of an array in
this order a-z then A-Z (and then 0-9 I think, but thats not too important).
Is there a way to make the function case insensitive (a=A - z=Z)?

Thnx!




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

Date: Mon, 30 Aug 1999 16:13:22 -0400
From: "Brian Tully" <webdev@gstockco.com>
Subject: How to store results of one query to use for another - msql & perl
Message-Id: <pHBy3.747$kf5.45493@iad-read.news.verio.net>

I would greatly appreciate any help/advice on my following dilemma:

Using Perl and mSQL, I am trying to write a CGI script that will use the
results of one query and match it with another query.

The first query queries a "regions" table: select DealerCodes from regions
where SalesRegions clike '8' (i.e., which DealerCodes are in SalesRegion 8).
The results should be a list of about 6 different DealerCodes.

I'd like to take those results and use it in my next query so I can match up
the DealerCodes with Username, DealerName and other info.  This info is
stored in a different table, "users".

Is there any way I can make a query such as select Username, DealerName from
users where DealerCode = $DealerCodes (where $DealerCodes is the results of
the previous query)?  I've tried several things such as saving the results
as a hash and an array but I haven't been able to figure out how to get the
second query to try to match each of the DealerCodes.  Below is some things
I've tried without success:

    $sth = $dbh->query("select DealerCode from regions where $Function clike
'$RegionNum' order by DealerCode");

  unless ($sth) {

   $errmsg = $dbh->errmsg;
   &error_routine("There was a database error: $errmsg.<BR>");
   &check_errors;
  }

  %DealerCodes;

  while (%DealerCodes = $sth->fetchhash) {

   $sth = $dbh->query("select
FirstName,LastName,Username,PinNumber,DealerCode,DealerName from users where
DealerCode = $DealerCodes{DealerCode}");
  }

########################


     $sth = $dbh->query("select DealerCode from regions where $Function
clike '$RegionNum' order by DealerCode");

  unless ($sth) {

   $errmsg = $dbh->errmsg;
   &error_routine("There was a database error: $errmsg.<BR>");
   &check_errors;
  }

  (@DealerCodes) = $sth->fetchrow;

     foreach $region (@DealerCodes) {

   $sth = $dbh->query("select
FirstName,LastName,Username,PinNumber,DealerCode,DealerName from users where
DealerCode = $region");
  }

(This one only lists the results of the first DealerCode)


Any ideas what I'm doing wrong?

Many thanks in advance,
Brian


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

Date: Mon, 30 Aug 1999 19:10:26 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: identifying an empty line
Message-Id: <slrn7slk97.ue.*@dragons.duesouth.net>

On 30 Aug 1999 08:17:34 -0500, Abigail) held herself at gunpoint, and
typed the following into comp.lang.perl.misc:
: Matthew Bafford (me!) (*@dragons.duesouth.net) wrote on MMCXC September
: MCMXCIII in <URL:news:slrn7skiok.n5.*@dragons.duesouth.net>:
: "" 
: ""     !($a =~ /\S/)
: 
: I would write that as $a !~ /\S/;

I probably would, too.

: ""     $a =~ /^$/
: 
: Note that this will match a string consisting of a single newline.

True, but C</^\z/> is too ugly for my tastes.  I prefer C<$>, but it doesn't
always DWIM.

: ""     !(() = split /./, $a)
: 
: split /fubblefur/ would work as well.

True, and your version is much more elegant. :-)

Self documenting code:

!(() = split / $a to find out if there are any chars in /, $a)

: Abigail

--Matthew


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

Date: 30 Aug 1999 14:10:04 -0400
From: Matt Curtin <cmcurtin@interhack.net>
Subject: Re: Perl Y2K Bugs on the Internet
Message-Id: <xlx7lmdnnr7.fsf@gold.cis.ohio-state.edu>

>>>>> On 30 Aug 1999 13:26:37 -0400, catfood@apk.net (Mark W. Schumann) said:

Benjamin> The Pink Camel said "don't worry about it."  Worse - it
Benjamin> didn't mention 'ctime' in relation to tm structs and on page
Benjamin> 321 it actually *used* "19$year"!

The struct tm relationship was specifically mentioned in both the
documentation for gmtime() and localtime(), both of which were given
appropriate attention by other things that would be seen by folks
looking for what they need to know.

The lack of attention to the year element of that array was indeed a
deficiency, especially in the case of gmtime() where it says that the
"only" significant part of the struct tm relationship is that some
elements begin at zero instead of one.

Mark> Your example from the Pink Camel is indeed apalling if true.

The page 321 example is correct; I just verified it.

-- 
Matt Curtin cmcurtin@interhack.net http://www.interhack.net/people/cmcurtin/


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

Date: Mon, 30 Aug 1999 11:38:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Y2K Bugs on the Internet
Message-Id: <MPG.12346f6e1b5c40ab989ed6@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.  Java crossposts removed.]

In article <37c9ba63.1577006@news.skynet.be> on Sat, 28 Aug 1999 
10:54:10 GMT, Bart Lateur <bart.lateur@skynet.be> says...
 ...
> And I'm pretty sure that in the original design, tm_year was intended to
> return the year in 2 digits. All that "years since 1900" nonsense is
> nothing but a backward compatible patch.

I can't speak for 'the original design', which occurred before I got 
involved with the Standard C Library.  I don't have ancient Unix 
documentation available.  But I can vouch for the existence of the 
following lines in a Bell Labs Technical Memorandum that I co-wrote 
dated October 11, 1978:

  The structure definition in the <time.h> header file is:

    struct tm {
      int tm_sec;       /* 0 to 59 */
      ...
      int tm_mon;       /* 1 to 12 */
      int tm_year;      /* year - 1900 */
      ...

Comments on the selected lines:

tm_sec:  The bogosity of 0 to 60 or 61 had not yet appeared.  A 1988 
book ('The C Book: Featuring the Draft ANSI C Standard', by Mike 
Banahan) still has 59, but the Standard itself (begun in 1983, adopted 
in 1990) has 61.  I don't recall who is to blame -- perhaps Bill Plauger 
(chair of the Library Subcommittee), probably not me!  There is no 
comment on localtime() in the accompanying Rationale, primarily authored 
by Plauger.

tm_mon:  My hand-written notes say this:  'check on UNIX & fix if 
wrong!'  'it is 0-11 on Research!'  'AND on USG!!'  So my reasonable 
conjecture was wrong, and was corrected in the next release of the memo, 
dated January 2, 1980.

tm_year:  I have no evidence to support Bart's dismissive statement 
about 'nonsense is nothing but a backward compatible patch.'  I know of 
no document that shows 'tm_year was intended to return the year in 2 
digits.'  Accusing Dennis Ritchie and Ken Thompson of short-sighted 
dumbness -- and the rest of us of chicanery -- is rather offensive, and 
perhaps an apology is in order.  

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


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

Date: 30 Aug 1999 18:47:35 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Perl Y2K Bugs on the Internet
Message-Id: <37cad1c7$0$207@nntp1.ba.best.com>

Mark W. Schumann <catfood@apk.net> wrote:
>>Worse - it didn't mention 'ctime' in relation to tm structs 
>>and on page 321 it actually *used* "19$year"! 

> Your example from the Pink Camel is indeed apalling if true.

It's in there, in the "real programming examples" chapter (or whatever
that was called). I had to see it to believe it myself. Though I didn't
bother checking to see where, exactly, the $year variable came from.

It was actually kind of fun to dust off the old girl and flip through
the pages. Perl documentation (to say nothing of the language itself)
has certainly come a long way.

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Mon, 30 Aug 1999 19:18:10 GMT
From: burt@ici.net (Burt Lewis)
Subject: printf rounding question
Message-Id: <SNAy3.3040$Se.6821@news.goodnet.com>

Hi,

I'm doing some calculations of averages and want the answers to appear like:

 .679
 .233
 .333

My script as I have it returns:

0.679
0.233
0.333

This is what I have so far:
$pct301 = (4/6);
printf ("%.3f%s", $pct301, '%');

displays:

0.667%
==============================

I'm looking to get just .667

Appreciate any help!

Burt Lewis



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

Date: Mon, 30 Aug 1999 12:54:27 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: printf rounding question
Message-Id: <MPG.1234814dae90bc989edf@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <SNAy3.3040$Se.6821@news.goodnet.com> on Mon, 30 Aug 1999 
19:18:10 GMT, Burt Lewis <burt@ici.net> says...
 ...
> $pct301 = (4/6);
> printf ("%.3f%s", $pct301, '%');
> 
> displays:
> 
> 0.667%
> ==============================
> 
> I'm looking to get just .667

If you don't want a trailing '%', don't print one.  :-)

Here is a one-liner solution, which would also work for numbers >= 1:

  print +((sprintf "%.3f", $pct301) =~ /^0*(.*)/);

Another way (simpler, brute-force, non-negative numbers only):

  print '.' . int($pct301 * 1000 + 0.5);

or

  print '.', int($pct301 * 1000 + 0.5);

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


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

Date: Mon, 30 Aug 1999 12:51:21 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: printf rounding question
Message-Id: <37CAE0B9.6084B3F4@cisco.com>

[ Burt Lewis wrote:

> $pct301 = (4/6);
> printf ("%.3f%s", $pct301, '%');
> displays:
> 0.667%
> I'm looking to get just .667

Your trailing % appears  because you are putting it there.
Use printf ("%.3f", $pct301); to lose it.
The leading zero will be there because that is how the printf works.
If a decimal-point  character  appears,  at least 1 digit appears before it.
{ from man -s 3S  printf  }
You will have to find your own perly way to format this.
--



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

Date: Mon, 30 Aug 1999 19:04:30 GMT
From: glepa@yahoo.com (Glenn Paulsen)
Subject: Re: Random number
Message-Id: <37cad4de.7021052@news.online.no>

On 30 Aug 1999 08:23:25 -0500, abigail@delanet.com (Abigail) wrote:

>That's why you posted to Usenet. You already posted your question
>a few days ago, and the speedy reply to got then made you think
>Usenet is an excellen medium to get questions answered fast.

Thats correct that i posted a question some days ago.. but since i didnt get a
solution that worked. i posted the question again to maybe get a answer that do.

>Oh, a gimme, gimme, gimme post. We love them here. We also love
>those banner ads.

*S* well i cant perl so i cant give som back.. but i can networking and i reply
to a lot of questions in other news groups...


>Eeeck. A web wussie! Go away, go away!

???

Well sorry that you had a bad day so that you had to write that message to a new
person in this newsgroup... i feel realy welcome here... :-;

Best regards

Glenn


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

Date: Mon, 30 Aug 1999 19:05:45 GMT
From: glepa@yahoo.com (Glenn Paulsen)
Subject: Re: Random number
Message-Id: <37cad5e4.7283710@news.online.no>

Thanks
Thanks.. i will try this...

Best regards

Glenn Paulsen


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

Date: Mon, 30 Aug 1999 12:15:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Random number
Message-Id: <MPG.12347817a5cc20c3989edb@nntp.hpl.hp.com>

In article <37cad4de.7021052@news.online.no> on Mon, 30 Aug 1999 
19:04:30 GMT, Glenn Paulsen <glepa@yahoo.com> says...
> On 30 Aug 1999 08:23:25 -0500, abigail@delanet.com (Abigail) wrote:
 ...
> >Eeeck. A web wussie! Go away, go away!
> 
> ???
> 
> Well sorry that you had a bad day so that you had to write that message to a new
> person in this newsgroup... i feel realy welcome here... :-;

Abigail has a bad day every day.  Don't take it to heart.  Web wussies 
(one of which I am whom) are welcome here, provided they restrict their 
inquiries to Perl issues, not HTML, CGI, or whatever.

> Best regards
> 
> Glenn

You seem to be surviving in good spirits!  :-)  Now shorten your line 
lengths to 72 characters, and all will be well.

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


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

Date: 30 Aug 1999 20:54:42 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Ready to get to work but...
Message-Id: <7qer2i$fbr$1@info2.uah.edu>

In article <E5ry3.1$V75.440@vic.nntp.telstra.net>,
	"Wyzelli" <wyzelli@yahoo.com> writes:

: Abigail <abigail@delanet.com> wrote in message
: news:slrn7sk7mv.23d.abigail@alexandra.delanet.com...
: 
: > What have browsers to do with testing Perl programs?
: 
: If the Perl program is involved with CGI, everything!

Nope.  A browser isn't strictly necessary to examine the output of a
CGI program.

: It don't matter how many times you say it, and despite the fact that Perl
: has many functions other than CGI, the majority of new Perl users are
: learning it for CGI.

There *is* a newsgroup for CGI, you know.

:                       If you were a tad less sarcastic they may be
: keener to learn some of the other things, rather than getting fobbed
: off and being left with a sour taste about Perl because the 'Perl
: Guru's (of whom you are perceived to be one) take the high and mighty
: tone.

I'm all for winning new people over to Perl, but I'm most certainly not
willing to do it at the price of mollycoddling rude and clueless lusers.

: Of course if a comment annoys you, you can just ignore it!

Fine advice.  You should consider it yourself.

Greg
-- 
Today a racist is anyone who is winning an argument with a liberal.
    -- Peter Brimelow


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

Date: Mon, 30 Aug 1999 16:16:16 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: SHTML and PERL
Message-Id: <7qeo73$6s0$1@nntp9.atl.mindspring.net>

kayec wrote in message ...
:To make my site easily manageable i use server side includes to
:setup the head and foot of each page.

Ok

:I decided to make a little bulletin board with PERL so user can
:post messages.

That's Perl, but ok.

:Now usually you can just PRINT all the HTML
:and it will be sent out the  browser but how can i dynamically create a
:page AND use server side includes


Er, you can't, not if you are using CGI.  It doesn't work that way.  Why
do you want to use SSI?  Just have the script read in the files and then
print it out where you want them.   Much better to just have Perl do all
the work.


HTH

AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
I don't know if it's what you want, but it's what you get.  :-)
- Larry Wall in <10502@jpl-devvax.JPL.NASA.GOV>





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

Date: 30 Aug 1999 16:54:14 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Spawn a Web process
Message-Id: <7qecvm$571$1@gellyfish.btinternet.com>

On Fri, 27 Aug 1999 13:31:58 -0700 David T. Cannon wrote:
> Lauren,
> 
>     Thanks for the reply. I think my question was clear as stated. But let
> me clarify it with more text.
> 
>     I have a cgi form. I complete some fields on the form that will be read
> from my cgi(Perl) script "script1" that will then launch another Perl
> "script2". The reason I need to launch Perl script 2 is that it takes hours
> to complete, and I need the browser to come back and acknowledge that the
> process has been started.
> 
>     I have tried the system() command, but the browser waits for the system
> call to end before continuing:
> 
> system("/opt/apache/htdocs/aw/aw-report -o /home/good/b1 -r
> 1999080200-1999080300 &");
> 
> 

I would recommend using fork() and exec() closing the STDOUT in the
child.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Mon, 30 Aug 1999 22:43:15 +0200
From: Rolf Raven <rolf.raven@quantis.nl>
Subject: Re: Subst text in file with variable contents
Message-Id: <37CAECE3.D4AA6032@quantis.nl>

bigtrain23@my-deja.com wrote:
> 
> all,
> i'm trying to open a file for writing (file
> contains info i want to keep), search for the
> string 'defaultgateway=' (no quotes) and subtitute
> a variable's value for whatever comes after the
> equal sign. how do i do this?

I don't know how you do this.
I would use a temp file. One for reading, and one for writing the entire
contents to, substituting what needs to be substituted when I find a match
(if (/defaultgateway/) { print OUT "defaultgateway=666\n"; })
When I'm done, remove the original file and rename the new one.

That's how I do this.

floR


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

Date: Mon, 30 Aug 1999 12:54:37 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: Testing files on cd-rom?
Message-Id: <7qeni0$iib$1@brokaw.wa.com>

Thomas Weholt wrote in message <37CA668F.8AC43432@bibsyst.no>...
>Hi,
>
>Does anybody know if there are any modules, code or other ways of
>testing files in cd-roms to see if they are corrupt? I could copy each
>file to disk but that would req. min. 650mb of free space all the time.


How would you know whether a file is corrupt or not?  It seems that you
would have to have the non-corrupted version of the files available on
your hard drive in order to verify that the files are not corrupted.

Of course, I could be ignorant of some checksum-type feature of CD-ROM's
(which is not unlikely).

Yes, Perl can perform my first suggestion, and it would take a lot less
than 650Mb (depending on the amount of memory in your system: down to
0Mb).

Lauren




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

Date: Mon, 30 Aug 1999 14:32:58 -0400
From: Mark Conlin <Mark.Conlin@bridge.bellsouth.com>
Subject: Re: Want to use PERL to run script on another server.
Message-Id: <37CACE5A.EB1CFB70@bridge.bellsouth.com>

I thought I would answer my own question, what I was looking
for really was a UNIX command and not a Perl command.

rsh, allows you to get to another server, if you have a login 
there and you can run a command. 

So, I am going to use that to get to the other server
and hit the script.

Mark

Mark Conlin wrote:
> 
> I would like to use PERL to run another PERL script on a different
> server.
> 
> Is there a way to access the script as if I had hit it with a web
> browser, from
> inside a different script on a different server ?
> 
> thanks


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

Date: Mon, 30 Aug 1999 13:20:45 -0500
From: "Tim Bornholtz" <tbornhol@prioritytech.com>
Subject: Re: writing to a file within a loop
Message-Id: <09FCAA105E4C7DBE.FDCD511F5C5A75E3.26A455972DE7A4AC@lp.airnews.net>


Lakmal Jinadasa <lakmal@ml.com> wrote in message
news:37CAB5A1.38DCD6B0@ml.com...
>
>
> I open a file within a foreach loop
> then try to write some data to the file.
> everything goes fine except the data is not in the file.
>
> Part of the program is as follows
>
> foreach $key1(@list1)
>     foreach $key2 (@list2) {
>      open DAT ">File_Name";

Always check the return code from your open
        open DAT ">File_Name" || die $!;

$! will hold the error value or message depending on the context used.

hth,
Tim Bornholtz
tbornhol@prioritytech.com





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

Date: Mon, 30 Aug 1999 12:03:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: writing to a file within a loop
Message-Id: <MPG.1234756dae714c22989ed9@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article 
<09FCAA105E4C7DBE.FDCD511F5C5A75E3.26A455972DE7A4AC@lp.airnews.net> on 
Mon, 30 Aug 1999 13:20:45 -0500, Tim Bornholtz 
<tbornhol@prioritytech.com> says...
> Lakmal Jinadasa <lakmal@ml.com> wrote in message
> news:37CAB5A1.38DCD6B0@ml.com...
 ...
> >      open DAT ">File_Name";
> 
> Always check the return code from your open
>         open DAT ">File_Name" || die $!;

Always compile the code that you publish in this newsgroup, first.

There are two errors in the above statement -- one syntactic and the 
other semantic.

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


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

Date: Mon, 30 Aug 1999 19:14:01 GMT
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
Subject: Re: writing to a file within a loop
Message-Id: <7qel5d$5pc$1@nnrp1.deja.com>

[In article <37CAB5A1.38DCD6B0@ml.com>,
  Lakmal Jinadasa <lakmal@ml.com> wrote:
> I open a file within a foreach loop
> then try to write some data to the file.
> everything goes fine except the data is not in the file.
>
> foreach $key1(@list1)
>     foreach $key2 (@list2) {
>      open DAT ">File_Name";
>      @arr = output_of _a function;
> print DAT @arr;
> close (DAT);
>     }
>
> }
>


Open the file outside the loop. If you open it inside the loop then the
next write
to the file will overwrite the earlier contents.  If you still want to
open it inside
the loop then open it in append mode.  Also finding if the file open
succeeded
is a good idea.
--


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Mon, 30 Aug 1999 12:37:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: writing to a file within a loop
Message-Id: <MPG.12347d35f1a21eec989edd@nntp.hpl.hp.com>

In article <7qel5d$5pc$1@nnrp1.deja.com> on Mon, 30 Aug 1999 19:14:01 
GMT, Makarand Kulkarni <makarand_kulkarni@my-deja.com> says...
 ...
> Open the file outside the loop. If you open it inside the loop then the
> next write
> to the file will overwrite the earlier contents.  If you still want to
> open it inside
> the loop then open it in append mode.

Reading the problem description is a good idea.

> > Seperate file is created for each key1.key2

So your proposal is irrelevant.

>                                       Also finding if the file open
> succeeded
> is a good idea.

Yes, it is.  And so would be setting your newsreader not to produce 
random line breaks.

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


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

Date: Mon, 30 Aug 1999 22:47:44 +0200
From: Rolf Raven <rolf.raven@quantis.nl>
Subject: Re: writing to a file within a loop
Message-Id: <37CAEDF0.F692F7DC@quantis.nl>

Lakmal Jinadasa wrote:
> 
> everything goes fine except the data is not in the file.
> 
> foreach $key1(@list1)
>     foreach $key2 (@list2) {
>         open DAT ">File_Name";
>         @arr = output_of _a function;
>         print DAT @arr;
>         close (DAT);
>     }
> }
> The files are there with 0 byte length.

Looks to me the problem is not writing to the file, but rather getting
the data into @arr.


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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 V9 Issue 681
*************************************


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