[16702] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4114 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 24 00:10:44 2000

Date: Wed, 23 Aug 2000 21:10:20 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967090220-v9-i4114@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 23 Aug 2000     Volume: 9 Number: 4114

Today's topics:
    Re: Lotsa difiiculties - need help with my Perl !! (Keith Calvert Ivey)
    Re: lwp post method (Keith Calvert Ivey)
        MIME Mail help on NT - no sendmail! <tracyterrell@entersysgroup.com>
    Re: MIME Mail help on NT - no sendmail! <wyzelli@yahoo.com>
    Re: MIME Mail help on NT - no sendmail! <tracyterrell@entersysgroup.com>
    Re: mnemonics for //m, //s (was: Re: negative lookahead (brian d foy)
    Re: mnemonics for //m, //s (was: Re: negative lookahead (Neil Kandalgaonkar)
        mysterious error, posibly regarding return or else drdementor@my-deja.com
    Re: mysterious error, posibly regarding return or else <wyzelli@yahoo.com>
    Re: Newbie - Escaping special chars in forms <tina@streetmail.com>
    Re: OT: Re: Programming Ethics (Martien Verbruggen)
    Re: perl modem dialing script <zgsmz@my-deja.com>
    Re: Perl vs. other scripting languages (Abigail)
    Re: PLEASE HELP !!! What is wrong with Windows... (Keith Calvert Ivey)
    Re: Self-Answering Questions (Was Re: Flipflop matching <uri@sysarch.com>
    Re: Self-Answering Questions (Was Re: Flipflop matching (Martien Verbruggen)
    Re: Self-Answering Questions (Was Re: Flipflop matching (Keith Calvert Ivey)
    Re: Set @ARGV and ignore STDIN? (Keith Calvert Ivey)
        simple script debug - problem found (Kevin)
        simple script debug (Kevin)
    Re: simple script debug <taboo@comcen.com.au>
    Re: TextAreas and Security <j-e-b@swbell.net>
    Re: TextAreas and Security <mischief@motion.thispartfake.net>
    Re: To push or not to push (Keith Calvert Ivey)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Aug 2000 00:50:52 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Lotsa difiiculties - need help with my Perl !!
Message-Id: <39a67026.2772330@news.newsguy.com>

"Chris Stith" <mischief@motion.net> wrote:

>$foo = 0;
>while(<F>) {
>     $file[$foo] = $_;
>     $foo++;
>}
>
>which is pretty standard Perl.

Perl that is being ridiculed in another thread as we speak.
Why do you need $foo when you can just do this?

    while (<F>) {
        push @file, $_;
    }

And of course the real "standard Perl" way would be

    my @file = <F>;

or just losing the array entirely and reading and processing a
chunk at a time instead, depending on the exact application.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 24 Aug 2000 02:23:04 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: lwp post method
Message-Id: <39aa8549.8183760@news.newsguy.com>

matt@NOSPAMcipherdesign.com wrote:

>it would really clarify things if someone could tell me whats wrong
>with the following code. it just fetches the search page, it doesnt
>actually search...

It doesn't even do that for me -- it gives an error.  I suspect
it's because AltaVista isn't set up to respond to POST requests.
The search forms use GET.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 24 Aug 2000 02:20:05 GMT
From: "Tracy Terrell" <tracyterrell@entersysgroup.com>
Subject: MIME Mail help on NT - no sendmail!
Message-Id: <pD%o5.14250$C5.180407@typhoon.austin.rr.com>

Hey folks, here is an easy one (I bet) ...

I am trying to use MIME-Tools and MailTools to send mail w/ attachment from
an NT machine (Perl - ActiveState 5.6).  I am starting by trying to get the
example code from MIME::Entity to work, but as you can see it uses sendmail
to actually send the mail.  Can someone help me understand what I need to do
differently to send this MIME Entity using functionality offered by the
MailTools module (which I think ultimately uses
Net::SMTP)?

Thanks for your time!
Tracy


use MIME::Entity;

$top = build MIME::Entity Type    =>"text/plain",
                          From    => "me@domain.com",
                          To      => "you@domain.com",
                          Subject => "Test Mime";

attach $top  Path=>"./short.txt";


# I'm looking for a "MailTools" replacement for this block.....
open MAIL, "| /usr/lib/sendmail -t -i" or die "open: $!";
$top->print(\*MAIL);
close MAIL;








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

Date: Thu, 24 Aug 2000 11:57:08 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: MIME Mail help on NT - no sendmail!
Message-Id: <mL%o5.12$r73.2181@vic.nntp.telstra.net>

"Tracy Terrell" <tracyterrell@entersysgroup.com> wrote in message
news:pD%o5.14250$C5.180407@typhoon.austin.rr.com...
> Hey folks, here is an easy one (I bet) ...
>
> # I'm looking for a "MailTools" replacement for this block.....
> open MAIL, "| /usr/lib/sendmail -t -i" or die "open: $!";
> $top->print(\*MAIL);
> close MAIL;

Install one of the windows ports of sendmail?

Wyzelli




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

Date: Thu, 24 Aug 2000 02:39:17 GMT
From: "Tracy Terrell" <tracyterrell@entersysgroup.com>
Subject: Re: MIME Mail help on NT - no sendmail!
Message-Id: <pV%o5.14273$C5.183959@typhoon.austin.rr.com>

> > Hey folks, here is an easy one (I bet) ...
> >
> > # I'm looking for a "MailTools" replacement for this block.....
> > open MAIL, "| /usr/lib/sendmail -t -i" or die "open: $!";
> > $top->print(\*MAIL);
> > close MAIL;
>
> Install one of the windows ports of sendmail?
>
> Wyzelli
>

Well, I'm sure that would work, but I'm already using MailTools to send "no
attachment" emails in other scripts and would like to stick to one mechanism
for sending mail (to the degree that it still makes sense...) - if for no
other reason than to keep overall maintenance straightforward.  Thanks for
the suggesstion.

T




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

Date: Wed, 23 Aug 2000 21:10:38 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: mnemonics for //m, //s (was: Re: negative lookahead assertions in Perl Regex)
Message-Id: <brian-ya02408000R2308002110380001@news.panix.com>

In article <8o1f1s$b22$1@localhost.localdomain>, neil@brevity.org (Neil Kandalgaonkar) posted:

> In article <MPG.140dad7779d321e198acc9@nntp.hpl.hp.com>,
> Larry Rosler  <lr@hpl.hp.com> wrote:
 
> >The Perl dcumentation provides mnemonics, in two places.

> >perlop:
> >    m   Treat string as multiple lines.
> >    s   Treat string as single line.

> Those don't work for me, and apparently not for most people.

i don't know your definition of most, but this is the first
time i've heard that it doesn't work.  i teach this stuff
to a lot of people, too ;)

but then, what works for you might not work for someone else.
you can't please everyone.

> When people want to match something that spans multiple lines,
> they automatically think of "m" precisely because of that entry
> in perlop. 

> But "m" actually breaks a multi-line string into individual lines,
> with regards to what ^ and $ do.

it doesn't do anything except affect how anchors match.  anchors match
as if there were multiple lines in the string, thus, a "multi-line
string".

s allows the . (dot) to match newlines so that constructs like

   m/.*/

can match a string with embedded newlines, just as if the string
were one line.

> Worse, that mnemonic suggests that //m and //s are mutually
> exclusive, and they aren't!

mnemonics are, after all, just aids to memory.  you should 
remember what they actually do based on the mnenomic rather
than expecting the mnenomic to be the definitive statement
on the matter.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Thu, 24 Aug 2000 02:00:47 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: mnemonics for //m, //s (was: Re: negative lookahead assertions in Perl Regex)
Message-Id: <8o1v6k$b6l$1@localhost.localdomain>

In article <brian-ya02408000R2308002110380001@news.panix.com>,
brian d foy <brian@smithrenaud.com> wrote:
>In article <8o1f1s$b22$1@localhost.localdomain>, neil@brevity.org (Neil Kandalgaonkar) posted:

>> Those don't work for me, and apparently not for most people.
>
>i don't know your definition of most, but this is the first
>time i've heard that it doesn't work.  i teach this stuff
>to a lot of people, too ;)

I'll bow to vastly superior experience, but I had the sense (dunno from
where) that this is just well known as one of the things that trips
people up a lot. Maybe it's all in my head. 

>mnemonics are, after all, just aids to memory.  you should 
>remember what they actually do based on the mnenomic rather
>than expecting the mnenomic to be the definitive statement
>on the matter.

Of course.

Silly mnemonic:

/s -- affects .        -- a dot is like a Spot
/m -- affects ^ and $  -- the symbols for Masonry and Money.  :)  



-- 
Neil Kandalgaonkar <neil@brevity.org>


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

Date: Thu, 24 Aug 2000 03:00:57 GMT
From: drdementor@my-deja.com
Subject: mysterious error, posibly regarding return or else
Message-Id: <8o2350$7je$1@nnrp1.deja.com>

syntax error at validateemail.pm line 29, near "return"
syntax error at validateemail.pm line 35, near "else"

last 2 errors should be ignored i think, this pavkage ran ok before...
BEGIN failed--compilation aborted at processmail.pm line 4.
BEGIN failed--compilation aborted at processmail.cgi line 3.


this is the file im gettint the error in....
################ start of file
package validateemail;
use strict;


my $error_type = 0;

sub new
{
 my $class = shift;
 my $self = {};
 bless($self,$class);
 return $self;
}

sub kernel
{#start of sub
    my $email = $_[1];
    print"<br><br>this is the address that its checking...";
    print $email;
    print"<br><br>";

    if ($email =~ m/[A-Za-z]\w{2,62}@[A-Za-z\-]{2,61}[A-Za-z]\.[A-Za-z]
{2,3}/)
    {#start of valid syntax block
     print" valid email address syntatically ...<br>";


     # @@@@@@ when I remove this code it works
     # I originally had a more meaningful if statement, >>>>>>>
     # i simplified it to try to diagnose the problem
     # code is so simple now i dont know why it wont work.
     If($error_type == 0)
     {
      print "test123"; # line 29
      return 0;
     }
     # @@@@@@ end of code that when removed program works >>>>


     return 1;
    }#end of valid syntax block #35
    else
    {
     return 0;
    }
}#end of sub

sub get_error_type
{
 return $error_type;
}

return 1;

###################### end of file


i dont know why it wont work.
in perl can you have a return statement at any time and break out of
the method sub or function, what ever you want to call it...
does this return method work like in c ++?
maybe its just stupid syntax, either way im stumped...

thanks

JIm


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 24 Aug 2000 13:06:48 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: mysterious error, posibly regarding return or else
Message-Id: <tL0p5.34$r73.2554@vic.nntp.telstra.net>

>
>      # @@@@@@ when I remove this code it works
>      # I originally had a more meaningful if statement, >>>>>>>
>      # i simplified it to try to diagnose the problem
>      # code is so simple now i dont know why it wont work.
>      If($error_type == 0)
>      {
>       print "test123"; # line 29
>       return 0;
>      }

Start with a lower case for the i in If?

Wyzelli




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

Date: 24 Aug 2000 01:43:57 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Newbie - Escaping special chars in forms
Message-Id: <8o1ukt$9r2k3$2@ID-24002.news.cis.dfn.de>

hi,
scottfreez@my-deja.com wrote:

> In ASP I use server.urlEncode to encode special characters.

> Does anyone know a similar function in Perl? I'm creating a form on the
> fly and submitting it to another page. Problems are arising when there
> are "&" characters in the form.

use
$value = CGI::escape($value);

(not documented)

tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Thu, 24 Aug 2000 01:55:15 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: OT: Re: Programming Ethics
Message-Id: <slrn8q903c.ma.mgjv@verbruggen.comdyn.com.au>

On Wed, 23 Aug 2000 19:39:33 GMT,
	Tim Hammerquist <tim@degree.ath.cx> wrote:
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> 
> > Most products originating in Redmond are
> > wrong.
> 
> What's with this "Most" business?  =)

Redmond must have more than one company, right? And even the largest
company there has acquired products recently enough not to have been
able to screw them up yet. :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | This matter is best disposed of from
Commercial Dynamics Pty. Ltd.   | a great height, over water.
NSW, Australia                  | 


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

Date: Thu, 24 Aug 2000 02:37:13 GMT
From: ivan <zgsmz@my-deja.com>
Subject: Re: perl modem dialing script
Message-Id: <8o21on$66s$1@nnrp1.deja.com>

searching deja for termios* wrt this problem yielded this golden advice
(from the faq?), which should allow me to tweak my code and win!:

require Perl POSIX module, read the tcsetattr docs for proper use.

if I actually get this code to work, I will post the script.
-ivan


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 24 Aug 2000 03:21:23 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Perl vs. other scripting languages
Message-Id: <slrn8q9548.tj3.abigail@alexandra.foad.org>

KN (khayyam.noon@unisys.com) wrote on MMDXLIX September MCMXCIII in
<URL:news:8o1dql$8d7$1@trsvr.tr.unisys.com>:
][ What are the pros and cons of using Perl versus other scripting languages?

Pros:  Having dinner with Perl Mongers.
       Camels can go weeks without water.
           (But Pythons can go weeks without food)
       Luke warm balls.
       It looks like line noise - even your cat can program!
       Damian Conway.
       Perl Golf.
       Cute babes.
       JAPHs.
       Cheap puns.


Cons:  Having dinner with Perl Mongers.
       There are no fun anagrams of "Larry Wall".
       Godzilla.
       People claim you can program OO in Perl.
       Slashdot.
       Each new version of Perl will break half of your programs.
       Perl is hard for most people to write. They write PERL or Pearl.




Abigail
-- 
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;
sub   _   {push         @_ => /::(.*)/s and goto &{ shift}}
sub shift {print shift; @_              and goto &{+shift}}
Hack ("Just", "Perl ", " ano", "er\n", "ther "); # 20000723


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

Date: Thu, 24 Aug 2000 02:49:32 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: PLEASE HELP !!! What is wrong with Windows...
Message-Id: <39ad8c3e.9964627@news.newsguy.com>

dowe@krikkit.localdomain (Dowe Keller) wrote:
>comet999 <comet999@my-deja.com> wrote:

>>%cats = &readdatabase("h:\data\cats");
>
>Make that:
>
>%cats = &readdatabase("h:\\data\\cats");
>
>Perl was looking for:
>h:datacats which probably isn't what you wanted.

It's worse than that, since "c" after a backslash is special
(see perlop, under "Quote and Quote-like Operators").  The "\ca"
is control-A, or chr(1), or "\x01", or "\001", or however you
want to write it, not just "ca".

The best answer is probably to use regular slashes instead of
backslashes.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 24 Aug 2000 01:13:04 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Self-Answering Questions (Was Re: Flipflop matching)
Message-Id: <x7wvh7sbq7.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> Oh, that's much too easy.  But I've got some time to waste.

you have too much of that!

:)

that list just shows you larry (the wall's) linguistic background. and it
highlights the interesting split of perl into line noise and well chosen
english words.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Thu, 24 Aug 2000 02:02:20 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Self-Answering Questions (Was Re: Flipflop matching)
Message-Id: <slrn8q90gl.ma.mgjv@verbruggen.comdyn.com.au>

On Wed, 23 Aug 2000 17:41:37 -0700,
	Larry Rosler <lr@hpl.hp.com> wrote:
> In article <39A458EF.6F4840C2@vpservices.com> on Wed, 23 Aug 2000 
> 16:06:23 -0700, Jeff Zucker <jeff@vpservices.com> says...
> > 
> > how do I make my variables local to a subroutine?
                  ^^           ^^^^^
> 
> Careful -- that can produce the less-than-best answer!  :-)

It actually gives both alternatives, with the (generally) preferred
one first.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's not a lie, it's a
Commercial Dynamics Pty. Ltd.   | terminological inexactitude.
NSW, Australia                  | 


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

Date: Thu, 24 Aug 2000 01:26:40 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Self-Answering Questions (Was Re: Flipflop matching)
Message-Id: <39a8784c.4858276@news.newsguy.com>

Jeff Zucker <jeff@vpservices.com> wrote:

>how do I split a string into parts?

It seems to me that most of the people who ask that question in
this newsgroup are trying to use split() when they should be
using substr(), unpack(), or a regex with capturing parentheses.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 24 Aug 2000 01:41:16 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Set @ARGV and ignore STDIN?
Message-Id: <39a97b14.5570794@news.newsguy.com>

philip.hibbs@tnt.co.uk wrote:

>#!/usr/bin/perl
>
>use Text::Wrap;
>
># @files = sort {-M $a <=> -M $b} <*.txt>; # sort files by age
># $file = shift @files;                   # get the first (newest)
># undef @files;                          # free up memory
># @ARGV = ($file);                      # set list of files to process
># print @ARGV;
>
>$match = shift;

@ARGV is now empty, because you've shifted off its only element.
That's why the loop below reads from STDIN (and the regex
matches against the file name you determined above, if the lines
are uncommented).

>while (<>) {
>    chomp;
>    print "\r".$_ if m/[0-9]{4}/i;
>    print wrap("\n "," ",$_)."\n" if m/$match/i;
>}

It wouldn't necessarily have helped in this particular case, 
but you should get into the habit of using -w and strict (as
recommended every day in this group).  They'll help you find
mistakes in your code.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 24 Aug 2000 02:14:46 GMT
From: REMOVEMEmelonmisc@iname.com (Kevin)
Subject: simple script debug - problem found
Message-Id: <39a484e9.10353751@news.ozemail.com.au>

thanks all, but it was an xtra curly bracket, thanks in anycase

Kevin

------

hi all

when i run the following script, i get the output returned, but it
first says the headers that are returned are incorrect, it is a very
simple redirection script, any hlep to this perl newbie would be
greatly appreciated

regards

kev

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


#!/usr/local/bin/perl
# Read in form data
  %Clients = (
John => 'pass1',
peter => 'pass2',
Carmen => 'pass3',
test_site => 'pass4');

  &parse_form;

  $clientid = $input{'clientid'};
  $password =  $input{'password'};
  $function = $input{'function'};
  $CorrectPass = $Clients{$clientid};

   if ($function eq "post") {
       if ($CorrectPass eq $password) {
    print "Content-type: text/html\n\n";
    print "<html>\n";

    print "<HEAD>\n";
    print "<TITLE>Logging in</Title>\n";
    print "<META HTTP-EQUIV=\"Refresh\"
content=\"1;URL=http://xyc.com/cgi-bin/abc.pl?site=$clientid\">\n";
    print "</HEAD>\n";
    print "<BODY>\n";
    print "</BODY>\n";
    print "</HTML>\n";
	}

	}
       else {
    print "Content-type: text/html\n\n";
    print "<HTML>\n";
    print "<HEAD><TITLE>Invalid Password</Title></HEAD>\n";
    print "<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF
VLINK=#800040 ALINK=#800040>\n";
    print "<CENTER><H2>Invalid login information</H2></CENTER><BR>\n";
    print "$clientid - $password";
    print "</BODY>\n";
    print "</HTML>\n";
	};
   };


sub badpassword {
    print "Content-type: text/html\n\n";
    print "<HTML>\n";
    print "<HEAD><TITLE>Invalid Password</Title></HEAD>\n";
    print "<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF
VLINK=#800040 ALINK=#800040>\n";
    print "<CENTER><H2>Invalid Password</H2></CENTER><BR>\n";
    print "</BODY>\n";
    print "</HTML>\n";
    exit;
}

sub goto_url {

    print "Location: http://$_[0].html\n\n";
}

sub parse_form {

   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
   if (length($buffer) < 5) {
         $buffer = $ENV{QUERY_STRING};
    }
   @pairs = split(/&/, $buffer);
   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);

      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

      $input{$name} = $value;
   }
}




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

Date: Thu, 24 Aug 2000 01:44:39 GMT
From: REMOVEMEmelonmisc@iname.com (Kevin)
Subject: simple script debug
Message-Id: <39a47d93.8475773@news.ozemail.com.au>

hi all

when i run the following script, i get the output returned, but it
first says the headers that are returned are incorrect, it is a very
simple redirection script, any hlep to this perl newbie would be
greatly appreciated

regards

kev

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


#!/usr/local/bin/perl
# Read in form data
  %Clients = (
John => 'pass1',
peter => 'pass2',
Carmen => 'pass3',
test_site => 'pass4');

  &parse_form;

  $clientid = $input{'clientid'};
  $password =  $input{'password'};
  $function = $input{'function'};
  $CorrectPass = $Clients{$clientid};

   if ($function eq "post") {
       if ($CorrectPass eq $password) {
    print "Content-type: text/html\n\n";
    print "<html>\n";

    print "<HEAD>\n";
    print "<TITLE>Logging in</Title>\n";
    print "<META HTTP-EQUIV=\"Refresh\"
content=\"1;URL=http://xyc.com/cgi-bin/abc.pl?site=$clientid\">\n";
    print "</HEAD>\n";
    print "<BODY>\n";
    print "</BODY>\n";
    print "</HTML>\n";
	}

	}
       else {
    print "Content-type: text/html\n\n";
    print "<HTML>\n";
    print "<HEAD><TITLE>Invalid Password</Title></HEAD>\n";
    print "<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF
VLINK=#800040 ALINK=#800040>\n";
    print "<CENTER><H2>Invalid login information</H2></CENTER><BR>\n";
    print "$clientid - $password";
    print "</BODY>\n";
    print "</HTML>\n";
	};
   };


sub badpassword {
    print "Content-type: text/html\n\n";
    print "<HTML>\n";
    print "<HEAD><TITLE>Invalid Password</Title></HEAD>\n";
    print "<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF
VLINK=#800040 ALINK=#800040>\n";
    print "<CENTER><H2>Invalid Password</H2></CENTER><BR>\n";
    print "</BODY>\n";
    print "</HTML>\n";
    exit;
}

sub goto_url {

    print "Location: http://$_[0].html\n\n";
}

sub parse_form {

   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
   if (length($buffer) < 5) {
         $buffer = $ENV{QUERY_STRING};
    }
   @pairs = split(/&/, $buffer);
   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);

      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

      $input{$name} = $value;
   }
}




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

Date: 24 Aug 2000 00:45:27 +1000
From: "Kiel Stirling" <taboo@comcen.com.au>
Subject: Re: simple script debug
Message-Id: <39a3e387$1_3@nexus.comcen.com.au>


REMOVEMEmelonmisc@iname.com (Kevin) wrote:
>hi all>
>when i run the following script, i get the output returned, but it
>first says the headers that are returned are incorrect, it is a very
>simple redirection script, any hlep to this perl newbie would be
>greatly appreciated
>
>regards
>
>kev
>
>-------------
>
>
>#!/usr/local/bin/perl
># Read in form data
>  %Clients = (
>John => 'pass1',
>peter => 'pass2',
>Carmen => 'pass3',
>test_site => 'pass4');
>
>  &parse_form;
>
>  $clientid = $input{'clientid'};
>  $password =  $input{'password'};
>  $function = $input{'function'};
>  $CorrectPass = $Clients{$clientid};
>
>   if ($function eq "post") {
>       if ($CorrectPass eq $password) {
>    print "Content-type: text/html\n\n";
>    print "<html>\n";
>
>    print "<HEAD>\n";
>    print "<TITLE>Logging in</Title>\n";
>    print "<META HTTP-EQUIV=\"Refresh\"
>content=\"1;URL=http://xyc.com/cgi-bin/abc.pl?site=$clientid\">\n";
>    print "</HEAD>\n";
>    print "<BODY>\n";
>    print "</BODY>\n";
>    print "</HTML>\n";
>	}
>
>	}
>       else {
>    print "Content-type: text/html\n\n";
>    print "<HTML>\n";
>    print "<HEAD><TITLE>Invalid Password</Title></HEAD>\n";
>    print "<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF
>VLINK=#800040 ALINK=#800040>\n";
>    print "<CENTER><H2>Invalid login information</H2></CENTER><BR>\n";
>    print "$clientid - $password";
>    print "</BODY>\n";
>    print "</HTML>\n";
>	};
>   };
>
>
>sub badpassword {
>    print "Content-type: text/html\n\n";
>    print "<HTML>\n";
>    print "<HEAD><TITLE>Invalid Password</Title></HEAD>\n";
>    print "<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF
>VLINK=#800040 ALINK=#800040>\n";
>    print "<CENTER><H2>Invalid Password</H2></CENTER><BR>\n";
>    print "</BODY>\n";
>    print "</HTML>\n";
>    exit;
>}
>
>sub goto_url {
>
>    print "Location: http://$_[0].html\n\n";
>}
>
>sub parse_form {
>
>   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>   if (length($buffer) < 5) {
>         $buffer = $ENV{QUERY_STRING};
>    }
>   @pairs = split(/&/, $buffer);
>   foreach $pair (@pairs) {
>      ($name, $value) = split(/=/, $pair);
>
>      $value =~ tr/+/ /;
>      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>
>      $input{$name} = $value;
>   }
>}
>

I am thinking that your script is printing a Content-type then 
the Location header 
ie,
Content-type: text/html

Location: http://$_[0].html 

I think this would generate your error.
Also maybe read perldoc CGI for a more efficient way to generate
HTML.

-Kiel.


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

Date: Wed, 23 Aug 2000 20:12:12 -0500
From: Eric Benson <j-e-b@swbell.net>
Subject: Re: TextAreas and Security
Message-Id: <39A4766C.CEC25067@swbell.net>

Thank you, kind sir.

Albert Dewey wrote:
> 
> $CGI::POST_MAX=1024 * 450;
> 
> This will limit the max size that Perl will process in a single form
> submission to 450K in size. Adjust the number to suit your needs.
> 
> Albert Dewey
> 
> Eric Benson wrote:
> 
> > I have a Perl book that has the following quotes:
> >
> > "...it would be relatively simple for a visitor...to crank up a file
> > transfer and dump a few megabytes of garbage (into a Text of TextArea
> > input field)."
> >
> > The book goes on to say that this could crash my web server.  Or, at the
> > least, it would hog disk space, and my Perl program would email all of
> > this garbage to the address of whoever the perpetrator entered in the
> > email address field.
> >
> > Of course, the Text tag in HTML has a MAXLENGTH attribute which will
> > prevent this.  However, the TextArea tag does not have a MAXLENGH
> > attribute.  About this, the book I have says:
> >
> > "You'll fall back on a second line of defense for (preventing transfer
> > of huge amounts of data via a TextArea field): the Perl-CGI script
> > itself."
> >
> > Here's the good part - the book NEVER says anything further about this
> > subject.  It does not show how to use Perl to prevent this.  I have
> > searched numerous FAQs and this newsgroup, and could find nothing on the
> > subject.
> >
> > My questions are:
> >
> > 1) Is this true?  Could someone send a large file to my Perl script via
> > a Text or TextArea field?
> >
> > 2) I currently have a routine to check for any characters that could be
> > used to enter system commands or HTML code into a Text or TextArea field
> > (i.e., [;<>%\*`|]).  The code is:
> >
> >         for($n = 0; @in[$n]; $n++)
> >         {
> >                 ($dummy, $temp) = split(/=/, @in[$n]);
> >                 $temp =~ tr/+/ /;
> >                 $temp=~ s/%([\ dA-Fa-f][\ dA-Fa-f])/
> >                 pack ("C", hex ($1))/eg;
> >                 if ($temp =~ /[;<>%\*`|]/)
> >                 {
> >                   #The error message goes here.
> >                 }
> >
> >                 @in[$n] = $temp;
> >         }
> >
> > If the answer to 1) above is "yes", will this prevent that from being
> > done with a TextArea field?
> >
> > 3) If the above code would not secure against an action like this, how
> > can it be prevented and/or dealt with?
> >
> > Thanks,
> >
> > Eric Benson
> > --
> > Be just...fear not.

-- 
Be just...fear not.


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

Date: Wed, 23 Aug 2000 21:04:41 -0500
From: "Chris Stith" <mischief@motion.thispartfake.net>
Subject: Re: TextAreas and Security
Message-Id: <sq90lm3rt91119@corp.supernews.com>


"Eric Benson" <j-e-b@swbell.net> wrote in message
news:39A4766C.CEC25067@swbell.net...
> Thank you, kind sir.
>
> Albert Dewey wrote:
> >
> > $CGI::POST_MAX=1024 * 450;
> >
> > This will limit the max size that Perl will process in a single form
> > submission to 450K in size. Adjust the number to suit your needs.
> >
> > Albert Dewey

Or, if you want something procedural that checks the
size of an individual textarea for when (if) you do a small
script not worth the overhead of a module, you could try this:

if( len( $FORM{datafromtextarea} )   > $size_limit ) {
     print_error_message_page();
}

assuming, of course, that the variables are proper for your
particular implementation.

I'm aware this probably isn't what the OP particularly
needed at the moment, since he already thanked the
previous poster. It does give an option for those who do
'dirty little tools'.

Mr. Mischief (Chris Stith) mr_mischief1@hotmail.com
Motion Internet  mischief@motion.net
"If Microsoft cared, I mean really, truly cared where you
wanted to go today, they wouldn't make products that
crash halfway there" -- Mr. Stryfe (aka Joey Calvey)




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

Date: Thu, 24 Aug 2000 01:19:30 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: To push or not to push
Message-Id: <39a7776f.4636802@news.newsguy.com>

Steven Merritt <smerr612@mailandnews.com> wrote:

>     if (/^\+>*/) {

That matches any line that starts with a plus sign followed by
zero or more greater-thans.  That is, the >* isn't doing
anything, since every plus sign is followed by at least zero
greater-thans.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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


------------------------------
End of Perl-Users Digest V9 Issue 4114
**************************************


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