[9565] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3159 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 14 23:07:21 1998

Date: Tue, 14 Jul 98 20:00:33 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 14 Jul 1998     Volume: 8 Number: 3159

Today's topics:
        accessing subroutines in different scripts. <ricdola@email.msn.com>
    Re: accessing subroutines in different scripts. (Ronald J Kimball)
    Re: cgi module confusion (William R. Ward)
    Re: create NCSA combined log from separate agent/refere (brian d foy)
        error message with sysopen in script from perlfaq5 (Ian Donen)
    Re: forking on win32 (Peter Scott)
        How to Call calling file? stephenwhite@sprint.ca
    Re: Indentation <scribble@pobox.com>
    Re: Perl Beautifier Home Page (Michael J Gebis)
    Re: Perl Beautifier Home Page (Larry Rosler)
    Re: Perl Beautifier Home Page (Michael J Gebis)
    Re: Perl Beautifier Home Page (Larry Rosler)
        perl embedding on win32 livshits@acm.org
        Perl Setup on NT <tdean@gte.net>
    Re: Recommend me Perl! (Ronald J Kimball)
    Re: RegExps: Check if string consists of EXACTLY 3 digi (brian d foy)
    Re: RegExps: Check if string consists of EXACTLY 3 digi (Ronald J Kimball)
        Rounding  xxx.xxxxxx to  xxx.xx <inquiries@halbrook.com>
    Re: Rounding  xxx.xxxxxx to  xxx.xx <tchrist@mox.perl.com>
    Re: Run a new page from the output of cgi script (-)
    Re: Simple problem with perl script. (Ronald J Kimball)
    Re: Simple problem with perl script. (Larry Rosler)
    Re: Sticking in NULL after split <franzen@pmel.noaa.gov>
    Re: Sticking in NULL after split (David Alan Black)
    Re: Sticking in NULL after split (David Alan Black)
    Re: Sticking in NULL after split (brian d foy)
    Re: Sticking in NULL after split (Ronald J Kimball)
    Re: Sticking in NULL after split (Larry Rosler)
    Re: Sticking in NULL after split (Larry Rosler)
    Re: Sticking in NULL after split (brian d foy)
    Re: trying to install perl (brian d foy)
    Re: WebBots <scribble@pobox.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 14 Jul 1998 20:21:47 -0500
From: "Dolores D. Alcazar" <ricdola@email.msn.com>
Subject: accessing subroutines in different scripts.
Message-Id: <Oyslc64r9GA.94@upnetnews05>


    Hello,

    I was wondering if it was possible to access subroutines located in
different scripts.  Since I use cgi-lib.pl quite often and many of the subs
are taken from that script...  I would like to do something similar and
access subroutines from a different script.  So I tried using the same
syntax:

   require "somescript.pl";

    then just call the subroutine, however, I always get a 550 error...  can
someone help me out?

    Ric




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

Date: Tue, 14 Jul 1998 21:53:24 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: accessing subroutines in different scripts.
Message-Id: <1dc6f9m.2o7kl81iq406bN@bay2-61.quincy.ziplink.net>

Dolores D. Alcazar <ricdola@email.msn.com> wrote:

>    require "somescript.pl";
> 
>     then just call the subroutine, however, I always get a 550 error...
                                              ^^^^^^^^^^^^^^^^^^^^^^^^
> can someone help me out?

Try running your script from the command line, or looking at the web
server's error logs, to find out *why* you're getting a 550 error.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 14 Jul 1998 19:16:07 -0700
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: cgi module confusion
Message-Id: <waa7m1fkgew.fsf@ese.UCSC.EDU>

Juli@my-dejanews.com writes:
> I'm new to "cgi" perl programming.
> What is the difference between these two lines?
> I know one uses the cgi perl library and the other uses
> the cgi perl module.
> What's the difference between the two,
> and which one is better to use with cgi scripting?
> require "cgi-lib.pl";
> use CGI;

For a comparison of these modules that I did for a talk last year, see
this URL:
	http://www.bayview.com/mindsrc-talk/

It also contains links to information about the two approaches.
Basically cgi-lib.pl was written for Perl 4 and uses the old
non-object-oriented style.  CGI.pm was written for Perl 5 and takes
full advantage of the object-oriented features of Perl 5.  Also,
CGI.pm provides shoftcut useful functions for generating HTML tags,
while cgi-lib.pl only handles the mechanics of passing data from the
form on the previous page to your script.

--Bill.

[posted and mailed]

-- 
William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862
 PGP Key 0x2BD331E5; Public key at http://www.bayview.com/~hermit/pubkey.txt
-----------------------------------------------------------------------------
"Language is a virus from outer space."  --William S. Burroughs


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

Date: Tue, 14 Jul 1998 21:19:42 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: create NCSA combined log from separate agent/referer files?
Message-Id: <comdog-ya02408000R1407982119420001@news.panix.com>
Keywords: from just another new york perl hacker

In article <35ABBE60.E7263803@d2r.com>, Devon Copley <devon@d2r.com> posted:

>Has anyone already written a Perl script to combine separate request,
>agent, and referer log files into a single NCSA combined format
>logfile?  If so, could you send me the code?  Thanks for any help in
>advance -

apache lets you define your own log format.  otherwise, the necessary
information to correalate those logs have been lost and the task is
impossible without making guesses.

-- 
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>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


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

Date: Wed, 15 Jul 1998 01:44:00 GMT
From: waz@interlog.com (Ian Donen)
Subject: error message with sysopen in script from perlfaq5
Message-Id: <35ac0749.1961996@news>


Hi,

I'm trying the following script in a web counter:
----------------------
#!/usr/bin/perl -w

sysopen(FH, "../numvisits.log", O_RDWR|O_CREAT, 0644) or die "can't open
numvisits.log: $!";
flock(FH, 2) 		or die "can't flock numvisits.log: $!";
$num = <FH> || 0;
seek(FH, 0, 0) 		or die "can't rewind numvisits.log: $!";
truncate(FH, 0) 	or die "can't truncate numvisits.log: $!";
(print FH $num+1, "\n")	or die "can't write numvisits.log: $!";
# DO NOT UNLOCK THIS UNTIL YOU CLOSE
close FH 		or die "can't close numvisits.log: $!";
--------------------

This is pretty much directly out of PerlFaq5

However, it's not working! What I get is the following error in my error log:
---------------
Argument "O_SVWST" isn't numeric in sysopen at /cgi-bin/countvisitors.cgi line
3.
can't truncate numvisits.log: Permission denied at /cgi-bin/countvisitors.cgi
line 7,  chunk 1.
---------------

I don't have any documentation that explains sysopen very well, so I don't
understand why this error is occuring. Please help!

Thanks,

-Ian
waz@interlog.com



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

Date: 14 Jul 1998 16:27:04 GMT
From: psi@euclid.jpl.nasa.gov (Peter Scott)
Subject: Re: forking on win32
Message-Id: <6og0so$egm@netline.jpl.nasa.gov>

In article <6o632a$vfi$2@mainsrv.main.nc.us>, scott@softbase.com writes:
> > I noticed that fork is unimplemented on win32, is there
> > a way around this, perhaps through a call to the windows createthread
> > api
> > in kernerl32.dll??
> 
> Absolutely not. Forking is *impossible* in Win32 because of
> differences in the process model. Think VMS when you think Win32.

We're talking about some other kind of VMS than the one from 
Digital?  'Cos the one I used, which had just changed its name to OpenVMS
the last time I did any programming on it, has a working vfork() call.
Is the difference between vfork() and fork() relevant here?

-- 
This is news.  This is your      |  Peter Scott, NASA/JPL/Caltech
brain on news.  Any questions?   |  (psi@euclid.jpl.nasa.gov)

Disclaimer:  These comments are the personal opinions of the author, and 
have not been adopted, authorized, ratified, or approved by JPL.


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

Date: Wed, 15 Jul 1998 01:40:19 GMT
From: stephenwhite@sprint.ca
Subject: How to Call calling file?
Message-Id: <35abfdd7.10651037@news.sprint.ca>

I built/modified some perl code to parse a web page but I do not know
how to call the web page that I just initiated the perl script from.
I need a generic call so that I can embed the perl script into any web
page.

Thanks everyone,

Stephen


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

Date: 14 Jul 1998 21:35:44 -0500
From: Tushar Samant <scribble@pobox.com>
Subject: Re: Indentation
Message-Id: <6oh4i0$26h@tekka.wwa.com>

Hm, I guess plonking down code which looks good with 2-space tabstops
in front of someone who uses 8-space tabstops is equally rude, now
that I think of it. Maybe I will try spaces-only. In any case I still
think having shiftwidths LESS than tabstops is the worst and causes
weird outdents.

Now that this subject has been squeezed dry, how about a flamewar on
"cuddled" elsifs?



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

Date: 14 Jul 1998 23:58:07 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6ograf$bj3@mozo.cc.purdue.edu>

lr@hpl.hp.com (Larry Rosler) writes:

}In "standards-speak" 'deprecated' has a very specific meaning:  "May be 
}removed from the language in a future revision of the standard."  This 
}isn't a value judgment about the feature or its use, just a warning that 
}it may go away some day. 

That meaning of deprecated isn't very standard.  Or at least Bjarne
doesn't think so:

"By deperecating a feature, the standards committee expresses the wish
that the feature would go away.  However, the committee does not have
a mandate to remove a heavily used feature - however redundant or
dangerous it may be.  Thus, a deprecation is a strong hint to the
users to avoid the feature." P818 Bjarne3

So at least one influential document defines "deprecated" to be a
value judgement.  

(Before the big flames come out: I'm arguing that Bjarne is an
influential figure in "standards-speak", not perl.  I also don't deny
the fact that Wall & Associates can define deprecated any way they
want, including one contrary to Bjarne.  But to my knowledge, they
have not done so.)
) 

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Tue, 14 Jul 1998 17:48:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Beautifier Home Page
Message-Id: <MPG.10159c21c99487a989713@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6ograf$bj3@mozo.cc.purdue.edu> on 14 Jul 1998 23:58:07 GMT, 
Michael J Gebis <gebis@albrecht.ecn.purdue.edu> says...
> lr@hpl.hp.com (Larry Rosler) writes:
> 
> }In "standards-speak" 'deprecated' has a very specific meaning:  "May be 
> }removed from the language in a future revision of the standard."  This 
> }isn't a value judgment about the feature or its use, just a warning that 
> }it may go away some day. 
> 
> That meaning of deprecated isn't very standard.  Or at least Bjarne
> doesn't think so:
> 
> "By deperecating a feature, the standards committee expresses the wish
> that the feature would go away.  However, the committee does not have
> a mandate to remove a heavily used feature - however redundant or
> dangerous it may be.  Thus, a deprecation is a strong hint to the
> users to avoid the feature." P818 Bjarne3
> 
> So at least one influential document defines "deprecated" to be a
> value judgement.  
> 
> (Before the big flames come out: I'm arguing that Bjarne is an
> influential figure in "standards-speak", not perl.  I also don't deny
> the fact that Wall & Associates can define deprecated any way they
> want, including one contrary to Bjarne.  But to my knowledge, they
> have not done so.)
> ) 

>From the Jargon Dictionary 
<URL:http://www.intergo.com/Library/ref/internet/jargon/chapt05.htm>:

deprecated: adj. Said of a program or feature that is considered 
obsolescent and in the process of being phased out, usually in favor of a 
specified replacement.  Deprecated features can, unfortunately, linger on 
for many years.  This term appears with distressing frequency in 
standards documents when the committees which write them decide that a 
sufficient number of users have written code which depends on specific 
features which are out of favor.  [Snarling smile added by me.  LR]

>From the C++ Glossary <URL:http://www.sni.net/~glenm/glos.htm#tag063>:

deprecate - to make obsolete (a language feature).

>From "The Design and Evolution of C++" by Bjarne Stroustrup:

(p. 46 in my first-edition copy): ... the C++ ANSI/ISO standard committee 
 ... has decided to deprecate implicit int.  That means that we may get 
rid of it in another decade or so.

(p. 419): ... access-declarations are deprecated.  That is, access-
declarations are slated to be removed sometime in the future after users 
have had ample time to upgrade.

CONCLUSION:  Bjarne knows perfectly well what 'deprecate' means, which is 
*exactly* what I said it means.  The only value judgment is 'obsolescent' 
and the implication is "Don't use it because it may go away."  If Bjarne 
chooses to use a dictionary connotation '...strongly implies regret and 
some degree of condemnation and often carries a suggestion of belittling' 
that is *his* choice, and not what the standards mean.  And he knows it!

And so did Ilya know it, and so, by now, should Tom C :-)

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


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

Date: 15 Jul 1998 01:29:11 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6oh0l7$dav@mozo.cc.purdue.edu>

lr@hpl.hp.com (Larry Rosler) writes:

}CONCLUSION:  Bjarne knows perfectly well what 'deprecate' means, which is 
}*exactly* what I said it means. 

  `When I use a word,' Humpty Dumpty said in rather a scornful tone, `it
  means just what I choose it to mean -- neither more nor less.' 

Unfortunately, I can't tell if this quote is an argument for you or
for me.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Tue, 14 Jul 1998 19:12:49 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Beautifier Home Page
Message-Id: <MPG.1015affeb7e5309989739@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6oh0l7$dav@mozo.cc.purdue.edu> on 15 Jul 1998 01:29:11 GMT, 
Michael J Gebis <gebis@albrecht.ecn.purdue.edu> says...
> lr@hpl.hp.com (Larry Rosler) writes:
> 
> }CONCLUSION:  Bjarne knows perfectly well what 'deprecate' means, which is 
> }*exactly* what I said it means. 
> 
>   `When I use a word,' Humpty Dumpty said in rather a scornful tone, `it
>   means just what I choose it to mean -- neither more nor less.' 
> 
> Unfortunately, I can't tell if this quote is an argument for you or
> for me.

I can :-)  Dodgson was an expert in formal logic, and this statement is 
satirical.

This is why responsible bodies like standards committees define terms or 
refer to an established formal lexicon.  They *tell* you what the terms 
mean when they use them.  Such terms as 'may' and 'should' and 'shall' 
have explicit definitions, which are far more specific than the 
dictionary definitions or common usages (and have legal and commercial 
implications, in many cases).

When Ilya says 'deprecated' and means 'obsolescent and might go away some 
time' it conforms to that formal lexicon (which I labeled "standards-
speak").  If Tom C understands 'deprecated' as 'casting aspersions' he is 
using a different, informal lexicon (which he labeled "Perl-speak").

All I dare add is that "standards-speak" is better defined and is used 
more widely and for much longer than "Perl-speak".

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


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

Date: Wed, 15 Jul 1998 01:59:48 GMT
From: livshits@acm.org
Subject: perl embedding on win32
Message-Id: <6oh2ek$n8f$1@nnrp1.dejanews.com>

Hi, I am trying to embed a perl interpreter into my C program.
I managed to build perl sources using Visual C successfully. However,
when I try to #include EXTERN.h and perl.h into my program, I get
compiler messages complaining about things like
  extern void PerlIO_init _((void));
in perlio.h.

Has anyone else had similar problems?

Please email...

Thanks,
- Vladimir

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 14 Jul 1998 20:43:34 -0400
From: "tdean" <tdean@gte.net>
Subject: Perl Setup on NT
Message-Id: <6ogu63$nje$1@news-2.news.gte.net>

I want to execute my perl scripts from within the Dos box on NT4SP3 from C:\
I have added the following to the path environment variable:
C:\;C:\Perl\bin and rebooted the machine to take effect
when I then open a NT Dos box which defaults to c:\ and I try to execute a
perl script:
perl perlscript.pl  I get the following msg:
"can't open perl script perlscript.pl. No such file or directory"
guys, whats the fix for this?

also, when I go and look at my file associations, I expected to see a .pl
assigned to perl.exe, but there is no .pl in the file associations, although
it shows in the registry. When I create a perl script, an icon is assigned .
Whats the story here?

Any help or information will be greatly appreciated. TIA

--
ICQ 7305805
replace at with @ and dot with .



--
ICQ 7305805
replace at with @ and dot with .




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

Date: Tue, 14 Jul 1998 21:46:36 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Recommend me Perl!
Message-Id: <1dc6ccn.mej3x1sgeloyN@bay2-61.quincy.ziplink.net>

Gabor <gabor@vmunix.com> wrote:

> In comp.lang.perl.misc, Tom Christiansen <tchrist@mox.perl.com> wrote :
> #  [courtesy cc of this posting sent to cited author via email]
> # 
> # Man, it gets worse every day. :-(
> # 
> # _Programming Perl_ (Wall, Christiansen, and Schwartz)
> # _Learning Perl_    (Schwartz and Christiansen; foreword by Wall)
> 
> Just curious, but why does it bother you so much.  Once you even sent me
> email correcting me because I had you last for Programming Perl.  As if
> that makes any difference.

This is probably the safest way to attribute authorship:

_Programming Perl_ (Christiansen, Wall, Christiansen, Schwartz, and
Christiansen)

;-)

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 14 Jul 1998 21:17:03 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: RegExps: Check if string consists of EXACTLY 3 digits ??
Message-Id: <comdog-ya02408000R1407982117030001@news.panix.com>
Keywords: from just another new york perl hacker

In article <r83ec4o8x3.fsf@asc.sps.mot.com>, Martin Gregory <mgregory@asc.sps.mot.com> posted:

>What do you think that this will print (guess before running!)?
>
>  perl -w -e '$a = "zaped\n"; $a =~ s/[a-z]*?(.)$/$1/; print length($a);'
>
>Can you explain the result?

the result is 2.  the dot does not match newlines unless you use
the /s modifier.  the dot matches the d, which is replaced by itself,
and the newline is left as is, leaving a string of length 2.

:)

-- 
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>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


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

Date: Tue, 14 Jul 1998 21:46:38 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: RegExps: Check if string consists of EXACTLY 3 digits ??
Message-Id: <1dc6ckt.11k5mep14ef9vuN@bay2-61.quincy.ziplink.net>

I R A Aggie <fl_aggie@thepentagon.com> wrote:

> /\d{3,3}?/ will match 3, 4 or more digits. Which makes sense, actually
> since it _does_ match _exactly_ 3 digits.

Note that that regular expression is exactly equivalent to /\d{3}/.

Technically, it doesn't match 3, 4 or more digits.  It matches exactly 3
digits, anywhere in a string, so it will successfully match any string
containing 3 or more digits in a row.  Which is pretty much what you
said, just put differently

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 14 Jul 1998 18:16:39 -0500
From: Joe Halbrook <inquiries@halbrook.com>
Subject: Rounding  xxx.xxxxxx to  xxx.xx
Message-Id: <35ABE6D7.6C8C3BB9@halbrook.com>

Here's a quick and easy one for you:

I need to round numbers like:  529.337263  to 529.34

What is the Perl syntax for doing this?

Thank you very much.

Joe Halbrook


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

Date: 15 Jul 1998 00:39:18 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Rounding  xxx.xxxxxx to  xxx.xx
Message-Id: <6ogtnm$44o$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, Joe Halbrook <inquiries@halbrook.com> writes:
:I need to round numbers like:  529.337263  to 529.34
:What is the Perl syntax for doing this?

The way documented in perlfaq4, included with every Perl 
distribution for a long time now, and thus available on 
your system.

Happy grepping,

--tom
-- 
/* Force them to make up their mind on "@foo". */
    --Larry Wall, from toke.c in the v5.0 perl distribution


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

Date: Wed, 15 Jul 1998 00:59:01 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Run a new page from the output of cgi script
Message-Id: <35abf0a3.59836799@nntp.idsonline.com>

Maria TheresiaWettstein <mariatw@pendragon.net> Said this:

>Hello everybody,
>
>I need some help here. I have an output sreen which show me what the
>users entered and uploaded so far but I really need to go ahead to a new
>form which reads some of the data in which was submitted earlier.
>
>Somebody told me to use:
>
>print"Location:http://www.pendragon.net/classifieds/ad_by_week.mv";
>
>but nothing happens. Can somebody advise me what to do and maybe how to
>set up this correctly.

I hope you didn't just put the location statement as printed above
without actually having a resource at /classifieds/ad_by_week.mv
because nothing will happen if there's nothing there.


>
>Also how do I get the new form to display the variables which come from
>the script?
>
>Any tips are very much appreciated.
>

The script that is handling the form data needs to take care of this
stuff.  It's rather simple once you know the "flow of logic".  

For instance, you have a form at http://www.myserver.com/form.html and
someone fills in the form and hits submit.  The <form action> line
reads like this:

<form action="http://www.myserver.com/cgi-bin/myform.cgi">

so the script "myform.cgi" needs to do whatever it does with the form
data, and then for the output it produces, include that form data in
another form, as <input type=text name="user_data" value="whatever the
user entered"> for example.

Let's say you have all the data in variables now, inside the script
"myform.cgi".  you've done whatever server-side stuff you needed to
do, and now you are producing the output to the web browser:

print <<"END_OF_HTML";
Content-type: text/html

<html>
<head>
<title>Submission accepted</title>
</head>
<body>
<h1>Submission accepted</h1>
Your information has been processed, please review this information
before completing the process.
<p>
You entered:
<p>
<form action="http://www.myserver.com/cgi-bin/finalform.cgi">
Name: <input type=text name="user_name" value="$username">
Email Address: <input type=text name="email" value="$email">
Web Page: <input type=text name="url" value="$url">
<<etc>>
<input type=submit value="Submit">

</body>
</html>
END_OF_HTML





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

Date: Tue, 14 Jul 1998 21:46:39 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Simple problem with perl script.
Message-Id: <1dc6eq1.gbxt6e19zwoqyN@bay2-61.quincy.ziplink.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> > >  foreach $line (@lines) {
> > >   ($username, $2, $3, $4, $5, $6, $7, $8, $9) = split (/:/, $_, 9);
>
> That line attempts to write into read-only variables, as the '-w' flag
> would have revealed.

Don't even need -w for that; it's a fatal error.

(The poster probably didn't see the error message because he didn't
check the error logs on his web server.  :-)

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 14 Jul 1998 19:19:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Simple problem with perl script.
Message-Id: <MPG.1015b18a2b02e23198973a@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <1dc6eq1.gbxt6e19zwoqyN@bay2-61.quincy.ziplink.net> on Tue, 14 
Jul 1998 21:46:39 -0400, Ronald J Kimball <rjk@coos.dartmouth.edu> 
says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> 
> > > >  foreach $line (@lines) {
> > > >   ($username, $2, $3, $4, $5, $6, $7, $8, $9) = split (/:/, $_, 9);
> >
> > That line attempts to write into read-only variables, as the '-w' flag
> > would have revealed.
> 
> Don't even need -w for that; it's a fatal error.
> 
> (The poster probably didn't see the error message because he didn't
> check the error logs on his web server.  :-)

Right.

perl -e '$1 = $_'

I blindly assumed he had *tried* 'perl -c' before posting the code.  :-(

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


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

Date: Tue, 14 Jul 1998 16:43:27 -0700
From: Nathan Franzen <franzen@pmel.noaa.gov>
Subject: Re: Sticking in NULL after split
Message-Id: <Pine.SOL.3.96.980714142608.4568A-100000@corona.pmel.noaa.gov>

On Tue, 14 Jul 1998, Douglas Wilson wrote:

> On 14 Jul 1998 20:35:22 GMT, beatle@arches.uga.edu (Benjamin Dixon)
> wrote:
> >($var1, $var2, $var3) = split(/:/);
> 
> >But say $var2 is an empty string... so that the output is:
> >var1,,var3
> 
> > how can I place the word 'NULL' inbetween each?
> 
> $str='a:b::c';
> @arr=map {($_ eq "")?"NULL":$_} split(/:/,$str);
> print join(",",@arr),"\n";

As I was mulling this over, Douglas Wilson's solution was the first to
occur to me, and I wondered whether it was preferable to '1 while s///'.

It's not.

#!/opt/local/bin/perl -w
use Benchmark;
$s = 'ook,,pook,crumb,bum,,,talk,,walk,,,,,,oof';
timethese(shift,
	  {
	   'substitute'=>'1 while $s=~s/,,/,NULL,/;@a=split /,/,$s',
	   'map'=>'@a=split /,/, $s; @a = map {$_?$_:"NULL"} @a'
	  }
	 );
__END__
Benchmark: timing 30000 iterations of map, substitute...
       map:  5 secs ( 4.67 usr  0.00 sys =  4.67 cpu)
substitute:  2 secs ( 1.59 usr  0.00 sys =  1.59 cpu)

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

I tried to time the difference between
    1 while $s=~s/,,/,NULL,/;
and 
    1 while $s=~s/,,/,NULL,/g;

but didn't see any significant difference.  The single substitution
appears to be *slightly* faster than '/g'.

But I came across another curiosity.  The following strings all have
fifteen colons.  The answers are all different.

$s="o:".(":" x 14);  @s=split /:/,$s;       print scalar @s,"\n";
$s=(":" x 14)."o:";  @s=split /:/,$s;       print scalar @s,"\n";
$s=(":" x 15);       @s=split /:/,$s, -1;   print scalar @s,"\n";

The important observation here is that trailing "NULLS" at the end of the
string will *not* be split by default.  This is another reason to
substitute the NULLS before splitting.  'split' has all kinds of curious
behaviors which trap the unwary yet ... well ... somebody must love 'em. 

-N

Nathan CM Franzen   franzen@pmel.noaa.gov | NOAA/PMEL
                    (206)-526-4808        | NOAA Western Regional Center
TAO project:                              | 7600 Sand Point Way NE
http://www.pmel.noaa.gov/toga-tao/        | Seattle WA 98115          





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

Date: 14 Jul 1998 21:24:19 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Sticking in NULL after split
Message-Id: <6oh0c3$mg5$1@pilot.njin.net>

Hello -

mcafee@moonpatrol.rs.itd.umich.edu (Sean McAfee) writes:

>In article <6ogfea$4ug$1@cronkite.cc.uga.edu>,
>Benjamin Dixon <beatle@arches.uga.edu> wrote:
>>I am trying to write a perl script that will generate a create statement
>>for an SQL server. Its pretty much just parsing an ascii file exported
>>from a different server... anyways, I split the thing into separate
>>variables like so:

>>($var1, $var2, $var3) = split(/:/);

>>then I want to print the results, separated by commas like so:

>>print "$var1, $var2, $var3";

>>But say $var2 is an empty string... so that the output is:

>>var1,,var3

>>In this case I see that I could just use s// and get the output to look
>>like this var1,NULL,var3. but if I have more than two commas, say
>>var1,,,var3, or even 100, how can I place the word 'NULL' inbetween each?
>>Probably a simple answer but I'm pretty new to perl. Thanks.

>This should do the trick:

>($var1, $var2, $var3) = map { $_ || "NULL" } split /:/;



The only thing is... that wong is... that won't work if any of the elements of the
split are 0.  (Which may or may not be an issue for this particular
case, but still.)


David Black
dblack@pilot.njin.net  <-- reasonably on-the-ball server du jour (sigh)
dblack@saturn.superlink.net  <-- slightly better for mail


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

Date: 14 Jul 1998 21:28:13 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Sticking in NULL after split
Message-Id: <6oh0jd$mhr$1@pilot.njin.net>

Hello -

beatle@arches.uga.edu (Benjamin Dixon) writes:

>I am trying to write a perl script that will generate a create statement
>for an SQL server. Its pretty much just parsing an ascii file exported
>from a different server... anyways, I split the thing into separate
>variables like so:

>($var1, $var2, $var3) = split(/:/);

>then I want to print the results, separated by commas like so:

>print "$var1, $var2, $var3";

>But say $var2 is an empty string... so that the output is:

>var1,,var3

>In this case I see that I could just use s// and get the output to look
>like this var1,NULL,var3. but if I have more than two commas, say
>var1,,,var3, or even 100, how can I place the word 'NULL' inbetween each?
>Probably a simple answer but I'm pretty new to perl. Thanks.


You could actually use s///:

$string =~ s/,(?=,)/,NULL/g;

but that's risky and vulnerable (could there be two consecutive commas
in the value of one of the variables? etc.).

Here's one way:

my $string = "one:two:0:four::five";
print join ',', map { $_ eq " && "NULL" || $_ } split ':', $string;


David Black
dblack@pilot.njin.net
dblack@saturn.superlink.net  <-- slightly better for mail


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

Date: Tue, 14 Jul 1998 21:35:12 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Sticking in NULL after split
Message-Id: <comdog-ya02408000R1407982135120001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6oh0c3$mg5$1@pilot.njin.net>, dblack@pilot.njin.net (David Alan Black) posted:

>mcafee@moonpatrol.rs.itd.umich.edu (Sean McAfee) writes:

>>($var1, $var2, $var3) = map { $_ || "NULL" } split /:/;

>The only thing is... that wong is... that won't work if any of the elements of the
>split are 0.  (Which may or may not be an issue for this particular
>case, but still.)

so change it a little bit:

   @array = map { defined($_) ? $_ : 'NULL' } split /:/;

-- 
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>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


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

Date: Tue, 14 Jul 1998 21:46:41 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Sticking in NULL after split
Message-Id: <1dc6eu5.yrnnq01v8s8zuN@bay2-61.quincy.ziplink.net>

Sean McAfee <mcafee@moonpatrol.rs.itd.umich.edu> wrote:

> ($var1, $var2, $var3) = map { $_ || "NULL" } split /:/;

Only if you want zeroes to be replaced with 'NULL'.  I've been bitten by
that one before.  :-)

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 14 Jul 1998 19:27:36 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sticking in NULL after split
Message-Id: <MPG.1015b371651d8fb798973b@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6oh0jd$mhr$1@pilot.njin.net> on 14 Jul 1998 21:28:13 -0400, 
David Alan Black <dblack@pilot.njin.net> says...
 ...
> my $string = "one:two:0:four::five";
> print join ',', map { $_ eq " && "NULL" || $_ } split ':', $string;
                   --->       ''       <---
or

  print join ',', map { length && $_ || "NULL" } split ':', $string;

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


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

Date: Tue, 14 Jul 1998 19:29:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sticking in NULL after split
Message-Id: <MPG.1015b3ded710a99798973c@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <comdog-ya02408000R1407982135120001@news.panix.com> on Tue, 14 
Jul 1998 21:35:12 -0400, brian d foy <comdog@computerdog.com> says...
> In article <6oh0c3$mg5$1@pilot.njin.net>, dblack@pilot.njin.net (David Alan Black) posted:
> 
> >mcafee@moonpatrol.rs.itd.umich.edu (Sean McAfee) writes:
> 
> >>($var1, $var2, $var3) = map { $_ || "NULL" } split /:/;
> 
> >The only thing is... that wong is... that won't work if any of the elements of the
> >split are 0.  (Which may or may not be an issue for this particular
> >case, but still.)
> 
> so change it a little bit:
> 
>    @array = map { defined($_) ? $_ : 'NULL' } split /:/;

Did you mean 'length'?  The value returned by split is a null string, but 
is defined, yes?

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


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

Date: Tue, 14 Jul 1998 22:57:25 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Sticking in NULL after split
Message-Id: <comdog-ya02408000R1407982257250001@news.panix.com>
Keywords: from just another new york perl hacker

In article <MPG.1015b3ded710a99798973c@nntp.hpl.hp.com>, lr@hpl.hp.com (Larry Rosler) posted:

>> 
>>    @array = map { defined($_) ? $_ : 'NULL' } split /:/;
>
>Did you mean 'length'?  The value returned by split is a null string, but 
>is defined, yes?

oy - yes, you're right.  length works:

   @files = map { length $_ ? $_ : 'NULL' } split /:/;

although i was thinking

   @files = map { $_ ne '' ? $_ : 'NULL' } split /:/;

-- 
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>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>
that '' gets me every time.


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

Date: Tue, 14 Jul 1998 21:26:33 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: trying to install perl
Message-Id: <comdog-ya02408000R1407982126330001@news.panix.com>
Keywords: from just another new york perl hacker

In article <Pine.OSF.3.96.980714133511.18706A-100000@natsys2.cceer.lsu.edu>, Yazan Moh'd Al-Issa <yazan@natsys2.cceer.lsu.edu> posted:

>        I am trying to install perl on my digital dec alpha
>machine(OSF"UNIX").  After runing configure, I don't know whether perl is
>installed successfully or not, since I don't even know how the perl
>interface looks like(if any).  when i type the command perl I recieve a
>blinking curser and that is it.  I am gonna appreciate it if some one can
>help.

follow the installation instructions.  even the parts that show you
how to test your perl:

   make test

if all of that looks good, you can start writing Perl scripts.  they
are plain text files.  to find out the language, check out

   Learning Perl
   Randal L. Schwartz & Tom Christiansen
   ISBN 1-56592-284-0 
   <URL:http://www.oreilly.com>

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>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


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

Date: 14 Jul 1998 21:27:26 -0500
From: Tushar Samant <scribble@pobox.com>
Subject: Re: WebBots
Message-Id: <6oh42e$s6u@tekka.wwa.com>

abigail@fnx.com writes:
>Darren Sweeney (darrensw@pacbell.net) wrote on MDCCLXXVIII September
>MCMXCIII in <URL: news:6oem67$olr$1@nnrp3.snfc21.pbi.net>:
>++ Hi all,
>++ 
>++ Is there a benefit to using perl/cgi rather than Frontpage WebBots. i need
>++ to make a decision which one to focus on.
>++ 
>++ All comments welcomed, thanks
>
>Webbots don't have airconditioning.

ABIGAIL MY AIRCONDITIONING IS BROKEN!



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

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


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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