[10619] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4211 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 13 01:07:27 1998

Date: Thu, 12 Nov 98 22:00:21 -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           Thu, 12 Nov 1998     Volume: 8 Number: 4211

Today's topics:
    Re: a RE for email addresses? (Martien Verbruggen)
    Re: Allowing escaped characters in a split (Kelly Hirano)
    Re: Allowing escaped characters in a split <ebohlman@netcom.com>
    Re: Allowing escaped characters in a split (Martien Verbruggen)
    Re: Allowing escaped characters in a split (Martien Verbruggen)
        Compiling Perl <randy@stonemarche.org>
        Definition of "odd characters" in -T/-B documentation. <ljz@asfast.com>
        Dynamic Array of FileHandles <tanthalas@mci2000.com>
    Re: Dynamic Array of FileHandles (Martien Verbruggen)
    Re: HELP!  Concat'ing multiple variables into one (Ronald J Kimball)
        How can I blank-pad a string variable?? <ESGDW@email.ais.unc.edu>
    Re: How can I blank-pad a string variable?? <uri@sysarch.com>
        How to do this without goto? <ttsg@ttsg.com>
    Re: Is it possible to pass ref of regular expression? <ebohlman@netcom.com>
    Re: MacPerl, Help, and Internet Config (Iain Chalmers)
        More efficient coding? bigcheese@my-dejanews.com
    Re: More efficient coding? (Sam Holden)
    Re: More efficient coding? <susanne@divine.net>
    Re: More efficient coding? <uri@sysarch.com>
        Passing data between cgi scripts. <u2537@shurflo.com>
    Re: Passing data between cgi scripts. jbharvey@corp.home.net
        Problem with extra new lines <mlabor@mexico.com>
    Re: Problem with extra new lines (Martien Verbruggen)
    Re: Security - How to circumvent it. (Eric Hagen)
        User pressing Esc or Stop after sending form... <bobm@cunix.com>
        What's wrong with this perl program? <zzhang@bayou.uh.edu>
    Re: What's wrong with this perl program? (Martien Verbruggen)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 13 Nov 1998 05:04:17 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: a RE for email addresses?
Message-Id: <l5P22.67$q%.192@nsw.nnrp.telstra.net>

In article <364B953A.C359E0BB@hotmail.com>,
	sara starre <nospam.gear4u@hotmail.com> writes:
> I tried to use the /.+\@.+\..+(\..+)*/ to find good email addresses, but
> it let
> "my mail@myplace.com" thru, so I modified it to:  /.+\@.+\..+(\..+)*/ &&
> !/[\s]/

It would have been simpler to change some of the dots in your regexp
to \w or some other character class that you decide you want to
accept. It's just as arbitrary.

> According to my camel book, /.+/ should be one or more characters- is
> whitespace considered a character?

Sure it is.

> Does anyone have any better suggestions for RE's to validate email
> addresses? This one seems pretty good:

See below.

> good: mymail@mycompany.com
> bad: mymail#myplace.com
> bad: my mail@myplace.com
> bad: mymail@myplace
> good: m1ymail@my1place2.com3good:
> good: m1ymail@my1place2.mystate.com3
> bad: m1ymail@my1place2.mystate. com3

you know... Many of the email addresses marked as bad in the above are
in fact fine. Some of the ones marked as good are incorrect, and
almost guaranteed to be undeliverable.

Instead of summarising all the problems, once again, I'll advise you
to use dejanews to find the hundreds of posts in the past that have
talked about this.

I also urge you to read perlfaq9:

# perldoc perlfaq9
/How do I check a valid mail address?

It gives you a whole list of pointers about why it's impossible to do
it in real time, and points you to a regexp by Tom Christiansen which
at least checks an email address against the RFC that describes them.

> PS: Thanks for the help with my assignment question.. :)

Assignment as in homework? I wonder why they would give you an
assigment that has no correct answer, and to which all the
approximations to correct answers have already been done, and are
freely available.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd.       | make a better idiot.
NSW, Australia                      | 


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

Date: 12 Nov 1998 18:50:46 -0800
From: hirano@Xenon.Stanford.EDU (Kelly Hirano)
To: joseph@zieglerzone.com
Subject: Re: Allowing escaped characters in a split
Message-Id: <72g6q6$6ap@Xenon.Stanford.EDU>

[posted and mailed]

In article <72g5iv$31t$1@nnrp1.dejanews.com>,  <joseph@zieglerzone.com> wrote:
>I'm trying to split on a comma, but I would like to allow people to escape the
>original string to allow a comma to exist after the split.
>
>Example:
>cars, trucks, vans\,s, bikes
>Should split into
>cars
>trucks
>van,s
>bikes

from perlre (`perldoc perlre`):
       (?<!pattern)
                 A zero-width negative lookbehind assertion.  For
                 example /(?<!bar)foo/ matches any occurrence of
                 "foo" that isn't following "bar".  Works only
                 for fixed-width lookbehind.

#!/usr/local/bin/perl5.005_01 -w

my $string = 'cars, trucks, vans\,s, bikes';

## use a zero-width nagative lookbehind assertion
my @array = split(/(?<!\\),/, $string);

## gotta get rid of the \'s
foreach (@array) {
  s/\\//g;
}

print join("\n", @array), "\n";

__END__

results in:
cars
 trucks
 vans\,s
 bikes
-- 
Kelly William Hirano	                    Stanford Athletics:
hirano@cs.stanford.edu	                 http://www.gostanford.com/
hirano@alumni.stanford.org      (WE) BEAT CAL (AGAIN)! 100th BIG GAME: 21-20


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

Date: Fri, 13 Nov 1998 04:53:53 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Allowing escaped characters in a split
Message-Id: <ebohlmanF2CG9t.Lw5@netcom.com>

joseph@zieglerzone.com wrote:
: I'm trying to split on a comma, but I would like to allow people to escape the
: original string to allow a comma to exist after the split.

Take a look at the Text::Parsewords module that comes with the standard 
distribution.  If that won't do what you want, go over to CPAN and check 
out Text::CSV.



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

Date: Fri, 13 Nov 1998 05:09:54 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Allowing escaped characters in a split
Message-Id: <CaP22.69$q%.192@nsw.nnrp.telstra.net>

In article <72g5iv$31t$1@nnrp1.dejanews.com>,
	joseph@zieglerzone.com writes:

> I'm trying to split on a comma, but I would like to allow people to
> escape the original string to allow a comma to exist after the
> split.

> cars, trucks, vans\,s, bikes

#!/usr/local/bin/perl5.00502 -w
use strict;

while(<DATA>)
{
	chomp;
	print join(':', split( /(?<!\\),/ )), "\n";
}

__DATA__
1,2,3,4
1\,2,3,4

Of course, you'll have to 'unescape' the comma at some point as well.

# perldoc perlre

Martien
-- 
Martien Verbruggen                  | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au    | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd.       | I can ask him what he meant - Steven
NSW, Australia                      | Wright


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

Date: Fri, 13 Nov 1998 05:10:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Allowing escaped characters in a split
Message-Id: <BbP22.70$q%.192@nsw.nnrp.telstra.net>

In article <72g6q6$6ap@xenon.stanford.edu>,
	hirano@Xenon.Stanford.EDU (Kelly Hirano) writes:

> ## gotta get rid of the \'s
> foreach (@array) {
>   s/\\//g;
> }

There may be backslashes in there which are not followed by a comma.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | The gene pool could use a little
Commercial Dynamics Pty. Ltd.       | chlorine.
NSW, Australia                      | 


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

Date: Thu, 12 Nov 1998 22:13:59 -0500
From: "Randy Perryman" <randy@stonemarche.org>
Subject: Compiling Perl
Message-Id: <72g87a$55h$1@pyrite.mv.net>

Help.....

I am trying to compile the stable.zip of perl and my head hurts.  I am not
too familiar with the compilers, but I keep getting a syntax error when I
try.  I am using Microsofts Visual C++ 5.0 with sp3 applied.  Can some one
help...






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

Date: 12 Nov 1998 23:28:44 -500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Definition of "odd characters" in -T/-B documentation.
Message-Id: <ltbtmcfc77.fsf@asfast.com>

I'm running version 5.005_02.

The documentation for the `-T' and `-B' operators in the `perlfunc'
man pages states this:

   The -T and -B switches work as follows.  The first
   block or so of the file is examined for odd
   characters such as strange control codes or
   characters with the high bit set.    [ ... ]

What is the meaning of "odd characters" and "strange control codes" in
this context?  If this is documented somewhere outside the Perl source
code itself, could anyone point me to this documentation?  Or if I do
have to get this out of the source code, could someone point me to the
appropriate source file?

Thanks in advance.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'


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

Date: Fri, 13 Nov 1998 03:08:02 GMT
From: Tanis <tanthalas@mci2000.com>
Subject: Dynamic Array of FileHandles
Message-Id: <364BA3B5.13AC27F2@mci2000.com>

I am writing a script that has "n" number of log files.  I need to merge
all of the files line by line according to the time on each line.  So, I
need to figure out how to open all of the files at one time.
Essentially, I want to create an array of FileHandles.  Does anyone know
how to do this?  I tried something, not this specific code, but along
the lines of the following code:


for ($z = 0; $z < $#array_num; $z++) {
    $path = "/dir1/dri2/dir3/logfile[$z]";
    $templine1 = "open(FILEHANDLE$z, \"$path\") || die \"$path: $!\n";
    eval $templine1;
    $templine2 = "$line = <FILEHANDLE$z>";
    eval $templine2;
}

The problem is that it does not open the file and read from it.  I keep
getting empty lines.  If you know a work around, please tell me.

Thanks



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

Date: Fri, 13 Nov 1998 05:13:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Dynamic Array of FileHandles
Message-Id: <0eP22.71$q%.192@nsw.nnrp.telstra.net>

In article <364BA3B5.13AC27F2@mci2000.com>,
	Tanis <tanthalas@mci2000.com> writes:

> Essentially, I want to create an array of FileHandles.  Does anyone know
> how to do this?

Anyone who reads the FAQ knows how to do this:

# perldoc perlfaq5
     How can I make a filehandle local to a subroutine?  How do I
     pass filehandles between subroutines?  How do I make an
     array of filehandles?

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd.       | crops where there ain't no crops.
NSW, Australia                      | 


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

Date: Fri, 13 Nov 1998 00:46:55 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: HELP!  Concat'ing multiple variables into one
Message-Id: <1diebog.1ywamme1h3hvmwN@bay1-325.quincy.ziplink.net>

D. Davis <dlincoln@ultrainteractive.com> wrote:

> # Put variables into an array... then make array row = single variable
> # Then make array text = to single variable.
> #
> $searchterm[0] = ($input{'level'});
> $searchterm[1] = ($input{'topic'});
> $searchterm[2] = ($input{'subject'});
>  
> $search_terms = "@searchterm";
   ^^^^^^^^^^^^

> $search_terms = $searchterm[0].$searchterm[1].$searchterm[2];
                   ^^^^^^^^^^     ^^^^^^^^^^     ^^^^^^^^^^

These variable names don't match.  Fix it and it will work.


> # Make seperate variables... then insert variables into an array...
> # Then make array text = to single variable.
> #
> $level = ($input{'level'});
> $topic = ($input{'topic'});
> $subject = ($input{'subject'});
>  
> @search_keys = ("$level", "$topic", "$subject");
> 
> $search_terms = "@search_keys";

This will work.

> # Make seperate variables... then try to concatentate variables w/ .=
> # as in:
> # $new_row .= "$day\|$month\|$year\|$session_username\|";
> 
> $level = ($input{'level'});
> $topic = ($input{'topic'});
> $subject = ($input{'subject'});
> $search_terms .= "$level\ $topic\ $subject";

This will work, although the new string will concatenated to the
previous value of $search_terms, whereas in your other two examples the
previous value is replaced.


TMTOWTDI.  All of these ways work.  If they really don't work for you,
you'll have to provide more info.

-- 
 _ / '  _      /         - 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: Thu, 12 Nov 1998 15:54:27 -0500
From: Gary Wolgast <ESGDW@email.ais.unc.edu>
Subject: How can I blank-pad a string variable??
Message-Id: <364B4B03.61D011D@email.ais.unc.edu>

I need to set up a variable that is to be 8 bytes long.  The first 5
characters are alphabetic but the last 3 must be blank.  I'm having no
luck at all.  Any ideas??  Thanks!



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

Date: 12 Nov 1998 23:22:56 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How can I blank-pad a string variable??
Message-Id: <x7ww506x27.fsf@sysarch.com>

>>>>> "GW" == Gary Wolgast <ESGDW@email.ais.unc.edu> writes:

  GW> I need to set up a variable that is to be 8 bytes long.  The first
  GW> 5 characters are alphabetic but the last 3 must be blank.  I'm
  GW> having no luck at all.  Any ideas??  Thanks!

there have been many threads on this subject. search dejanews for some
in the last few months. look for pad.

i also wrote an FAQ entry for this which will be in some future version
of that document. there are 2 zillion ways to do this in perl. 

hth,

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 12 Nov 1998 22:36:52 -0500
From: "Scott J. Ellentuch" <ttsg@ttsg.com>
Subject: How to do this without goto?
Message-Id: <364BA954.CF83C08@ttsg.com>

Hi,

Trying to figure out how to do something, wondering if people can help.

open (LIST,"<list");

while (<LIST>)
{
  if ($true)
  { 
    $SIG{'ALRM'} = 'toolong';
    alarm 6;
    $result=&readfile($_);
    alarm 0;
  }

  CONTINUE:
  print "Result for ".$_."was ".$result."\n";
}
close (LIST);
exit 0;
sub toolong
{
  print "Couldn't read the file within 6 seconds\n";
  goto CONTINUE;
}

The problem is that it tells me that it can't "goto" outside the
block.  How can I do this differently and get it to work properly?

Email copies would be nice.

Thanks, Tuc/TTSG


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

Date: Fri, 13 Nov 1998 04:48:52 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Is it possible to pass ref of regular expression?
Message-Id: <ebohlmanF2CG1H.LI6@netcom.com>

Damian Conway <damian@cs.monash.edu.au> wrote:
: bill_raty@my-dejanews.com writes:

: >    @newlist = mygrep( m/^b/i, @list );

: >and have the calling mechanism build a coderef for you (i.e. more condusive to
: >laziness)?

: You want the qr/.../ operator that was introduced in Perl 5.005.
: See the perlop manpage for details.

That reminds me: is there any way of doing a repeated (/g) match on a 
qr'd regexp short of interpolating it into an m/.../g construct?  If not, 
how expensive is such an interpolation?  Does the compiler treat a regexp 
consisting of only an interpolation of a compiled regexp as a special 
case to optimize?



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

Date: Fri, 13 Nov 1998 14:24:38 +1100
From: bigiain@mightymedia.com.au (Iain Chalmers)
Subject: Re: MacPerl, Help, and Internet Config
Message-Id: <bigiain-1311981424380001@bigman.mighty.aust.com>

In article <72g5eo$312$1@nnrp1.dejanews.com>, johnny99@sydney.dialix.oz.au
wrote:

> I'm sure this question has been asked before, and I apologise like hell, but I
> can't seem to find a fix for it, or a reference on DejaNews:
> 
> I can't get MacPerl's help menu to work. Every time I try it says:
> 
> Could not find helper for "pod". Do you want to create one?
> 
> "For "file" you should specifiy a WWW browser as the helper"
> 
> and then offers to open internet Config. I have done various things with
> internet config, (like, oh, I don't know, specifying a WWW browser as the
> helper for "file" for instance!) and nothing seems to work.
> 
> What the hell is going on?

there's an app called "shuck" included in the macperl distribution, you
need to tell internet config to use shuck for .pod files.


from the README.MAC file:
> Online Help
> -----------
> 
> MacPerl 5 comes with a considerable amount of pod based online help. For this
> help to work, make sure you have:
> 
>  - "MacPerl Help" and the "pod" folder in the same folder as your MacPerl
>    application.
>  - A recent version of Internet Config (Version 1.4 is
>    bundled with your distribution).
>  - Set up Internet Config with a helper for 3http2, set to a WWW Browser, and 
>    the 3Shuck2 application as the helper for 3pod2. 




> 
> TIA, please crosspost, redirect me, flame me, etc as appropriate,

*READ* *THE* *DOCS* - oh, hang on, you're trying too - good :-)

you may want to try the macperl mailing list out - a great place to ask
questions like this... these's a link to it on
<http://www.ptf.com/macperl/>

cheers

Iain


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

Date: Fri, 13 Nov 1998 02:52:04 GMT
From: bigcheese@my-dejanews.com
Subject: More efficient coding?
Message-Id: <72g6sk$440$1@nnrp1.dejanews.com>

There HAS to be a better way to do this:

if ($fi eq "do" || $fi eq "da" || $fi eq "du" || $fi eq "di" || $fi eq "de") {

^_^

Can anybody help me?

Thanks!
-Dan

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


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

Date: 13 Nov 1998 03:10:57 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: More efficient coding?
Message-Id: <slrn74n8q1.r7f.sholden@pgrad.cs.usyd.edu.au>

On Fri, 13 Nov 1998 02:52:04 GMT, bigcheese@my-dejanews.com
	<bigcheese@my-dejanews.com> wrote:
>There HAS to be a better way to do this:
>
>if ($fi eq "do" || $fi eq "da" || $fi eq "du" || $fi eq "di" || $fi eq "de") {
>
if (length($fi)==2 && $fi=~/d[aeiou]/) {

I suggest you read up on regular expressions...

perldoc perlre

-- 
Sam

Simple rule: include files should never include include files.
	--Rob Pike


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

Date: Thu, 12 Nov 1998 20:48:50 -0700
From: Susanne Austin <susanne@divine.net>
Subject: Re: More efficient coding?
Message-Id: <364BAC21.7306634B@divine.net>

how about

    if ($fi =~ /^d[aeiou[$/

Sam Holden wrote:

> On Fri, 13 Nov 1998 02:52:04 GMT, bigcheese@my-dejanews.com
>         <bigcheese@my-dejanews.com> wrote:
> >There HAS to be a better way to do this:
> >
> >if ($fi eq "do" || $fi eq "da" || $fi eq "du" || $fi eq "di" || $fi eq "de") {
> >
> if (length($fi)==2 && $fi=~/d[aeiou]/) {
>
> I suggest you read up on regular expressions...
>
> perldoc perlre
>
> --
> Sam
>
> Simple rule: include files should never include include files.
>         --Rob Pike




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

Date: 12 Nov 1998 23:21:12 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: More efficient coding?
Message-Id: <x7zp9w6x53.fsf@sysarch.com>

>>>>> "SH" == Sam Holden <sholden@pgrad.cs.usyd.edu.au> writes:

  SH> On Fri, 13 Nov 1998 02:52:04 GMT, bigcheese@my-dejanews.com
  SH> <bigcheese@my-dejanews.com> wrote:
  >> There HAS to be a better way to do this:
  >> 
  >> if ($fi eq "do" || $fi eq "da" || $fi eq "du" || $fi eq "di" || $fi
  >> eq "de") {
  >> 
  SH> if (length($fi)==2 && $fi=~/d[aeiou]/) {

  SH> I suggest you read up on regular expressions...

and you too! :-)

if ( $fi =~ /^d[aeiou]\z/) {

this is using 5.005.

hth,

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 12 Nov 1998 22:23:36 -0600
From: Thomas Beardshear <u2537@shurflo.com>
Subject: Passing data between cgi scripts.
Message-Id: <364BB448.1F902B36@shurflo.com>


I'm trying to create a cgi script that verifies a form(another cgi
script) before it processes the information.
If the verification process fails, I want to return the user to the
first cgi script to fix the problem.

I can see the form data in the 2nd cgi script, but I can't seem to pass
it back to the first script. I added $query->dump statements to both cgi

scripts to see what they're getting. Cgi script 2 works great, but the
data
is not being passed back to the 1st cgi script.

I want to do something like this in cgi script #1.

print '<textarea name="desc"...>';
if ( $query->param(desc) ne "" ) {
print data;
}
print '</textarea>';

If cgi script is called first, the text area would be blank, otherwise
it would have whatever the user typed before. i.e.

User runs cgi script 1
User enters data
Submit button calls cgi script 2
Cgi script 2 detects error and calls cgi script 1 with "data entered by
user"


but I don't know if that breaks any rules for html or forms.

Is there any way to pass data between cgi scripts without specifying
them on the url? I heard some people using files, but that will slow the

process down. (maybe not by much?).

Anyone have any suggestions?

Also, when I use Netscape to view the Page Source, I get one long line
of text instead of screen-wrapped text. Anyone know how to fix this as
well?





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

Date: Fri, 13 Nov 1998 05:35:49 GMT
From: jbharvey@corp.home.net
Subject: Re: Passing data between cgi scripts.
Message-Id: <VyP22.78$_g.430459@news.rdc1.sfba.home.com>

if ($query->param('desc')) {
    print $q->textarea(-name=>'textarea', -default=>$data);
}

Make sure that you set 'desc' in the previous script either with a hidden
param or a normal param.  See example in my previous reply.

Also in my previous reply I talked about the hidden fields:

print $query->hidden(-name=>'hidden_name', -default=>['value1','value2'...]);

Do you remember this at all?  Perhaps you should start referring to the 
CGI.pm manual: http://stein.cshl.org/WWW/software/CGI/cgi_docs.html

j

Thomas Beardshear <u2537@shurflo.com> wrote:

> I'm trying to create a cgi script that verifies a form(another cgi
> script) before it processes the information.
> If the verification process fails, I want to return the user to the
> first cgi script to fix the problem.

> I can see the form data in the 2nd cgi script, but I can't seem to pass
> it back to the first script. I added $query->dump statements to both cgi

> scripts to see what they're getting. Cgi script 2 works great, but the
> data
> is not being passed back to the 1st cgi script.

> I want to do something like this in cgi script #1.

> print '<textarea name="desc"...>';
> if ( $query->param(desc) ne "" ) {
> print data;
> }
> print '</textarea>';

> If cgi script is called first, the text area would be blank, otherwise
> it would have whatever the user typed before. i.e.

> User runs cgi script 1
> User enters data
> Submit button calls cgi script 2
> Cgi script 2 detects error and calls cgi script 1 with "data entered by
> user"


> but I don't know if that breaks any rules for html or forms.

> Is there any way to pass data between cgi scripts without specifying
> them on the url? I heard some people using files, but that will slow the

> process down. (maybe not by much?).

> Anyone have any suggestions?

> Also, when I use Netscape to view the Page Source, I get one long line
> of text instead of screen-wrapped text. Anyone know how to fix this as
> well?





--
Justin B. Harvey					@Home Network
@Work Software Engineer					425 Broadway
jbharvey@corp.home.net					Redwood City, CA 94063
Voice: (650) 569-5692					http://www.home.net


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

Date: Thu, 12 Nov 1998 23:06:56 -0500
From: "Manuel Labor" <mlabor@mexico.com>
Subject: Problem with extra new lines
Message-Id: <72gb7p$qde$1@oak.prod.itd.earthlink.net>

I am trying to combine two array varibles into one string.  The problem is
when i use the following

$sep=" ";
$combine=join $sep,$datag, $newsymbol;
  print FINALDATA $combine;

I get these results:

 gbfe
" 11/12/98","   .656  ","   .594  ","   .656  ","   .594  ","    213,800"

the gbfe is $newsymbol, the second line is $datag

both $newsymbol and $datag are values from 2 separate arrays (@newsymbol and
@datag)

I have tried using chop and chomp, chop completel remove the var and chomp
gives a number instead of the "gbfe"

Thanks for anyhelp







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

Date: Fri, 13 Nov 1998 05:32:30 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Problem with extra new lines
Message-Id: <OvP22.74$q%.192@nsw.nnrp.telstra.net>

Please read the following information on how to choose a good subject
line: http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

In article <72gb7p$qde$1@oak.prod.itd.earthlink.net>,
	"Manuel Labor" <mlabor@mexico.com> writes:

>  gbfe
> " 11/12/98","   .656  ","   .594  ","   .656  ","   .594  ","    213,800"
> 
> the gbfe is $newsymbol, the second line is $datag
> 
> both $newsymbol and $datag are values from 2 separate arrays (@newsymbol and
> @datag)
> 
> I have tried using chop and chomp, chop completel remove the var and chomp
> gives a number instead of the "gbfe"

You really should try being a bit more clear about what your exact
problem is. I had to read this message three times before I figured
out that you were not complaining about join not doing what you want,
but about having newlines in your strings.

chomp will definitely do the trick, but ONLY if you have not changed
the builtin $? variable. If you have, you will make sure you set it
back to its original state. chomp returns the number of characters
chomped.

chop chops of the last character and returns the chopped character.
Maybe you did something like:

$var = chop $var;

or

$var = chomp $var;

which is most likely not what you want.

# perldoc perlvar
# perldoc -f chomp
# perldoc -f chop

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.       | you come to the end; then stop.
NSW, Australia                      | 


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

Date: 13 Nov 1998 03:41:18 GMT
From: ehagen@Hawaii.Edu (Eric Hagen)
Subject: Re: Security - How to circumvent it.
Message-Id: <72g9ou$3u3@news.Hawaii.Edu>

If I remember off of the top of my head, I got this to work with setting
the path to a very limited path.  Using ksh I set it like this.

export PATH=/bin

The key here then becomes one of making sure that all commands used by
your script have complete paths in them.  I don't run any perl scripts as
root in this manner, but perl reacts the same to all set user id scripts.
I use it to run commands designed to run as a set user like oracle etc as
any individual.

Hope this helps.  Because it took me a while from digging through the docs
to figure out, it is there, just not spelled out clearly with big signs.

asitmain.tperry@email.state.ut.us wrote:
: I am trying to devise a script that will alow a user on my Y2K test
: system to reboot and set the date on that system.  I initally started
: to write this in shell and found that I could set the date and reboot
: the system vi a suid 4755 mode script.  However when I attempt this in
: perl I get many warning, errors, and aborts.  I have tried a C wrapper
: that executes the script where the suid bit is on the C, but I get the
: following message:

: Insecure $ENV{PATH} while running setuid at /ipl/ipl.pl line 14, <>
: chunk 1

: Although I understand that there is significant security risk with
: this script, let me make myself clear that I really don't care if the
: users have root password on this system, I was only hopeing not to
: have to give it to them in order to keep the less curious ones from
: biting their fingers off.  

: Could anyone give me an idea on how I can run this script with root
: permissions from a nonroot person without causing all of these
: security triggers to occure?  (I will recomplie perl again if that
: will help)

: Thanks in advance,

: Tim Perry
: asitmain.tperry@email.state.ut.us
: tperry@blinksoft.com

: <please respond via email as well as via usenet>

--
Eric Hagen                  "Sometimes we get lost in the darkness, 
ehagen@Hawaii.Edu	     the dreamers learn to steer by the stars..."
			    "You fight for something because it is good.
	 				Not because it stands to succeed."


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

Date: Thu, 12 Nov 1998 22:50:23 -0500
From: Bob Mariotti <bobm@cunix.com>
Subject: User pressing Esc or Stop after sending form...
Message-Id: <364BAC7F.8C74200D@cunix.com>

I have just scoured the FAQ's and several perl books for this
information and have come up with no direct answer.  We have a script
that reads from a file and generate HTML on the fly to the requesting
client.  Problem appears to be this:  While waiting for response user
presses Esc or simply clicks away elsewhere.  In the meantime my perl
script may be ending but the stdout buffer from the c i/o program it
just executed still have data in it.  How can one tell if the client
exited so the buffers can be cleared?  I researched the SIG handling but
could not locate a SIG received from a sitation like this.
Could someone PLEASE respond with a reasonable idea of how to handle
this???
Thanks in advance.


--
+-----------------------+---------------------------+
+ Bob Mariotti          + Financial DataCorp (FDC)  +
+ Executive V.P.        + Credit Union Specialists  +
+ email bobm@cunix.com  + 703 Hebron Avenue         +
+ (860) 657-8983 voice  + Glastonbury, CT 06033 USA +
+ (860) 657-8987 fax    + http://www.cunix.com      +
+---------------------------------------------------+




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

Date: Thu, 12 Nov 1998 22:52:45 -0600
From: Zhengdong Zhang <zzhang@bayou.uh.edu>
Subject: What's wrong with this perl program?
Message-Id: <364BBB1D.293A@bayou.uh.edu>

This is a multi-part message in MIME format.

--------------BC36C63E5C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I must apologize for my last post and any inconvenience it may has
caused. I didn't realize how big it was. I cut the attached files as
short as possible without losing the nature of my problem. I have some
DNA sequences (negative.gb3, attached) form different bacterium species
and I used GDE program to align these sequences and make a phylogenetic
tree (nega_tree, attached). Now I try to write a perl program to
rearrange the original sequence order to be the same as the order of the
bacterium species in the tree. My program (sort.perl, attached, run in
UNIX) can create the intermediate files (nega_list and join_flat.gb)
successfully but the final file (sort_flat.gb) is empty. I tried to find
what's wrong with it but couldn't figure it out. Please help me to find
the bug. Thanks.

--------------BC36C63E5C
Content-Type: text/plain; charset=us-ascii; name="nega_tree"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="nega_tree"


  10 Populations

Neighbor-Joining/UPGMA method version 3.57c


 UPGMA method

 Negative branch lengths allowed


  +----------A.XYLANU  
  !  
  !                        +E.COLI    
  !                     +--1  
  !                  +--2  +E.COLI2   
  !                  !  !  
  !               +--3  +E.COLI3   
--9               !  !  
  !            +--5  +E.COLI4   
  !            !  !  
  !         +--6  +SALMONEL  
  !         !  !  
  !    +----7  +E.COLI5   
  !    !    !  
  +----8    +ERWINIA   
       !  
       !    +ALT.COLW  
       +----4  
            +SH.HANED  



Between        And            Length
-------        ---            ------
   9          A.XYLANU          0.18197
   9             8              0.08155
   8             7              0.08142
   7             6              0.00329
   6             5              0.00700
   5             3              0.00148
   3             2              0.00073
   2             1              0.00220
   1          E.COLI            0.00430
   1          E.COLI2           0.00430
   2          E.COLI3           0.00650
   3          E.COLI4           0.00723
   5          SALMONEL          0.00871
   6          E.COLI5           0.01571
   7          ERWINIA           0.01900
   8             4              0.09172
   4          ALT.COLW          0.00870
   4          SH.HANED          0.00870



--------------BC36C63E5C
Content-Type: text/plain; charset=us-ascii; name="negative.gb3"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="negative.gb3"

#A.XYLANU(5)
CTTCGTGAC-AATAGCGAAGAG--GTCACAC-CTGT--TCCCATACCGAACACAGAA---
--GTCAAGCTCTTCAGCG-CCG-ATGGT-AGTTGGGGG-TTTT-CCCCCTGCGAG-AG-T
AGGACGTCGCTAAG
#E.COLI(3)
TGCCTGGCGGC-AGTAGCGCGGTG--GTCCCAC-CTGA--CCCCATGCCGAACTCAGAA-
----GTGAAACGCCGTAGCG-CCG-ATGGT-AGTGTGGGG--TCT-CCCCATGCGAG-AG
-TAGGGAACTGCCAGGCAT
#E.COLI2(3)
TGCCTGGCGGC-CGTAGCGCGGTG--GTCCCAC-CTGA--CCCCATGCCGAACTCAGAA-
----GTGAAACGCCGTAGCG-CCG-ATGGT-AGTGTGGGG--TCT-CCCCATGCGAG-AG
-TAGGGAACTGCCAGGCAT
#E.COLI3(3)
TGCCTGGCGGC-CGTAGCGCGGTG--GTCCCAC-CTGA--CCCCATGCCGAACTCAGAA-
----GTGAAACGCCGTAGCG-CCG-ATGGT-AGTGTGGGG--TCT-CCTCATGCGAG-AG
-TAGGGAACTGCCAGGCAT
#E.COLI4(3)
TGCCTGGCGGC-CTTAGCGCGGTG--GTCCCAC-CTGA--CCCCATGCCGAACTCAGAA-
----GTGAAACGCCGTAGCG-CCG-ATGGT-AGTGTGGGG--TCT-CCCCATGCGAG-AG
-TAGGGAACTGCCAGGCAT
#E.COLI5(3)
TGTCTGGCGGC-CATAGCGCGGTG--GTCCCAC-CTGA--CCCCATGCCGAACTCAGAA-
----GTGAAACGCCGTAGCG-CCG-ATGGT-AGTGTGGGG--TCT-CCCCATGCGAG-AG
-TAGGGAACTGCCAGACAT
#ALT.COLW(3)
TGTCTGGAAAC-CATAGCATTGTG--GCACCAC-CTGA--TCCCATCCCGAACTCAGAA-
----GTGAAACGCAATTGCG-CCG-ATGGT-AGTGTGGGG--TCT-CCCCATGTGAG-AG
-TAGGTCATTTCCAGGCGC
#SH.HANED(3)
TGTCTGGAAAC-CATAGCATTGTG--GCCCCAC-CTGA--TCCCATCCCGAACTCAGAA-
----GTGAAACGCAATCGCG-CCG-ATGGT-AGTGTGGGG--TCT-CCCCATGTGAG-AG
-TAGGTCATTTCCAGGCGC
#ERWINIA(3)
TGCCTGGCGGT-GATAGCGCGGTG--GTCCCAC-CTGA--CCCCATGCCGAACTCAGAA-
----GTGAAACGCCGTAGCG-CCG-ATGGT-AGTGTGGGG--CCT-CCCCATGCGAG-AG
-TAGGGAACTGCCAGGCAT
#SALMONEL(3)
TGCCTGGCGGC-ACTAGCGCGGTG--GTCCCAC-CTGA--CCCCATGCCGAACTCAGAA-
----GTGAAACGCCGTAGCG-CCG-ATGGT-AGTGTGGGG--TCT-CCCCATGCGAG-AG
-TAGGGAACTGCCAGGCAT

--------------BC36C63E5C
Content-Type: text/plain; charset=us-ascii; name="sort.perl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="sort.perl"

#! /usr/bin/perl -w


open (FILE, "nega_tree") || die "can not open nega_tree for reading: $!";
open (LIST, ">nega_list") || die "can not create the file: $!";

for ($i = 0; <FILE>;)
{
   
   if (/!|\+/)
   {
      s/[^A-Z]*//i;
      print LIST;
      $i++ if ($_ ne "");
   }   
}

print LIST "Total: $i\n";

close (LIST);
close (FILE);

open (FLAT, "negative.gb3");
open (JOIN_FLAT, ">join_flat.gb");
foreach (<FLAT>)
{
   s/\n//;
   s/#|%/\n#/;
#   s/\)/\)\n/;
   print JOIN_FLAT;
}   
close (JOIN_FLAT);
close (FLAT);

open (LIST1,"nega_list") || die "can not open: $! ";
open (SORT_FLAT, ">sort_flat.gb") || die "can't open for writing: $!";
while (defined($name = <LIST1>))
{
   chomp ($name);
   open (FLAT1, "join_flat.gb");
   while (defined($line = <FLAT1>))
   {
      if ($line =~ m/\Q$name\E/si)
      {
         print SORT_FLAT $line;
         last;         
      }
   }
   close (FLAT1);
}

close (LIST1);
close (FLAT1);
close (SORT_FLAT);


--------------BC36C63E5C--



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

Date: Fri, 13 Nov 1998 05:55:29 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: What's wrong with this perl program?
Message-Id: <lRP22.80$q%.262@nsw.nnrp.telstra.net>

In article <364BBB1D.293A@bayou.uh.edu>,
	Zhengdong Zhang <zzhang@bayou.uh.edu> writes:
> This is a multi-part message in MIME format.

Please, don't do this. It's all plain text, no need to make multipart
crappy MIME stuff.

> successfully but the final file (sort_flat.gb) is empty. I tried to find
> what's wrong with it but couldn't figure it out. Please help me to find
> the bug. Thanks.

You never have a match.

Check the contents of the produced nega_list file. You'll find that
you have spaces behind your names. Make sure you get rid of those.

Some other comments:

You don't always check the return value of an open.
You don't use strict.
You leave FLAT1 open if you find a match. It's neater to close it.
You reopen and reread join_flat.gb every time. It may be more
efficient to store it in a hash in memory, or maybe even on disk as a
dbm file.
You don't need the s or i flag on the last regexp match.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 
Commercial Dynamics Pty. Ltd.       | What's another word for Thesaurus?
NSW, Australia                      | 


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

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

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