[8119] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1737 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 27 02:07:44 1998

Date: Mon, 26 Jan 98 23:00:24 -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           Mon, 26 Jan 1998     Volume: 8 Number: 1737

Today's topics:
    Re: _Effective Perl Programming_ <joseph@5sigma.com>
        Any news <-> HTML programs around? <brendan@sofcom.com.au>
        BBEdit and MacPerl (was Re: Finding...) (brian d foy)
    Re: crypt function ... help. <rjk@coos.dartmouth.edu>
    Re: declaring subroutine prototypes <rjk@coos.dartmouth.edu>
        Easy question 'cat file | grep "^H00" | cut -c2-8' perl (Clint Grimes)
    Re: Easy question 'cat file | grep "^H00" | cut -c2-8'  (Steve Lamb)
    Re: Easy question 'cat file | grep "^H00" | cut -c2-8'  <ajohnson@gpu.srv.ualberta.ca>
    Re: Easy question 'cat file | grep "^H00" | cut -c2-8'  (Steve Lamb)
    Re: Easy question 'cat file | grep "^H00" | cut -c2-8'  <ajohnson@gpu.srv.ualberta.ca>
    Re: Easy question 'cat file | grep "^H00" | cut -c2-8'  <rjk@coos.dartmouth.edu>
    Re: Evaluating stdin text (Mark-Jason Dominus)
        exec, fork and CGI confusion <d3a350@seanet.com>
        Executing another script o another web site? <vanucci@sp.dglnet.com.br>
        Graphical Perl debugger for Solaris? <nnylfv@ny.ubs.com>
    Re: How does perl do "tail -n" ? (Michael Wang)
    Re: Howto match similar line item in different files? <rjk@coos.dartmouth.edu>
        newbie stuck on null return for 0 (zero) user input <dev@hargray.com>
        newbie stuck on null return for 0 (zero) user input <dev@hargray.com>
    Re: newbie stuck on null return for 0 (zero) user input (brian d foy)
    Re: newbie stuck on null return for 0 (zero) user input <markm@nortel.ca>
    Re: PERL report problem <corky@ultranet.com>
    Re: Please define the usage in this example. (brian d foy)
    Re: Please define the usage in this example. (Mike D. Kail)
    Re: Please define the usage in this example. <markm@nortel.ca>
    Re: Please define the usage in this example. (brian d foy)
    Re: Pointless questions (was: Re: Perl, Sybperl, and Ye <joseph@5sigma.com>
    Re: printing an image (brian d foy)
    Re: printing an image <rjk@coos.dartmouth.edu>
    Re: ssh (Mike D. Kail)
    Re: Survival Of perl (Danny Aldham)
    Re: using packages with perl on Windows (NT)? (Nathan V. Patwardhan)
    Re: using packages with perl on Windows (NT)? <rjk@coos.dartmouth.edu>
    Re: White Hats and Black <ajohnson@gpu.srv.ualberta.ca>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 26 Jan 1998 22:46:41 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: _Effective Perl Programming_
Message-Id: <34CD74B1.58A7AE97@5sigma.com>

Andy Lester wrote:
> 
> :     I don't use English. It's just too verbose for this little book.
> :     Furthermore, English is not common practice among Perl
> :     programmers, and scripts that use English suffer a speed penalty.
> :     This is not to say that English is not useful, just that you won't
> :     see it here.
> 
> My use of English: If I have to use a special $variable that requires me
> to pick up a copy of the book to know what it is, I use English.
> Effectively, that means that if I have to use anything besides $_ or $&, I
> use it.  But that's just me.
> 
> Something that's struck me as vaguely annoying about _Effective Perl
> Programming_, ( and I DO love the book) 

Ooo, off to a good start!

> is the continual mentions of
> speed.  Granted, the "use English incurs a 50% speed hit immediately" is
> worth noting, but in general, he seems to be very concerned with speed.
> Me, I try always to remember "Premature optimization is the root of all
> evil", and eschewing English in favor of a speed increase seems premature
> to me.

I had my reasons for avoiding English, the most damming of which was
that those darn long identifiers wouldn't fit in those skinny columns.
I personally *never* use it but on the other hand I don't mind reading
code that does.

I don't recall being obsessed with speed.  (I did add a "speed" heading
to my index, though!)  A lot of the code I wrote could have been 
speedier, particularly in the regex chapter, but it would have been
harder to follow, and, especially, would have required elaborate
explanations that I thought were better left to Jeffrey's book (thus
my multiple mentions of it there).  That was a case where "better was
the enemy of good enough."  But there are certain things, like
avoiding unnecessary subscripting and dereferencing operations, that
I had to discuss because they were 1) significant phenomena and 2) not
well known.

I was hardly ever concerned about the speed of my code as I wrote the
book.  I did benchmark many snippets, but frankly I didn't discuss half
of the speed-related issues that arose, figuring that some of the speed
related optimizations would seep into readers by osmosis.

	-joseph

-- 
Joseph N. Hall, prop., 5 Sigma Productions       mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training  . . . . . . . . . . . . . . .  http://www.perltraining.com


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

Date: Tue, 27 Jan 1998 16:43:02 +1100
From: Brendan Quinn <brendan@sofcom.com.au>
Subject: Any news <-> HTML programs around?
Message-Id: <34CD73E6.D320D1E6@sofcom.com.au>

Hi everyone,

I've looked around on as many Perl archives as I can find with no
success, but I'm sure something like this has to be out there somewhere.

I'm after a Perl interface to Usenet News. It should display the
messages in a given newsgroup, allow reading and possibly followups.

Should be too hard given Net::NNTP, but I'd prefer to just use someone
else's code if I can :-)

I don't suppose Deja News would give away their code?

If noone else has done it, expect to find my version in the archives
soon!

Brendan.
-- 
Brendan Quinn                  |     brendan@sofcom.com.au
Sofcom Internet Publishers     | 
Level 1, 399 Riversdale Rd     |    Phone:  +61 3 9882 3811
Hawthorn East 3123             |    Fax:    +61 3 9882 7619
Victoria, AUSTRALIA            |     http://www.sofcom.com


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

Date: Mon, 26 Jan 1998 23:55:25 -0500
From: comdog@computerdog.com (brian d foy)
Subject: BBEdit and MacPerl (was Re: Finding...)
Message-Id: <comdog-ya02408000R2601982355250001@news.panix.com>
Keywords: from just another new york perl hacker

In article <Pine.GSO.3.96.980126182456.22284G-100000@user2.teleport.com>, Tom Phoenix <rootbeer@teleport.com> posted:

>On 26 Jan 1998, Mike West wrote:


>> I do use BBEdit on a Mac, which I love, but if the other bracket
>> is farther than a screen away, I do not find it.  I can split screens,
>> but last I checked the other screen does not blink the other bracket.
>
>The developers of BBEdit work very hard to make it a good editor for
>programmers. Perhaps you should check again to see if there is a way to do
>that, or you could suggest it to the BBEdit developers. Someone in a
>newsgroup like comp.editors may be able to tell you more. Good luck! 

speaking of BBEdit, i recently found this wonderful MacPerl interface
package on Hyperarchive:

   <URL:http://hyperarchive.lcs.mit.edu/HyperArchive/Archive/
      text/bbe/macperl-bbedit-extensi.hqx>


[btw: look at the Balance (Apple-B) command in the Text Menu, or
the BBedit User Guide which documents its use.]

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: Tue, 27 Jan 1998 01:47:33 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: crypt function ... help.
Message-Id: <34CD8305.E64A2CA0@coos.dartmouth.edu>

chad wrote:
> 
> How do I de-crypt a crypt'd string?  I cryp'd it using the perl crypt function.

Slowly and painfully.

Chipmunk


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

Date: Tue, 27 Jan 1998 00:39:32 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: declaring subroutine prototypes
Message-Id: <34CD7314.9749878D@coos.dartmouth.edu>

[posted and mailed]

Tom Phoenix wrote:
> 
> On Mon, 26 Jan 1998, Chipmunk wrote:
> 
> > I've noticed that declaring subroutine prototypes has no effect when the
> > declaration is done later in the code than the subroutine call.
> 
> As documented in perlsub.

I have to disagree.  perlsub appears to say the same thing as Programming Perl:

  As of the 5.002 release of perl, if you declare
    sub mypush (\@@)
  then mypush takes arguments exactly like push does. The declaration of the
  function to be called must be visible at compile time.

The declarations of the functions I am calling are visible at compile time.
They just happen to be later in the file.

If that text is supposed to mean "the declaration of the function to be called
must appear before the function call", then it should say that.  :-)

> > Why is that?
> 
> Because Perl's internal compiler doesn't have ESP. :-)  How can perl check
> the prototype on foo(1, 2) if you haven't given it the prototype for foo
> yet? And consider what a prototype could do to foo(@bar) as well: Perl
> can't even compile the call without knowing (or assuming) a prototype.
> (Nevertheless, I think that we could make it a -w warnable offense to
> define a sub with a proto other than the default (@) after a call to that
> sub has been defined.)

I was thinking the compiler would find all the prototype declarations and apply
them early in the compilation process.  But I was wrong, it does not work
that way.  Which makes sense now that I think about it, given how the compiler
behaves in other situations.

> The primary purpose for prototypes, as I understand it, is to allow you to
> make subs which act like builtins. (Usually, this is done from a module,
> which you 'use' at the top of the script.) But you can always call a sub
> with other parameters than the proto expects. Doing the call before the
> proto is one way to do that.

A better way is to use the ampersand, so it's not like it's an important feature
to be able to ignore the prototype by doing the call first.  And it makes the code
harder to maintain, because the prototypes have to be declared at the
beginning of
the file, and if they're moved elsewhere they won't apply everywhere.

Thanks for explaining!

Chipmunk


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

Date: Tue, 27 Jan 1998 03:40:53 GMT
From: cgrimes72@earthlink.net (Clint Grimes)
Subject: Easy question 'cat file | grep "^H00" | cut -c2-8' perl equiv. (0/1)
Message-Id: <34cd52d9.303103@news.earthlink.net>

There's gotta be an easy way to do this.  I keep reading and
suffocating in all the search/substitute options.

I have a number of text files that I need to seach through for lines
that start with "H00" and then get the next 6 numbers and print these
numbers out.

The numbers correspond to batch ID's that are uploaded daily, there
are between 1 and 20 batches per file.  I said I could do it, knowing
it can't be that hard, and yet I'm haing little success.

I'm currently frustrating myself with code like this:

	foreach $_ (`type $currfile | grep "^H00"`)
		{
	#	($batch) = /H00\s+(.*)/;
		/s/^H00(.*)\/(.*)/\1/;
		$batch = $_;
		print $batch . " ";
		}

I included an entire upload file and program such as it is, if anyone
is feeling really bored and/or is an overachiever.

Thanks for any suggestions,
-Clint
Clint_Grimes@ccmail.fh.com


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

Date: 27 Jan 98 05:25:17 GMT
From: morpheus@no-spam.calweb.com (Steve Lamb)
Subject: Re: Easy question 'cat file | grep "^H00" | cut -c2-8' perl equiv. (0/1)
Message-Id: <slrn6cqrtu.hci.morpheus@web1.calweb.com>

cgrimes72@earthlink.net in <<34cd52d9.303103@news.earthlink.net>> wrote:
>I have a number of text files that I need to seach through for lines
>that start with "H00" and then get the next 6 numbers and print these
>numbers out.


    How you get into the files I'll leave up to you, but the loop I'd use
once in there is:

while(<FILE>)
{
  my($blah) = $_;
  if ($blah =~ /^H00(??????)/)
  {
    print($1);
  }
}

   That searches each line of the file for a line that starts with H00 and
then grabs the next 6 characters and prints them out.  Well, in theory it
does.  I've not run it or nuffin' but it should work.

-- 
             Steve C. Lamb             | Opinions expressed by me are not my
    http://www.calweb.com/~morpheus    | employer's.  They hired me for my
CC: from news not wanted or appreciated| skills and labor, not my opinions!
---------------------------------------+-------------------------------------


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

Date: Tue, 27 Jan 1998 00:09:49 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Easy question 'cat file | grep "^H00" | cut -c2-8' perl equiv. (0/1)
Message-Id: <34CD7A2D.10ED83A8@gpu.srv.ualberta.ca>

Steve Lamb wrote:
!
! cgrimes72@earthlink.net in <<34cd52d9.303103@news.earthlink.net>> wrote:
! >I have a number of text files that I need to seach through for lines
! >that start with "H00" and then get the next 6 numbers and print these
! >numbers out.
! 
! 
!     How you get into the files I'll leave up to you, but the loop
! I'd use once in there is:
! 
! while(<FILE>)
! {
!   my($blah) = $_;
!   if ($blah =~ /^H00(??????)/)
!   {
!     print($1);
!   }
! }
! 
!    That searches each line of the file for a line that starts
! with H00 and then grabs the next 6 characters and prints them
! out.  Well, in theory it does.  I've not run it or nuffin' but it
! should work.

nope... (??????) is not a valid regexpression...
try something along the lines of:

#!/usr/bin/perl -w
while (<DATA>){
    print "$1\n" if /H00\s*(\d{6})/;
}
__DATA__
H00123456789        this ones good
H00  987654321      this ones good
H00blahblahblahblah this one's no good
HOO123456           this one's no good
H00                 not good either
__END__

and adjust the regex for any alternate but valid ways the
"next 6 numbers" might arrive as.

regards
andrew


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

Date: 27 Jan 98 06:27:38 GMT
From: morpheus@no-spam.calweb.com (Steve Lamb)
Subject: Re: Easy question 'cat file | grep "^H00" | cut -c2-8' perl equiv. (0/1)
Message-Id: <slrn6cqvir.3td.morpheus@web1.calweb.com>

ajohnson@gpu.srv.ualberta.ca in <<34CD7A2D.10ED83A8@gpu.srv.ualberta.ca>> wrote:
>nope... (??????) is not a valid regexpression...
>try something along the lines of:

    Erp, slipped into a different regexp.  I was thining (......)

-- 
             Steve C. Lamb             | Opinions expressed by me are not my
    http://www.calweb.com/~morpheus    | employer's.  They hired me for my
CC: from news not wanted or appreciated| skills and labor, not my opinions!
---------------------------------------+-------------------------------------


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

Date: Tue, 27 Jan 1998 00:17:54 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Easy question 'cat file | grep "^H00" | cut -c2-8' perl equiv. (0/1)
Message-Id: <34CD7C12.4880F561@gpu.srv.ualberta.ca>

Andrew Johnson wrote:

oops!

[snip]
> #!/usr/bin/perl -w
> while (<DATA>){
>     print "$1\n" if /H00\s*(\d{6})/;

                     /^H00\s*(\d{6})/;

somehow, the little pointy thingy escaped my
fingertip unnoticed.
regards
andrew


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

Date: Tue, 27 Jan 1998 01:46:30 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Clint Grimes <cgrimes72@earthlink.net>
Subject: Re: Easy question 'cat file | grep "^H00" | cut -c2-8' perl equiv. (0/1)
Message-Id: <34CD82C6.F76E2891@coos.dartmouth.edu>

[posted and mailed]

Clint Grimes wrote:
> 
> I have a number of text files that I need to seach through for lines
> that start with "H00" and then get the next 6 numbers and print these
> numbers out.

The command line you provided in the subject does not do what you
asked for in the above paragraph.  It prints 7 characters, and includes
the two zeros in that.

perl -ne 'print substr($_, 3, 6), "\n" if /^H00/'

Chipmunk


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

Date: 27 Jan 1998 00:22:02 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Evaluating stdin text
Message-Id: <6ajqtq$6iv$1@monet.op.net>
Keywords: axisymmetric mutagen radiant smokehouse

In article <6aitmf$cqa$1@cyprus.atlantic.net>,
Chip Salzenberg <chip@pobox.com> wrote:
>Well, you'd have to come up with a regex that covers all possible
>expressions, and I think that's impossible.  So maybe your config
>file should bracket the expressions somehow:
>
>  "This is {{$i++}}"
>  "This is {{++$i}}"

The Text::Template module already supports something almost exactly
like this;  you can hand it a piece of text, either frmo a file or as
an array of strings, and it will find {perl expressions} in the text
and replace them with their values, so that

	Dear {$recipient},

	I am relaibly informed that one plus two is (1+2}.
	Also, the results of the `oracle' function are:
	
		{ &oracle(); }

Turns into:

	Dear Edgar,

	I am relaibly informed that one plus two is 3.
	Also, the results of the `oracle' function are:
	
		HEED MY WORDS, FOOLISH MORTAL.



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

Date: Mon, 26 Jan 1998 21:48:08 -0800
From: Robert Goheen <d3a350@seanet.com>
Subject: exec, fork and CGI confusion
Message-Id: <34CD7518.E0288620@spam.me.com>

Bear with me, I'm not altogether up on using fork and exec.  What I'm
trying to do is have a script execute at the end of a CGI script to do
some clean-up.  I want to use exec to free up the user while the second
script runs.  So, working from some research via www.dejanews.com and
the perlfunc documentation on fork, I came up with the following
statement at the end of my script, which executes after a page has been
sent to the user:


  unless ($pid = fork) {        
     unless (fork) {
       close (STDOUT);     # end of output to browser.
       exec "cleanup.pl";
       exit 0;
       }        
     exit 0;    
  }    
  waitpid($pid,0);

And it works fine.  The script cleanup.pl runs fine.  HOWEVER, the page
gets sent to the user 3 times.  Again, I don't know much about the
proper use (and misuse) of fork, but I'm assuming the two calls to fork
create processes that send the page two more times to the browser.  So,
I've tried moving the close(STDOUT) statement up, to before one or both
of the unless statements, but when I do that, cleanup.pl doesn't get
executed.  I've also tried redirecting STDOUT, but even that prevents
cleanup.pl from executing properly.  (Cleanup.pl writes some content to
a file, and a database using NDBM_File.)

So, I'm stuck between creating a page that contains a couple of copies
of itself, or not having cleanup.pl execute.  Can someone please tell me
if there's a better way of doing this, or if there's a way to keep the
fork calls from sending extra information to the client browser.

Many (desparate) thanks.

Robert S. Goheen
rsgoheen@pobox.com


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

Date: Tue, 27 Jan 1998 03:24:44 -0200
From: "Fabiano Vanucci" <vanucci@sp.dglnet.com.br>
Subject: Executing another script o another web site?
Message-Id: <885878820.612853@citroen>

Can Exec() function execute another script that isn't on the same web site?
I mean....
First, my "post01.pl" that is located at (for example)
"www.ibm.com/cgi-bin/post01.pl"
Then, this "post01.pl" has to execute "rec02.pl" at
"www.compaq.com/cgi-bin/rec02.pl", gets his return value, and process it.

Can it be done? How?

Thanks,

Fabiano Vanucci




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

Date: Mon, 26 Jan 1998 23:21:33 -0500
From: Olivier Lefevre <nnylfv@ny.ubs.com>
Subject: Graphical Perl debugger for Solaris?
Message-Id: <34CD60CD.4B1A@ny.ubs.com>

The subject says it all.

Thanks,

-- O.L.


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

Date: 27 Jan 1998 04:40:44 GMT
From: mwang@alhena.ibk.ml.com (Michael Wang)
Subject: Re: How does perl do "tail -n" ?
Message-Id: <6ajogc$g2m$1@news.ml.com>

>If one really really really cared about speed... we could optimize the
>above to work for speed _and_ large files:
>
>    my $maxlines = 50;
>    if ($ARGV[0] =~ /^-(\d+)$/) {
>        $maxlines = $1;
>        shift @ARGV;
>    }
>
>    my @lines = ();
>    while (<>) {
>        push(@lines, $_);
>	splice(@lines, 0, $maxlines) if @lines >= (2 * $maxlines);
>    }
>    splice(@lines, 0, @lines - $maxlines) if @lines > $maxlines;
>    print @lines;
>
>Sorta moving window approach :-) Means we copy memory around a lot less.

To get the last 10 lines from 1,000,000 line file, for example, 
you still read every line of the file, that is where the inefficiency
comes from, I think.

The most efficient way is to use "seek", I think, to reach the end 
of the file and read backward. As a matter of fact, that is how the 
tail.c is written. (I do not how lseek is written and if it is written in C,
anyone knows? I bet it does not count chars.)

OK, since tail.c has already been written with numerous options, why
should we reinvent the wheel? ksh makes no differentiation between
build-in commands and "external" commands, I like it. It looks natural.
However it looks very urgly to call an external command from Perl, 
either using "system" or with "use shell". It looks very unnatural. 
If I use a lot "system", then I better off use ksh. 

To summarize, there are a great number of efficient and time proven
utilities have been written, and yet Perl does not have a natural way
(comparing with ksh) calling them. That buffles me. Please enlighten me,
thanks.


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

Date: Tue, 27 Jan 1998 00:48:35 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: Howto match similar line item in different files?
Message-Id: <34CD7533.E292ACE2@coos.dartmouth.edu>

Chip Salzenberg wrote:
> 
> According to r.hazeltine@nepean.uws.edu.au:
> >I want to join the contents of the second file to the reciprocal line in
> >the first file
> 
> If this is a stand-alone utility need, then you should look into one
> of the many freely available "join" programs.

That was my first thought, although I don't know if join will provide all
the functionality he wants in this situation.

> Otherwise, it's probably best to read one file into a hash, then read
> the next file and add on to each hash value the new fields.

Note that the entries are identified using non-unique keys.  Perhaps
reading the file into a hash of lists would work, where each value is a
reference to a list of all the lines with the corresponding key.

Chipmunk


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

Date: Mon, 26 Jan 1998 22:57:05 -0500
From: dev <dev@hargray.com>
Subject: newbie stuck on null return for 0 (zero) user input
Message-Id: <34CD5B11.16FE5427@hargray.com>

When a user enters data into my simple HTML form and only enters 0
(zero) as input for a field, the resulting value in my perl script is
null.  This is wreaking havoc with me because 0 (zero) needs to be a
valid response that I can evaluate, as well as null responses.  

Please tell me what could be causing this, or even direct me to a form
processor that you know won't do this to me.

Thanks,

Dev


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

Date: Mon, 26 Jan 1998 22:56:46 -0500
From: dev <dev@hargray.com>
Subject: newbie stuck on null return for 0 (zero) user input
Message-Id: <34CD5AFE.8E86BA63@hargray.com>

When a user enters data into my simple HTML form and only enters 0
(zero) as input for a field, the resulting value in my perl script is
null.  This is wreaking havoc with me because 0 (zero) needs to be a
valid response that I can evaluate, as well as null responses.  

Please tell me what could be causes this, or even direct me to a form
processor that you know won't do this to me.

Thanks,

Dev


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

Date: Tue, 27 Jan 1998 00:12:11 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: newbie stuck on null return for 0 (zero) user input
Message-Id: <comdog-ya02408000R2701980012110001@news.panix.com>
Keywords: from just another new york perl hacker

In article <34CD5B11.16FE5427@hargray.com>, dev@hargray.com posted:

>When a user enters data into my simple HTML form and only enters 0
>(zero) as input for a field, the resulting value in my perl script is
>null.  This is wreaking havoc with me because 0 (zero) needs to be a
>valid response that I can evaluate, as well as null responses.  
>
>Please tell me what could be causing this, or even direct me to a form
>processor that you know won't do this to me.

my guess is that you aren't using CGI.pm.  if you are, there is
probably something wierd in your code, although you haven't given
us a chance to see that.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: 26 Jan 1998 23:54:10 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: newbie stuck on null return for 0 (zero) user input
Message-Id: <lq1g1maqzyl.fsf@bmers2e5.nortel.ca>

dev <dev@hargray.com> writes:
> When a user enters data into my simple HTML form and only enters 0
> (zero) as input for a field, the resulting value in my perl script is
> null.  This is wreaking havoc with me because 0 (zero) needs to be a
> valid response that I can evaluate, as well as null responses.  
> 
> Please tell me what could be causes this, or even direct me to a form
> processor that you know won't do this to me.

Any sample code you could submit for analysis?

The most obvious would be a check for:

    if ($abc) { ... }

instead of :

   if (defined($abc)) { ... }

but without actually seeing your code i have no clue.

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Mon, 26 Jan 1998 23:56:38 -0500
From: Bob Trieger <corky@ultranet.com>
To: john kelly <john.kelly@citicorp.com>
Subject: Re: PERL report problem
Message-Id: <34CD6906.742@ultranet.com>

> format STDOUT_SUMMARY=
> 
>                   Summary
>                           Average   @<<<<<<<<  @<<<<<<<<  @<<<<<<<<<
> @<<<<<<<<
> $AVG_mean,$AVG_mode,$AVG_deliv_range
>                           Median    @<<<<<<<<  @<<<<<<<<  @<<<<<<<<<
> @<<<<<<<<
  ^^^^^^^^^
> $MED_mean,$MED_mode,$MED_deliv_range
                                       ^^^^^^^^^^

I've never used the format function but aren't you missing a fourth
variable here?

I suggest using "printf" instead. It really makes life much easier.


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

Date: Tue, 27 Jan 1998 00:04:50 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Please define the usage in this example.
Message-Id: <comdog-ya02408000R2701980004500001@news.panix.com>
Keywords: from just another new york perl hacker

In article <34CD5231.5A1D@shareone.com>, mpryor@shareone.com posted:

>In the following code snippet...
>        foreach $i(0..$#in_key){
>        .
>        .
>        };
>
>What exactly does the # sign perform?  I realize it's used for comments,
>but in this case, I haven't found an explanation in the docs.

the $#array_name construct is the index of the last element in the
array, usually one less than the number of elements in the array.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: 27 Jan 1998 04:54:37 GMT
From: mdkail@fv.com (Mike D. Kail)
Subject: Re: Please define the usage in this example.
Message-Id: <slrn6cqqbp.5oi.mdkail@dime.fv.com>

On Mon, 26 Jan 1998 21:19:13 -0600, Mark Pryor <mpryor@shareone.com> wrote:
>In the following code snippet...
>
>
>	foreach $i(0..$#in_key){
>	.
>	.
>	};
>
>What exactly does the # sign perform?  I realize it's used for comments,
>but in this case, I haven't found an explanation in the docs.
                                     ^^^^^^^^^^^^^^^^^^^^^

i guess you didn't read the perlvar man page...

[...]
     $#      The output format for printed numbers.  This
             variable is a half-hearted attempt to emulate awk's
             OFMT variable.  There are times, however, when awk
             and Perl have differing notions of what is in fact
             numeric.  The initial value is %.ng, where n is the
             value of the macro DBL_DIG from your system's
             float.h.  This is different from awk's default OFMT
             setting of %.6g, so you need to set "$#" explicitly
             to get awk's value.  (Mnemonic: # is the number
             sign.)



-- 
/*-------------------------------------------------------------*/
/*  Mike D. Kail                    |  voice:  (619) 350-3524  */
/*  Unix System Architect           |  fax:    (619) 793-2950  */
/*  FIRST VIRTUAL Holdings Inc.     |  e-mail: mdkail@fv.com   */
/*-------------------------------------------------------------*/



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

Date: 26 Jan 1998 23:51:32 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Please define the usage in this example.
Message-Id: <lq1iur6r02z.fsf@bmers2e5.nortel.ca>


[ author cc:'ed ]

Mark Pryor <mpryor@shareone.com> writes:
> In the following code snippet...
> 
> 	foreach $i(0..$#in_key){
> 	.
> 	.
> 	};
> 
> What exactly does the # sign perform?  I realize it's used for comments,
> but in this case, I haven't found an explanation in the docs.

Exactly which docs did you read? I found this in perldata off the bat...

     Scalar values are always named with '$', even when referring
     to a scalar that is part of an array.  It works like the
     English word "the".  Thus we have:

         $days               # the simple scalar value "days"
         $days[28]           # the 29th element of array @days
         $days{'Feb'}        # the 'Feb' value from hash %days
         $#days              # the last index of array @days

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Tue, 27 Jan 1998 01:41:42 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Please define the usage in this example.
Message-Id: <comdog-ya02408000R2701980141420001@news.panix.com>
Keywords: from just another new york perl hacker

In article <slrn6cqqbp.5oi.mdkail@dime.fv.com>, mdkail@fv.com posted:

>On Mon, 26 Jan 1998 21:19:13 -0600, Mark Pryor <mpryor@shareone.com> wrote:
>>In the following code snippet...
>>
>>
>>       foreach $i(0..$#in_key){
>>       .
>>       .
>>       };
>>
>>What exactly does the # sign perform?  I realize it's used for comments,
>>but in this case, I haven't found an explanation in the docs.

>i guess you didn't read the perlvar man page...
>
>[...]
>     $#      The output format for printed numbers.  This
>             variable is a half-hearted attempt to emulate awk's
>             OFMT variable.  

is this a serious post?

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: Mon, 26 Jan 1998 22:55:46 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Pointless questions (was: Re: Perl, Sybperl, and Year 2000)
Message-Id: <34CD76D1.F0B1B233@5sigma.com>

Tom Phoenix wrote:

> What the docs, FAQs, and people of this newsgroup tell you three times is
> true.

Are you sure about that?  Maybe Bill Clinton *is* telling the truth!

(It's a joke!  <ducking>)

The empty y2k questions do become tiring.

	-joseph

-- 
Joseph N. Hall, prop., 5 Sigma Productions       mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training  . . . . . . . . . . . . . . .  http://www.perltraining.com


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

Date: Tue, 27 Jan 1998 00:02:29 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: printing an image
Message-Id: <comdog-ya02408000R2701980002290001@news.panix.com>
Keywords: from just another new york perl hacker

In article <34CD458D.51B47B0A@internetmci.com>, George Cyriac <gcyriac@internetmci.com> posted:

>open("sm.gif",IMAGE);

>What am I doing wrong?  How do I get the image into a variable?

you forgot to use the -w switch to turn on warnings.  you would have
gotten a warning about that open(), which should be something like:

   open( FILEHANDLE, $filename ) or &handle_error();


good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: Tue, 27 Jan 1998 01:33:14 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: printing an image
Message-Id: <34CD7FAA.95282777@coos.dartmouth.edu>

George Cyriac wrote:
> 
> open("sm.gif",IMAGE);

[With apologies to Tom Phoenix]

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ pass the filehandle as the first argument to open().
Thanks!

;-)

Chipmunk


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

Date: 27 Jan 1998 04:22:24 GMT
From: mdkail@fv.com (Mike D. Kail)
Subject: Re: ssh
Message-Id: <slrn6cqofd.5oi.mdkail@dime.fv.com>

On Mon, 26 Jan 1998 16:57:40 -0600, Thomas Lockney
<media@organizedmedia.com> wrote:
>
>I'm looking for a module or any information pertaining to ssh within
>perl. I need to replicate a directory tree across a systems, one of
>which is using ssh. I don't want to have to make system calls to scp
>each time I find a file needing to be copied. Anyone have any experience
>with this?

NOTE: this has *nothing* to do with perl

what you want is 'rsync', you can retrieve it at:

	 ftp://samba.anu.edu.au/pub/rsync

-- 
/*-------------------------------------------------------------*/
/*  Mike D. Kail                    |  voice:  (619) 350-3524  */
/*  Unix System Architect           |  fax:    (619) 793-2950  */
/*  FIRST VIRTUAL Holdings Inc.     |  e-mail: mdkail@fv.com   */
/*-------------------------------------------------------------*/



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

Date: 26 Jan 1998 20:44:33 -0800
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: Survival Of perl
Message-Id: <6ajonh$g8j$1@lennon.postino.com>

X-Newsreader: TIN [version 1.2 PL2]

Frank (FHeasley@chemistry.com) wrote:
: I'm referring to any module which will not self extract and install in
: a windows environment.  There are far to many of them, and it's
: frustrating to download them from CPAN only to find that they are
: unusable.  Plus, if you can get them to work on your local machine,
: you still have the additional problem of getting them installed on
: your ISP's system - not always an easy thing to accomplish.

You're kidding, right? Self extract and install? If this is what 
you want, stick with the Activestate port of perl, and quit
complaining here about how tough modules are to install. Complain
to Activestate who put together a port without Makemaker. The
people that build & install the core perl distribution of perl
on Win32 have no trouble installing modules. It is exactly the
same process that is used on every other platform ie, perl Makefile.pl ,
make , make test & make install. 

--
Danny Aldham           SCO Ace , MCSE , JAPH , DAD
Ban the neutral zone trap. It's killing our National sport.


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

Date: 27 Jan 1998 04:55:57 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: using packages with perl on Windows (NT)?
Message-Id: <6ajpct$7h6@fridge.shore.net>

Mike Noel (noel@integrityonline.com) wrote:
: Ok.  I'm about ready to kill my windows machine.  (I wonder how many
: people actually make the change from UNIX to Windows successfully...)

What version of Perl are you using?  If I recall correctly, earlier
versions of the Activeware/state/whatever didn't fully implement
MakeMaker (if they implemented it at all).  I'm pretty sure that you
can use Sarathy's Perl (5.004_02) port and that MakeMaker will work.

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: Tue, 27 Jan 1998 01:14:44 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Mike Noel <noel@integrityonline.com>
Subject: Re: using packages with perl on Windows (NT)?
Message-Id: <34CD7B54.8D5FC6A7@coos.dartmouth.edu>

[posted and mailed]

Mike Noel wrote:
> 
> use lib 'c:\\perl';
> 
> Now my error message is:
> 
> Can't locate lib.pm in @INC at Makefile.pl line 12.
> BEGIN failed--compilation aborted at Makefile.pl line 12.

hehe :-)

> Well, lib.pm is in c:\perl on my system.  What do I do next?

How did it end up there?  The default location for the library
files is c:\perl\lib, not c:\perl.
Try moving all your libraries down into the lib directory and
see if that helps.

Chipmunk


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

Date: Mon, 26 Jan 1998 23:46:29 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: White Hats and Black
Message-Id: <34CD74B5.7F6BC2ED@gpu.srv.ualberta.ca>

Myles Barrett Williams wrote:
!
! jgd@alpha2.csd.uwm.edu (John G Dobnick) writes:
! > From article <lcn2gj9lu6.fsf@duncan.cs.utk.edu>, by Myles Barrett Williams <a@b.c.d>:
! > >                                           I predict Netscape will find
! > > that they can't even give their browser away.  It will end up being
! > > the favorite of hackers, but it's pretty much finished as an end-user
! > > browser.
! >
! >   Hmmm...   just like another "free software package" named Perl?  :-)
! 
!
! I see no relevance here.  End-users are the people who do not
! program, so you won't find them using Perl.

hmm, programmers aren't end-users? especially Perl programmers?
I guess all that vast quantity of POD documentation for the
core language and all the POD documentation for the large number
of contributed modules is entirely without value seeing as how it
is *user* documentation and not source-code documentation. Not to
mention the fact that we'd not get much done if we didn't find
ourselves on the business end of an OS and a text editor at least
occassionally.

! End-users outnumber hackers, and they have sharply contrasting
! ideas about what is desirable in software.  Always will.  If

so lets change the dichotomy to programmers and non-programmers,
certainly some programmer's may want to do away with some aspects
of an 'application' or add features that the non-programmer could
care less about --- but both would want good solid functioning
software that did what it purported to do with a minimum of fuss
and resource consumption --- and if Joe non-programmer wants some
other feature is he more or less likely to see it implemented
when the source is available to programmers everywhere as
opposed to being held by a single entity?

! It looks to me like Netscape is just trying to quit the browser
! business without anyone knowing.

perhaps...but regardless of the underlying motive, there may be
some interesting times ahead for both programmers and
non-programmers as a result of the source code release :-)

regards
andrew


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 1737
**************************************

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