[17107] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4519 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 4 14:05:39 2000

Date: Wed, 4 Oct 2000 11:05:12 -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: <970682712-v9-i4519@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 4 Oct 2000     Volume: 9 Number: 4519

Today's topics:
    Re: converting \codes (Gary E. Ansok)
    Re: Cookie problem ghorghor@my-deja.com
    Re: Cookie problem <anders@wall.alweb.dk>
        Deleting files older than n days dottiebrooks@my-deja.com
    Re: Deleting files older than n days stdenton@my-deja.com
    Re: Fork creates grandchildren? nobull@mail.com
        Help me get this code working mrstevejones@my-deja.com
        Help with CGI <dunfeeje@pilot.msu.edu>
    Re: help: FORCE perl to evaluate arithmetic string <godzilla@stomp.stomp.tokyo>
        https and lwp apacheproblems@my-deja.com
    Re: Limiting Form Field Input? xlr6drone@my-deja.com
    Re: Limiting Form Field Input? <jeff@vpservices.com>
    Re: Limiting Form Field Input? <jeff@vpservices.com>
    Re: Multiple TIEs on a hash? <bkennedy@hmsonline.com>
    Re: Need help with a Regular expression <anders@wall.alweb.dk>
    Re: Need help with a Regular expression <salvador@my-deja.com>
    Re: Need the best Perl Tutorial -- bar none (Jon S.)
        perl asynchronous modem on Solaris? <phil_xxx@my-deja.com>
        printing a postscript file directly joseph7971@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 4 Oct 2000 17:29:00 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: converting \codes
Message-Id: <8rfpcs$5nk@gap.cco.caltech.edu>

In article <8rdofs$865$1@samba.rahul.net>,
Lloyd Lim  <Lloyd_Lim@mail.limunltd.com> wrote:
>In article <MPG.144437d9d6b504f49897e5@localhost>,
>jason  <elephant@squirrelgroup.com> wrote:
>>Lloyd Lim wrote ..
>>>
>>>I'd like to be able to process \t, \n, \r, ..., \033, \x1B, \c[
>>>in a string and substitute the appropriate characters just like
>>>Perl does.  I'd also prefer avoiding eval, if possible.
>
>Yes, I just want to be safe because the input can be anything.
>After further thought, I came up with the following using eval:
>
>$str = quotemeta($str);
>$str =~ s/\\\\(?=[tnrfae01xc])/\\/g;
>$str = eval("qq($str)");
>
>I think this should be safe, but you never know what someone will
>come up with.  Can anyone think of any obvious holes?

With the substitution as you have it now, strings like \\t and \\\t
will not be processed correctly.

However, when I tried a couple of quick solutions (like adding \\ to
the character class or adding |\\\\ after it), I opened up the 
possibility of unmatched right parentheses (with varying numbers of
backslashes, depending on what I was trying) ending the qq() string 
prematurely, and I was not able to come up with a complete solution.

-- Gary Ansok


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

Date: Wed, 04 Oct 2000 14:59:04 GMT
From: ghorghor@my-deja.com
Subject: Re: Cookie problem
Message-Id: <8rfgji$9j$1@nnrp1.deja.com>

In article <eEGC5.425$u23.36301@news000.worldonline.dk>,
  Anders Lund <anders@wall.alweb.dk> wrote:
> ghorghor@my-deja.com wrote:
>
> > In article <smFC5.940$UW.31081@news010.worldonline.dk>,
> >   Anders Lund <anders@wall.alweb.dk> wrote:
> > > ghorghor@my-deja.com wrote:
> > >
> > > > Can someone help me please
> > >
> > > You, by reading documentation.
> > > The CGI module comes with excellent documentation.
> > > Perl comes with excellent documentation.
> > >
> > > perldoc CGI, then search for cookie...
>
> >
> > i know that
> > the exemple come to the perldoc CGI::Cookie
> > but even the exemple doesn't work so ...
>
> Oh yes I see that. Then you have to figure out why not. First, why
not try
> dumipng your result,
>
> $cookies = fetch CGI::Cookie;
> foreach (keys %$cookies) {
>      print "$_: value: ", $cookies->{$_}->value,
>                 " name: ", $cookies->{$_}->name, "<br>";
> }
>
> and see if anything is present.
> If nothing is printed, your server didn't get any cookies back, and
you
> need to find out why. Maybe cookies is turned of in the client
browser,
> maybe you did something wrong. Running the program from the terminal
(DOS
> prompt in your case??) allows you to see the output, including the
HTTP
> headers.
>
> > and there isn't written anywhere that CGI::Cookie supporte IE so i m
> > not sure to use some that doesn't work with IE :)
>
> Sure. Cookies is a part of the HTTP 1.1 specs, and eventhough MS does
their
> best to polute any standard when they can, they dosen't do it if it
is too
> obvious a drawback for their users...
>
> -anders
> --
> [ the word wall - and the trailing dot - in my email address
> is my _fire_wall - protecting me from the criminals abusing usenet]
>
thx to answer me,
i have tried a lot of things and that didn't help me
after i found an exemple that works that is the code :

use strict;
use CGI qw/:standard/;
use CGI::Carp qw/fatalsToBrowser/;
use CGI::Cookie;

# Define all variables "with use vars" #

use vars qw(
	$scriptname $version $ver_date $authors	$company
	$address1 $city $state $zipcode
	$phone $email $main_page $copy $design
	$c $r1 $r2 $b1 $b2 $c1 $c2 $rc
	$title $header
	$query
	$your_cookie
	%get_cookies
	$new_cookie
	$retreived_cookie
	$current_time
);

$scriptname = "tcookie2.cgi";
$version	= "1.00.00";
$ver_date   = "06-08-00";
$authors	= "Dave Van Abel";
$company	= "Dave Van Abel";
$address1	= "2131 S. Allison Court";
$city		= "Lakewood";
$state		= "CO";
$zipcode	= "80227";
$phone		= "303-989-6481";
$email		= "dvanabel\@vanabel.com";
$main_page	= "<a href='http://www.vanabel.com' TARGET='_top'>Main
Page for vanabel.com</font></a>";
$copy 		= "<FONT size='2'>\&copy 2000, Dave Van Abel";
$design		= "<a href='http://vanabel.com/' TARGET='_top'>Design
by Dave Van Abel</font></a>";

$c = "<font color=red>*</font>";
$r1 = "<font color=red>";
$r2 = "</font>";
$b1 = "<font color=blue>";
$b2 = "</font>";
$c1 ="<center>";
$c2 ="</center>";

$title       = "Page 2 of Cookie Testing Script!";	#HTML TITLE
$header      = "Page 2 of Cookie Testing Script!";	#HTML HEADER

$query  = new CGI();

# Retreive Info for Cookie #

$new_cookie = $query->param('new_cookie');

# Retreive the Existing Cookie #

#%get_cookies = fetch CGI::Cookie;
	# retreive all cookies ??
#$retreived_cookie = $get_cookies{'dva'}->value;	# bad when none
existed!!
$retreived_cookie = cookie('dva');

if ($new_cookie eq "") {
	$new_cookie = localtime;
}
$your_cookie = new CGI::Cookie(
	-name=>'dva',
	-value=>$new_cookie,
	-expires=>'+30d'
);

print $query->header(-cookie=>$your_cookie);
print $query->start_html(
		-title=>$title,
		-bgcolor=>'white',
		-text=>'#000000'
		),

	# Header #

	"<CENTER><font color=blue><H3>$header</H3></font></CENTER>",

    "<P><CENTER><TABLE CELLPADDING=4 CELLSPACING=2 BORDER=1
bgcolor='#CfCfCf'>",

	# New Info #

	"<TR>",
	"<TD colspan='2' bgcolor='#FF2F2F' height=5'><STRONG>$c1 Cookie
Information</STRONG></TD>",
	"</TR>",

    "<TR>",
    "<TD>Your Previous Cookie was</TD>",
    "<TD>$r1 $retreived_cookie $r2</TD>",
    "</TR>",
    "<TR>",
    "<TD>Your New Cookie now is</TD>",
    "<TD> $r1 $new_cookie $r2</TD>",
    "</TR>",
    "</TABLE></CENTER><P>",

	"<p>",
	$c1,
	"$main_page<p>",
	"$copy<p>",
	$c2,
 	$query->end_html;

# End of Script #

and with this script i have understand my problem, in fact i must do my
cookie traitement before sending HTML code to the browser.

and it is a problem for me, but i think i ll do with :(

now i m looking how to close the query ( like in the exemple )
without using star_html ...

but i think it ll be quite easy

Thanks to have spent time to read me

and sorry for my bad english

Bye


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


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

Date: Wed, 4 Oct 2000 17:34:02 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Cookie problem
Message-Id: <J6IC5.1002$UW.34248@news010.worldonline.dk>

ghorghor@my-deja.com wrote:
> thx to answer me,
> i have tried a lot of things and that didn't help me
> after i found an exemple that works that is the code :
> 

Your'e wellcome..
I'll give a few comments on your code.

> use strict;
Good!
> use CGI qw/:standard/;
You don't seem to make use of any of the methods that you import into the 
namespace of oyur script here. after saying "use CGI qw(standard);", Iød 
expect you to do like

print header, starthtml,h1(Cool stuff);

etc. Look at some of the examples that comes with CGI.

> use CGI::Carp qw/fatalsToBrowser/;
> use CGI::Cookie;

You allready got CGI::Cookie support by using CGI, so this is really 
unnessecary. Look at the CGI docs to see how Lincoln Stein sugests that 
cookies are used with the CGI module..
> 
> # Define all variables "with use vars" #
> 
> use vars qw(
> $scriptname $version $ver_date $authors       $company
> $address1 $city $state $zipcode
> $phone $email $main_page $copy $design
> $c $r1 $r2 $b1 $b2 $c1 $c2 $rc
> $title $header
> $query
> $your_cookie
> %get_cookies
> $new_cookie
> $retreived_cookie
> $current_time
> );
> 
> $scriptname = "tcookie2.cgi";
> $version      = "1.00.00";
> $ver_date   = "06-08-00";
> $authors      = "Dave Van Abel";
> $company      = "Dave Van Abel";
> $address1     = "2131 S. Allison Court";
> $city         = "Lakewood";
> $state                = "CO";
> $zipcode      = "80227";
> $phone                = "303-989-6481";
> $email                = "dvanabel\@vanabel.com";
> $main_page    = "<a href='http://www.vanabel.com' TARGET='_top'>Main
> Page for vanabel.com</font></a>";
> $copy                 = "<FONT size='2'>\&copy 2000, Dave Van Abel";
> $design               = "<a href='http://vanabel.com/' TARGET='_top'>Design
> by Dave Van Abel</font></a>";
> 
> $c = "<font color=red>*</font>";
> $r1 = "<font color=red>";
> $r2 = "</font>";
> $b1 = "<font color=blue>";
> $b2 = "</font>";
> $c1 ="<center>";
> $c2 ="</center>";

You dion't seem to use all theese, using the w switch or the warnings 
pragma (in perl 5.6) will give you an idear.

> $title       = "Page 2 of Cookie Testing Script!";    #HTML TITLE
> $header      = "Page 2 of Cookie Testing Script!";    #HTML HEADER
> 
> $query  = new CGI();
No needs for () here, to me
$q = new CGI;
looks cool ;-))

> 
> # Retreive Info for Cookie #
> 
> $new_cookie = $query->param('new_cookie');
> # Retreive the Existing Cookie #

This is a bit weird, you don't have a HTML FORM element which could provide 
your CGI object with parameters. for retrieving your cookie values, CGI 
docs states

       To retrieve a cookie, request it by name by calling
       cookie() method without the -value parameter:
 
               use CGI;
               $query = new CGI;
               %answers = $query->cookie(-name=>'answers');
               # $query->cookie('answers') will work too! 
 
> 
> #%get_cookies = fetch CGI::Cookie;
> # retreive all cookies ??
> #$retreived_cookie = $get_cookies{'dva'}->value;      # bad when none
> existed!!
> $retreived_cookie = cookie('dva');
> 
> if ($new_cookie eq "") {
> $new_cookie = localtime;
> }
> $your_cookie = new CGI::Cookie(
> -name=>'dva',
> -value=>$new_cookie,
> -expires=>'+30d'
> );
> 
> print $query->header(-cookie=>$your_cookie);
> print $query->start_html(
> -title=>$title,
> -bgcolor=>'white',
> -text=>'#000000'
> ),
> 
> # Header #
> 
> "<CENTER><font color=blue><H3>$header</H3></font></CENTER>",
> 
>     "<P><CENTER><TABLE CELLPADDING=4 CELLSPACING=2 BORDER=1
> bgcolor='#CfCfCf'>",
> 
> # New Info #
> 
> "<TR>",
> "<TD colspan='2' bgcolor='#FF2F2F' height=5'><STRONG>$c1 Cookie
> Information</STRONG></TD>",
> "</TR>",
> 
>     "<TR>",
>     "<TD>Your Previous Cookie was</TD>",
>     "<TD>$r1 $retreived_cookie $r2</TD>",
>     "</TR>",
>     "<TR>",
>     "<TD>Your New Cookie now is</TD>",
>     "<TD> $r1 $new_cookie $r2</TD>",
>     "</TR>",
>     "</TABLE></CENTER><P>",
> 
> "<p>",
> $c1,
> "$main_page<p>",
> "$copy<p>",
> $c2,
>  $query->end_html;

Else, your code is OK, I like utilizing print as a list operator very much. 
However, you could improve performance by using HERE documents for some of 
that, and you should avoid importing functions that you don't use. 
Personally, I allways use an object ($obj = new CLASS(params)), but if you 
look at osme of the examples for CGI, you'll see that importing can be cool 
too...

-anders
-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Wed, 04 Oct 2000 16:07:32 GMT
From: dottiebrooks@my-deja.com
Subject: Deleting files older than n days
Message-Id: <8rfkjt$448$1@nnrp1.deja.com>

Hi,
  Does anyone have a script to delete files over n days old on NT?  I'm
working on a script that has

use Time::ParseDate;
use Time::localtime;
use File::stat;
 ...

  $file_date = ctime(stat($file)->mtime);

and it's giving me a
Can't call method "mtime" on an undefined value at line ...
which makes me think the stat may not be working.

Thanks,
Russ


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


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

Date: Wed, 04 Oct 2000 17:24:14 GMT
From: stdenton@my-deja.com
Subject: Re: Deleting files older than n days
Message-Id: <8rfp3k$8au$1@nnrp1.deja.com>

In article <8rfkjt$448$1@nnrp1.deja.com>,
  dottiebrooks@my-deja.com wrote:
>   $file_date = ctime(stat($file)->mtime);
>
> and it's giving me a
> Can't call method "mtime" on an undefined value at line ...
> which makes me think the stat may not be working.


Yeah, stat is pretty much Unix only.  It returns a list on NT, but
several of the fields are undef'ed.  I don't have Perl on any nearby NT
boxes, but if you call the "standard" stat builtin function (not
File::stat) and look at the list of values returned, you should be able
to quickly figure out what you need.


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


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

Date: 04 Oct 2000 18:38:28 +0100
From: nobull@mail.com
Subject: Re: Fork creates grandchildren?
Message-Id: <u9pulg7bhn.fsf@wcl-l.bham.ac.uk>

wbuchan@uk.noha-systems.com writes:

> I'm calling fork (code similar to that on p.167 of the Camel book if
> anyone's checking!) and in the child process calling exec gzip which
> reads from a named pipe.

exec() with a single argument that contains shell metacharacters is
implemented by calling sh with a -c switch.

>  The child process is 1844 but what I see when
> I do a ps -ef seems to show that this child has created it's own child.
> 
>  wbuchan  1845  1844  0 11:20:58 pts/6    0:00 sh -c gzip -6 > exp.dat <
> /u01/exports/exp_pipe
> 
>  wbuchan  1844     1  0 11:20:58 pts/6    0:00 sh -c gzip -6 > exp.dat <
> /u01/exports/exp_pipe
> 
> It does work: anything I send to the pipe gets compressed.  And if I
> manually decompress then I get back the original input.  However I'm a
> bit puzzled/concerned why there appears to be two gzip processes
> created.

There do not.  There appear to be two sh processes.  There's probably
also a gzip proceess which will be a child of one of the above.  This
may be a feature of your sh and is not related to Perl.  If your sh
were a link to bash then you wouldn't have any sh processes, just the
gzip process.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 04 Oct 2000 15:23:09 GMT
From: mrstevejones@my-deja.com
Subject: Help me get this code working
Message-Id: <8rfi0k$1fa$1@nnrp1.deja.com>

Please help with this code:
I wrote this with help from this board and a Perl book.
I keep getting and error:
Uninitialized value at actualexe line 24
The purpose of this prog. is to open a 3 field CSV file, search for the
given dpsr and and that records hours to the total and return the total
hours.

What am I missing


Thanks
Steve
################################################################

#!/usr/local/bin/perl -w
# utm03/toll/webserver/htdocs/ncs/prodesk/actualcsv.csv << path of
#actual data

########################
# Beta Actuals Database#
# By Steve J Jones     #
# 816                  #
# ISSD                 #
########################
my $mysearch = <STDIN>;
# my $projid;
# my $dpsr;
# my $hours = 0;
my $total = 0;
chop $mysearch;

open ACTDATA, "/toll/webserver/htdocs/ncs/prodesk/actualcsv.csv" or
die "Unable to open Actuals Data file: $!\n";

#	@actarray = <ACTDATA>;



	while(my($projid,$dpsr,$hours)=split/,/,<ACTDATA>)
{
	if($dpsr == $mysearch) ## <---- error here(I think)
	{
	  $total += $hours;
	}



         print $total, "\n";
}


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


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

Date: Wed, 04 Oct 2000 13:31:24 -0400
From: Jeffrey Scott Dunfee II <dunfeeje@pilot.msu.edu>
Subject: Help with CGI
Message-Id: <39DB696C.3A1AED8D@pilot.msu.edu>

I have a cgi script written in perl used for a feedback form on a web
page.  When you click on the submit button it sends an e-mail and then
tries to print html back to the browser to display a "temporary" web
page thanking the user, and then eventually I am going to add some html
to re-direct the web page back to the original. Anyways, the problem is
encountered when it tries to print the html back to the web browser, it
gets through the e-mail section, sends the e-mail but when it hits the
first print statement for the html it asks to open the file or save it
to disk (I'm using netscape on this one, it works in I.E, but the users
don't want to switch so I'm stuck making it work for netscape).  And
when you choose Open it, it displays the html printed into my default
text editor.  And only the html.  if you could take a look and see if I
am doing something wrong that would be much appreciated.  Oh, we are
running perl 5.0 on an NT system.  Thanks


do "cgi-lib.pl" || die "Fatal Error: Can't load cgi library";
&ReadParse;
open(FEEDBACK,'>>C:\InetPub\mailroot\compose\feedback.txt');
print FEEDBACK "IP Address:   $ENV{'REMOTE_ADDR'}\n";
print FEEDBACK "Host Name:   $ENV{'REMOTE_HOST'}\n";
print FEEDBACK "Name:   $in{'FULLNAME'}\n";
print FEEDBACK "Phone:  $in{'PHONE'}\n";
print FEEDBACK "E-Mail: $in{'EMAIL'}\n||\n";
print FEEDBACK "Comments:\n$in{'COMMENTS'}\n\n";
close FEEDBACK;
open(SEND,'>C:\InetPub\mailroot\compose\send.txt');
print SEND "x-sender: web\@pp.msu.edu\n";
#print SEND "x-receiver: amcarey\@pplant.msu.edu\n";
print SEND "x-receiver: cmantes\@pplant.msu.edu\n";
print SEND "Subject: Physical Plant Home Page comment.\n";
print SEND "IP Address:   $ENV{'REMOTE_ADDR'}\n";
print SEND "Host Name:   $ENV{'REMOTE_HOST'}\n";
print SEND "Name:   $in{'FULLNAME'}\n";
print SEND "Phone:  $in{'PHONE'}\n";
print SEND "E-Mail: $in{'EMAIL'}\n";
print SEND "Comments:\n$in{'COMMENTS'}\n";
close SEND;
$command='copy C:\Inetpub\mailroot\compose\send.txt
c:\inetpub\mailroot\pickup\send.txt';
system($command);
unlink('C:\Inetpub\mailroot\compose\send.txt');
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE> Your Feedback has been successfully sent</TITLE>\n";
print "</HEAD>\n";
print "<BODY>\n";
print "<H1>Thank You</H1>\n";
print "</BODY>\n";
print "</HTML>\n";






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

Date: Wed, 04 Oct 2000 09:22:05 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: help: FORCE perl to evaluate arithmetic string
Message-Id: <39DB592D.BD07306F@stomp.stomp.tokyo>

Larry Rosler wrote:
 
> In article <39DA6C18.5154D3B1@stomp.stomp.tokyo>,
> godzilla@stomp.stomp.tokyo says...
> > ruzbehgonda@my-deja.com wrote:

> > > after building an arithmetic expression dynamically
> > > eg. $arith = ( (1 * 0) + 1) + 1
> > > i need perl to evaluate for the results...
> > > perl treats this as another string
> > > because of the operators and parenthesis and does
> > > not cast the string...

> > > how can i do this?

> > I have read some articles within this thread,
> > with humored interest. I also posted a clear
> > answer. Still, I am most curious. Why would
> > you "force" perl core to evaluate a mathematical
> > expression which is self-evaluating?

> > "Arithmetical" expressions automatically evaluate.
 
> As usual, you are dealing with a different problem from everyone else.
> Your code shows constant arithmetic expressions, which are evaluated
> when the program is compiled.  Everyone else is dealing with strings,
> which must be evaluated at run time.

No. You boys are blind and see a string. I see no string
but rather a standard mathematical expression which Perl
evaluates to two, numerical 2. Did you test his expression?
Tag a semicolon on the end of his line and run it. His is
a mathematical equation, not a string and, he clearly
states, with incorrect grammar, "arithmetic expression."

There are no apostrophes around his 'string' nor are
there any quotes around his "string" and, his wording
indicates along with his example, both indicate a
mathematical expression. His last sentence though,
is pure gibberish; makes no sense at all. Something
about casting a string, which at best, could be
viewed as casting troll bait. =)

 
> By the way, how did you get the following line of 
> code from your post to compile?
 
>     $string = 1 + 1 / 0 + 1 -1;

> Even without warnings and such, I get a fatal compilation error:
 
>     Illegal division by zero at ...

Easy. Look at this example,

1 / 0 + 1 = infinity plus one.

See my previous article for a print out on this
line in question. It's there, a clip from what
I see for a script crash. Actual message contains
more, but what I included says it all.

I ran that line separate from the rest of my lines,
and made it appear, I didn't, just for fun. There
is a way to compile code and print, using a buffer
flush and indirect division by zero, but as soon
as this division is attempted, FUBAR. Easier to
have your code print division by zero as a string,
not a mathematical formula.

See what I mean Mr. Rosler. This example cited by
the originating author cannot be printed. It will
automatically evaluate, mathematically. You have
to 'make' it a string to print which is changing
his clearly stated parameters and, clear question,

"How to use parentheses for math?"


Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


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

Date: Wed, 04 Oct 2000 16:23:50 GMT
From: apacheproblems@my-deja.com
Subject: https and lwp
Message-Id: <8rflib$4sv$1@nnrp1.deja.com>

We are trying to use https delivery protocol using Perl lwp. Can I use
perl agent to connect to an https server and exchange information. How
do I go about foing this?



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


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

Date: Wed, 04 Oct 2000 16:35:30 GMT
From: xlr6drone@my-deja.com
Subject: Re: Limiting Form Field Input?
Message-Id: <8rfm8h$5hu$1@nnrp1.deja.com>

HI,

Thank you for your reply.  I tried using maxlength in the input field but
this only works on "text" fields not "textarea" area fields. This is what
I found on documentation for the length() function:

length function

Return the number of bytes in a string

       length EXPR
       length

Returns the length in bytes of the value of EXPR. If EXPR is omitted,
returns length of $_.

I have no idead on how to apply this into the context of my script?

Any suggestions?

thanks,

Tim

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


In article <Pine.GSO.4.21.0010031421430.14163-100000@crusoe.crusoe.net>,
  japhy@pobox.com wrote:
> [posted & mailed]
>
> On Oct 3, xlr6drone@my-deja.com said:
>
> >I have a resume form and I want to prevent the user from inputting more
> >than 250 characters in any of the fields.  For example I need to prevent
> >people from pasting in text that will exceed 250 characters.
>
> Um, <input type="text" maxlength=250 ...>
>
> >Would it be possible to create a regular expression to handle this?
>
> This doesn't need to be done on the Perl side of things.  If you wanted
> to, though, why not use the length() function?
>
> --
> Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
> PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
> The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
> CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/
>
>


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


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

Date: Wed, 04 Oct 2000 10:08:07 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Limiting Form Field Input?
Message-Id: <39DB63F7.A31FADCE@vpservices.com>

[please put your response *after* an appropriately trimmed version of
the message you are responding to, thanks and see my comments below]  

xlr6drone@my-deja.com wrote:
> 
> In article <Pine.GSO.4.21.0010031421430.14163-100000@crusoe.crusoe.net>,
>   japhy@pobox.com wrote:
> > [posted & mailed]
> >
> > On Oct 3, xlr6drone@my-deja.com said:
> >
> > >I have a resume form and I want to prevent the user from inputting more
> > >than 250 characters in any of the fields.
> >
> > Um, <input type="text" maxlength=250 ...>
> >
> > >Would it be possible to create a regular expression to handle this?
> >
> > This doesn't need to be done on the Perl side of things.  If you wanted
> > to, though, why not use the length() function?
>
> Thank you for your reply.  I tried using maxlength in the input field but
> this only works on "text" fields not "textarea" area fields. This is what
> I found on documentation for the length() function:
> 
> [snip]
>
> I have no idead on how to apply this into the context of my script?

First, I agree with Elaine that you do *not* want to rely on maxlength
in the HTML input tag.  You can use it, but you should also have
something in your script because you have no way of knowing if people
will be using your form to submit responses to your script or if they
will make their own form, or if they will even send it using their own
hand-cooked browser that auto-submits a form.

If all you want to do is to check if the textarea string is longer than
your limit, use length() like so:

   if( length($text) > 250 ) { ... } 
   else { ... }

If what you want to do is only accept the first 250 characters, use
substr() instead like so:

   $text = substr($text,0,250);

That will discard any characters in the textarea beyond your limit.

-- 
Jeff


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

Date: Wed, 04 Oct 2000 10:21:11 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Limiting Form Field Input?
Message-Id: <39DB6707.7526896C@vpservices.com>

Jeff Zucker wrote:
>
> First, I agree with Elaine that you do *not* want to rely on maxlength

s/Elaine/Tina/;

Sorry :-(.

-- 
Jeff


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

Date: Wed, 04 Oct 2000 16:06:00 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Multiple TIEs on a hash?
Message-Id: <IzIC5.22393$td5.3952999@news1.rdc2.pa.home.com>


"Mark A. Wadden" <mark@gmi2.com> wrote in message
news:LIIB5.66115$dZ2.23280076@news3.rdc1.on.home.com...

> tie (%h, 'SDBM_File', 'foo.dbm', O_RDWR|O_CREAT, 0640) || die $!;
> tie (%h, 'Some_Other_Mod') || die $!;
>
> When I tried this it seemed to ignore the first tie statement and just use
> the last one (makes sense really).

Yes, tie() binds a variable to a package name, so there can be only one such
connection at a time.  When you tie() a variable that is already tied, the
DESTROY method of the previously tied package is called

> The other idea I had was to sub-class SDBM_File and append my extra
> functionality to each method and then use this new module to tie %h.  Does
> anyone know if this will work or if there's a better way?

I don't know if you would actually be able to add functionality since the
entire functionality of tie() is encapsulated in method calls, which would
be directly inherited by your new class - you can't add code to them.  What
you can do is just create and use a reference to a tied dbm hash in your own
pacakge's code - this would let you intercept calls and returns to the
SDBM_File methods.


--Ben Kennedy







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

Date: Wed, 4 Oct 2000 17:09:11 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Need help with a Regular expression
Message-Id: <qLHC5.452$u23.37615@news000.worldonline.dk>

sternr03@popmail.med.nyu.edu wrote:

> I have a program which gets in a field from a database
> A typical field would be:
> Columbia,Harvard
> or it could be:
> Columbia,NYU[New York,NY],Harvard[Boston],Yale
> or
> Columbia[NY]

First of all, go to the person who designed the format of your input and 
hit him HARD in th head, that'l make you feel better (if he's not you that 
is)..

Next, you need to escape the commas within square braces somehow.

# replace commas inside [] with : (colon)
$field =~ s/(\[[^,\[]+),([^\]]+\])/$1:$2/g; 

# Then get each school
@schools = split /,/, $field;

for (@schools) {
    /([^\[]+)(.*)/;
    $school = $1;
    $town = $2;
    $town =~ s/[\[\]]//g; #remove square brackets
    $town =~ s/\:/,/g;      #unescape commas
}

Then, you may wish to read the documentation for perl regexps,
perldoc perlre

-anders

-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Wed, 04 Oct 2000 15:30:44 GMT
From: Salva <salvador@my-deja.com>
Subject: Re: Need help with a Regular expression
Message-Id: <8rfif5$1uh$1@nnrp1.deja.com>

Hi Ricki!

> I have a program which gets in a field from a database
> A typical field would be:
> Columbia,Harvard
> or it could be:
> Columbia,NYU[New York,NY],Harvard[Boston],Yale
> or
> Columbia[NY]


try with something like that:

--------------------------------------------------------------
$source_line='Columbia,NYU[New York,NY],Harvard[Boston],Yale';
while($source_line=~/([^,\[\]]+)(?:\[([^\]]+))?/g)
    { $a{$1}=[split /,/,$2] }
--------------------------------------------------------------

then %a will contain a structure like:

%a = ( Columbia => [],
       NYU      => ['New York',
                    'NY'],
       Harvard  => [Boston],
       Yale     => [] }


Bye!

- Salva



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


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

Date: Wed, 04 Oct 2000 17:08:16 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: Need the best Perl Tutorial -- bar none
Message-Id: <39db6349.13484607@news.earthlink.net>

On Tue, 03 Oct 2000 11:30:31 -0500, Mark Rosenberg <herbs@capital.net>
wrote:

>Ditto to that. New to Perl and was wondering where I might find and
>online primer.
>
>Mark

Honestly, like the others said, I'd drop a few bucks on Learning Perl
or maybe, if you want to jump in feet first for CGI and perl, get a
book like Oreilly's perl for the web/cgi.pm (forget the title now) or
Lincoln Stein's book on CGI.pm.

But, Learning Perl is my recommendation.  Every site I found on the
web is either Doc/Faq type answers which often are a bit too cryptic
for a complete newbie or little "how to" CGI and Perl tutorials that
are very light in the loafers.  (Lots of code to snip, but very little
real theory and reasons.)

Jon


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

Date: Wed, 04 Oct 2000 16:13:53 GMT
From: Phil xxx <phil_xxx@my-deja.com>
Subject: perl asynchronous modem on Solaris?
Message-Id: <8rfkvo$4b1$1@nnrp1.deja.com>

I'm currently trying to write a program to dial up another computer I
want to open up in asynchronous mode.  In solaris, I read the the OS
assigns /dev/term/a and /dev/cua/a for the com port, one for incomming
transmissions the other for outgoing transmissions.  Has anyone got any
experience with this.  I reckon that I want to have 2 programs running a
dialer/sender and a pure listener.

Am I using the correct devices or is direct access on these devices
discouraged?

I have tried using Device::SerialPort but I have not managed to get this
to do a non blocking read yet, although I am currently playing with the
Lookfor  method.


Help Please!

Phil.


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


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

Date: Wed, 04 Oct 2000 15:00:03 GMT
From: joseph7971@my-deja.com
Subject: printing a postscript file directly
Message-Id: <8rfgld$ad$1@nnrp1.deja.com>

Hi,
I am trying to find out how to send a postscript file directly to a
printer from within a Perl program, especially for windows 95 operating
system. I have looked through older messages but I can't seem to find
exactly what I'm looking for. All help is appreciated,
Thanks in advance,
Joe Timoney


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


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

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


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