[21985] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4207 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 2 21:06:19 2002

Date: Mon, 2 Dec 2002 18:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 2 Dec 2002     Volume: 10 Number: 4207

Today's topics:
        A regex 'whoa' <bryan@akanta.com>
    Re: advanced html form question <wsegrave@mindspring.com>
    Re: advanced html form question <tassilo.parseval@post.rwth-aachen.de>
    Re: advanced html form question <wsegrave@mindspring.com>
    Re: advanced html form question <wsegrave@mindspring.com>
    Re: Application creation (joel)
    Re: calling inherited constructor, is this valid? <nospam1102@joesbox.cjb.net>
    Re: calling inherited constructor, is this valid? <nospam1102@joesbox.cjb.net>
    Re: Changing the width of the tab <mgjv@tradingpost.com.au>
    Re: cron and argv <ddunham@redwood.taos.com>
    Re: cron and argv <xxxxxxx@xxx.xxx>
    Re: cron and argv (David Efflandt)
        HELP! Looking for a cgi (Jorge Mesa)
    Re: HELP! Looking for a cgi <bryan@akanta.com>
    Re: help:  advanced html form question btam01@ccsf.edu
    Re: how to get it quoted? (Tad McClellan)
        How to split to scalar? <bob@bobber.com>
    Re: How to split to scalar? <mgjv@tradingpost.com.au>
    Re: How to split to scalar? <bob@bobber.com>
    Re: I love you Perl!!!!!!! <wasadmin@optonline.net>
    Re: mask bit detection <mgjv@tradingpost.com.au>
    Re: mysql <darkage@freeshellzzzz.org>
    Re: Show pictures? btam01@ccsf.edu
    Re: Show pictures? btam01@ccsf.edu
    Re: variable & class <robert@deadspam.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 03 Dec 2002 01:51:43 GMT
From: Bryan <bryan@akanta.com>
Subject: A regex 'whoa'
Message-Id: <3DEC0E2F.7050105@akanta.com>

I saw this in a colleagues code today (I SWEAR it's not mine!):

$part1 =~ 
/^(\d+)\s*\t\s*(\d+)\s*\t\s*(\d+)\s*\t\s*(\d+)\s*\t\s*(\d+)\s*\t\s*\d+\s*\t\s*(\d+)\s*\t\s*\d+\s*\t\s*([-|\+])\s*\t*$/;

Comments?



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

Date: Mon, 2 Dec 2002 17:14:34 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: advanced html form question
Message-Id: <asgpke$51n$1@slb2.atl.mindspring.net>

"Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
news:3debc654@news.victoria.tc.ca...
> Fred (joleebaby@hotmail.com) wrote:
<snip>

> I'm afraid that your question is too basic for anyone to give a good
> answer.  If you don't know how to proceed then the answer is to learn to
> program, or something like that - sorry if this sounds sarcastic, it is
> not meant to be so.
>
> You mention html forms, so I must assume this program will run as a cgi
> script.
>
> I suggest you find some example cgi script to see how they work.
>
> #!perl
>
> use strict;
> use CGI qw(:standard);
>
> print header;
>
> print "<html><header><title></title></header><body><pre>";
>
> my $colour = param('COLOUR');
>
> print "your answer was $colour";
>
> if ($colour eq "Blue")
> {  print "so what now?";
> }
>
> print "</pre></body></html>";
>

WADR to Mr. Dew-JOnes, the above appears to be a curious mixture of using
CGI.pm and then _not_ using its shortcuts, e.g.,

#!perl -w
# dev-jones_v2.pl - usage
http://localhost/cgi-bin/dew-jones_v2.pl?COLOUR=Blue
use strict;
use CGI qw(-no_xhtml :standard *pre);
my $colour = param('COLOUR');
print header, start_html, start_pre, "Your answer was $colour.";
if ($colour eq 'Blue'){
  print p, 'So what now?';
}
print end_pre, end_html;

might better illustrate the use of CGI.pm , IMO. If there's a compelling
reason to hand code HTML in a script that uses CGI.pm, it eludes me for now.
Perhaps Mr. Dew-Jones can let us know what it is.

Personally, I find the example to be lacking, in that the user, when he
points
his browser to the script with http://localhost/cgi-bin/dew-jones_v2.pl,
gets

Your answer was .

as the screen response.

OTOH, if the OP uses http://localhost/cgi-bin/dew-jones_v2.pl?COLOUR=Blue,
he'll get the expected response

Your answer was Blue.
So what now?

In closing, the example is not an example of _any_ kind of form; so it could
be considered to be Off-Topic. With that, I'll return to the OP's question
in another response.

Cheers.

Bill Segraves






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

Date: 2 Dec 2002 23:26:04 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: advanced html form question
Message-Id: <asgq6c$aum$1@nets3.rz.RWTH-Aachen.DE>

Also sprach William Alexander Segraves:

> "Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
> news:3debc654@news.victoria.tc.ca...

>> You mention html forms, so I must assume this program will run as a cgi
>> script.
>>
>> I suggest you find some example cgi script to see how they work.
>>
>> #!perl
>>
>> use strict;
>> use CGI qw(:standard);
>>
>> print header;
>>
>> print "<html><header><title></title></header><body><pre>";
>>
>> my $colour = param('COLOUR');
>>
>> print "your answer was $colour";
>>
>> if ($colour eq "Blue")
>> {  print "so what now?";
>> }
>>
>> print "</pre></body></html>";
>>
> 
> WADR to Mr. Dew-JOnes, the above appears to be a curious mixture of using
> CGI.pm and then _not_ using its shortcuts, e.g.,
> 
> #!perl -w
> # dev-jones_v2.pl - usage
> http://localhost/cgi-bin/dew-jones_v2.pl?COLOUR=Blue
> use strict;
> use CGI qw(-no_xhtml :standard *pre);
> my $colour = param('COLOUR');
> print header, start_html, start_pre, "Your answer was $colour.";
> if ($colour eq 'Blue'){
>   print p, 'So what now?';
> }
> print end_pre, end_html;
> 
> might better illustrate the use of CGI.pm , IMO. If there's a compelling
> reason to hand code HTML in a script that uses CGI.pm, it eludes me for now.
> Perhaps Mr. Dew-Jones can let us know what it is.

I can let you know: It's personal preference. I use CGI.pm mainly for
the processing of the data that come into the script and for diddling
with the response-header.

I am feeling far more comfortable with large here-doc sections for
spitting out HTML. HTML-wise this could be called WYSIWYG. Along with
Perl's curious @{[ ... ]} interpolation of arbitrary Perl code within
strings that makes up for a very basic yet powerful templating
mechanism.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Mon, 2 Dec 2002 17:48:54 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: advanced html form question
Message-Id: <asgrl2$meb$1@slb3.atl.mindspring.net>

"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
message news:asgq6c$aum$1@nets3.rz.RWTH-Aachen.DE...
<snip>
> > might better illustrate the use of CGI.pm , IMO. If there's a compelling
> > reason to hand code HTML in a script that uses CGI.pm, it eludes me for
now.
> > Perhaps Mr. Dew-Jones can let us know what it is.
>
> I can let you know: It's personal preference [PP]. I use CGI.pm mainly for
> the processing of the data that come into the script and for diddling
> with the response-header.
>

Thanks, Tasillo. I thought it might be PP.

> I am feeling far more comfortable with large here-doc sections for
> spitting out HTML. HTML-wise this could be called WYSIWYG.

I see. And you have no trouble keeping up with all the HTML tags?

>Along with
> Perl's curious @{[ ... ]} interpolation of arbitrary Perl code within
> strings that makes up for a very basic yet powerful templating
> mechanism.

I just felt the OP would be better served if he learned to use CGI.pm _and_
the shortcuts it includes, as long as he's using it.

Cheers.

Bill Segraves




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

Date: Mon, 2 Dec 2002 18:54:51 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: advanced html form question
Message-Id: <asgvfo$671$1@slb9.atl.mindspring.net>

"Fred" <joleebaby@hotmail.com> wrote in message
news:3deb7186$1@rutgers.edu...
> I am creating an online survey, the answers to which will be sent to a
mySQL
> dbase using php.
>

php? Are you sure you want to be here?

> Question:  I want the answers to the first question to be included in the
> next question.  The first question will give a multiple choice answer in
> check box form like so (this is just a simplified example not actual
> survey):
>
> What is your favorite color?
> _Blue
> _Green
> _Red
> x-Yellow
> _Pink
>
> The answer the respondent gave to the first question was yellow, so the
next
> question should read:
>
> Why is your favorite color yellow?
> _I like it
> _it makes me smile
> _my mother was that color
>
> So in essence, the first answer is inserted into the next question.  Is
this
> possible?

With Perl, it's definitely possible. With php? I don't even know if its PHP,
Php, or php; but I do know that I should look it up instead of asking here.
;-)

Since you've come to clpmisc with your question, I'll show you a Perl script
that does what you asked. We'll leave the construction of SQL queries and
submittal to mySQL until later, when and if you really have a problem with
Perl. If you have a problem with Perl, post what's not workijg for you after
you've searched the FAQs, Perl docs, and Google.

#!perl -w
use strict;
use CGI qw(-no_xhtml :standard);
print header,
 start_html,
 'What is your favorite color?',
 start_form,
 radio_group(-name=>'color',
   -values=>['None', 'Blue', 'Green', 'Red', 'Yellow', 'Pink'],
   -default=>'None',
 )
;
my $color=param('color');
# Don't print the second part if a color is not selected.
unless ($color eq 'None'){
 print p, 'Why is your favorite color ', $color, "?\n";
 print p, checkbox_group(-name=>'whycolor',
    -values=>['I like it', 'It makes me smile', 'My mother likes that
color'],
 )
}
;
print p, submit, end_form, end_html;

If you look at the HTML that this script generates, I think you'll see it
would indeed be a bit onerous to code the HTML by hand.

Use Perl and CGI.pm.

Cheers.

Bill Segraves








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

Date: 2 Dec 2002 16:48:54 -0800
From: jarmenta@espiritu.org (joel)
Subject: Re: Application creation
Message-Id: <4dc11ecd.0212021648.487b0a58@posting.google.com>

jan_may2002_fure@attbi.com (Jan Fure) wrote in message news:<e47a84bf.0212021115.e532a1f@posting.google.com>...
> Hi;
> 
> I hope everybody are recovered from giving thanks!
> 
> I would like to know what the best option is for distributing a Perl
> application to windows users. I like the idea of using the activestate
> perl develop kit (PDK), as it seems like I then could distribute the
> application without requiring installation of Perl and required
> modules.
> 
> The problem is that the demo is either buggy or intentionally gutted,
> as the Kommodo (Tools -> Build standalone perl application)
> application builder option erroneously reports that PDK is not
> installed.
> 
> I don't mind paying for the full license, but I would feel silly if
> what I want to do is still not possible. I have posed some questions
> to the activestate contact E-mail address, but I have been unable to
> get much more information than "See our web page".
> 
> Are there ways outside active Perl to make a standalone application?
> 
> Does anybody know if PDK does what I expect (allow me to distribute an
> executable file which does the same as a perl script using modules
> beyond those built into activestate perl)?
> 
> Jan

Download PDK from activestate:
(http://www.activestate.com/Products/Perl_Dev_Kit/)

Install the license and you should be able to use it from "Tools ->
Build standalone perl application".


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

Date: 2 Dec 2002 23:10:41 GMT
From: Josef Drexler <nospam1102@joesbox.cjb.net>
Subject: Re: calling inherited constructor, is this valid?
Message-Id: <asgp9h$8ic$1@panther.uwo.ca>

Bryan Castillo wrote:
> Josef Drexler <nospam1102@joesbox.cjb.net> wrote in message news:<as6a98$nm9$1@panther.uwo.ca>...
>> I'm constructing a new class which inherits from LWP::UserAgent.  I want to
>> initialize the instance using LWP::UserAgent's constructor, but then do a
>> few modifications and re-bless the instance to my derived class.
>> 
>> I read in perltobj that re-blessing almost always means the inherited class
>> is misbehaving, but I don't understand why this is bad.  I haven't seen
>> anything else in the docs where a constructor calls an inherited
>> constructor and then reblesses the reference.  Is there a good reason to
>> avoid this?  It seems to work fine, but I'd like to know if there are any
>> pitfalls that I'll walk into later on.
> 
> Most OO modules bless the object into the child class using the 2
> argument form of bless.
> 
> When you use syntax like:
> 
> Foo::Bar->new;
> 
> 'Foo::Bar' is the first argument in @_, when inside the new method.

I did know that already, and have use it in the cases where the derived
class doesn't have a constructor.

[snip]
>> This is an example of what I'm doing:
>> 
>> package LWP::FormAgent;
>> use base qw(LWP::UserAgent);
>> use strict;
>> use warnings;
>> 
>> sub new {
>>         my $class = shift;
>>         my $self = LWP::UserAgent->new(@_);
>>         push @{ $self->requests_redirectable }, 'POST';
>>         # ... do some other initialization stuff
>>         return bless $self, $class;
>> }
> 
> # try something like this instead 
> # if you don't have any specific initialization 
> # don't even define a new method.
> sub new {
>   my $self = LWP::UserAgent::new(@_);
>   print "I am doing some initialization\n";
>   return $self;
>}

However, it never occured to me to just pass the first argument on to the
inherited constructor.  Of *course* that's how I should do this, it
actually makes sense.

Thanks!

-- 
   Josef Drexler                 |    http://publish.uwo.ca/~jdrexler/
---------------------------------+----------------------------------------
 Please help Conserve Gravity    |  Email address is *valid*.
 Walk with a light step.         |  Don't remove the "nospam" part.


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

Date: 2 Dec 2002 23:16:37 GMT
From: Josef Drexler <nospam1102@joesbox.cjb.net>
Subject: Re: calling inherited constructor, is this valid?
Message-Id: <asgpkl$8ic$2@panther.uwo.ca>

Benjamin Goldberg wrote:
> Josef Drexler wrote:
> [snip]
> Now, you want to know *why* you should let your superclass bless it
> appropriately, rather than reblessing it?

Yes, that was my second question.

> What happens if, inside the superclass's constructor, it creates a
> hashref, blesses it, then calls methods on it to initialize it, then
> returns it?  For example, if the superclass's constructor were:
> 
>    sub new {
>       my $self = bless {}, shift();
>       $self->configure(@_);
>       return $self;
>    }
> 
> Suppose that you, the inheritor, want to override the configure method?
> 
> If your constructor is:
>    sub new {
>       my $class = shift();
>       my $self = SuperClassName->new(@_);
>       # other stuff with $self.
>       return bless $self, $class;
>    }
> 
> Then your overridden 'configure' method won't ever be called, and the
> superclass's 'configure' will be called instead.

I see now, thanks for explaining that.  Of course it really makes sense
now, I just didn't make the connection before.  It also didn't occur to me
that I could pass the "real" class name to the constructor of the derived
class, but that's what the 2-argument form of bless is all about, of
course.

Thanks for enlightening me!

-- 
   Josef Drexler                 |    http://publish.uwo.ca/~jdrexler/
---------------------------------+----------------------------------------
 Please help Conserve Gravity    |  Email address is *valid*.
 Play Chess, not Basketball.     |  Don't remove the "nospam" part.


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

Date: Tue, 03 Dec 2002 00:48:48 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Changing the width of the tab
Message-Id: <slrnauo004.4ru.mgjv@verbruggen.comdyn.com.au>

On 30 Nov 2002 22:40:17 -0800,
	AG <ag269@columbia.edu> wrote:
> I am trying to output a table of 2 columns using /t formatting:
> 
> However, if the length of the word if the first column exceeds 7
> characters, the next column is pushed further then the rest. Which
> leads me to my question:
> 
> Is there a way to change the default width of columns from 8 to ,say,
> 12 characters?

No.

A tab is a tab, and how it displays depends on your output device.

If you need fixed width outputs, you should probably consider using
printf with format specifiers that include a width, or use formats,
described in the perlform documentation. You would still need to make
sure that the space you reserve is long enough for the longest word,
or truncate it. For example:

my $foo = "rather_long_word";
my $bar = "short";
my $d = 12345;

printf "%-10.10s %-10.10s %10d\n", $foo, $bar, $d;

will print 

rather_lon short           12345


See the documentation for sprintf in the perlfunc pages for more
information.

If you need to reserve enough space for the longest word, loop over
the words, and find the largest length. Then use that length to create
a printf template.

Martien
-- 
                        | 
Martien Verbruggen      | True seekers can always find something to
Trading Post Australia  | believe in.
                        | 


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

Date: Mon, 02 Dec 2002 23:08:32 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: cron and argv
Message-Id: <QJRG9.492$c23.13386968@newssvr14.news.prodigy.com>

woodywit <markwitczak@yahoo.com> wrote:
> I'm having a problem with reading $ARGV[0] in a perl script that is
> executed by cron.  Any solutions?

A problem?  Can you describe?

> Here is the script AppCamDriver.pl:

> #!/usr/local/bin/perl -w
> use strict;
> my $martName = $ARGV[0];
> print $martName,"\n";

> The cron entry looks like this:
> 01 15 * * * csh -c \$CONIHOME/scripts/AppCamDriver.pl ALL

1) What does the output of the script look like?  What does the cron log
   show for that entry?
2) This is a perl script.  Why are you asking csh to get involved?  sh
   (which is the handler for cron jobs) can run perl just as well as
   csh.
3) Where did you set $CONIHOME to something useful?  

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: Mon, 02 Dec 2002 23:12:29 GMT
From: "Brad" <xxxxxxx@xxx.xxx>
Subject: Re: cron and argv
Message-Id: <xNRG9.34980$oa.1654679@news1.east.cox.net>


"woodywit" <markwitczak@yahoo.com> wrote in message
news:88c9f169.0212021501.272a0b7d@posting.google.com...
> I'm having a problem with reading $ARGV[0] in a perl script that is
> executed by cron.  Any solutions?
>
> Here is the script AppCamDriver.pl:
>
> #!/usr/local/bin/perl -w
> use strict;
> my $martName = $ARGV[0];
> print $martName,"\n";
>
> The cron entry looks like this:
> 01 15 * * * csh -c \$CONIHOME/scripts/AppCamDriver.pl ALL

Why are you running it with the csh?  If the script is set executable make
the final part of the cron line:

    $CONIHOME/scripts/AppCamDriver.pl ALL

That assumes, of course, that CONIHOME is defined.  Assuming the script is
in the same account that is running it, then use $HOME.

BTW, this is a UNIX question, not a perl question.

Brad





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

Date: Tue, 3 Dec 2002 01:40:26 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: cron and argv
Message-Id: <slrnauo2s9.e1m.efflandt@typhoon.xnet.com>

On 2 Dec 2002 15:01:55 -0800, woodywit <markwitczak@yahoo.com> wrote:
> I'm having a problem with reading $ARGV[0] in a perl script that is
> executed by cron.  Any solutions?

Yes.

> Here is the script AppCamDriver.pl:
> 
> #!/usr/local/bin/perl -w
> use strict;
> my $martName = $ARGV[0];
> print $martName,"\n";
> 
> The cron entry looks like this:
> 01 15 * * * csh -c \$CONIHOME/scripts/AppCamDriver.pl ALL

The backslash (\) in front of $CONIHOME prevents it from being expanded
(just like in Perl), so it is taken literally as '$CONIHOME' instead of
the value of "$CONIHOME" [assuming CONIHOME (w/o $) is properly defined].

Example of sh test script that just does echo $@:

efflandt@laptop:~> ./myshtest \$TERM
$TERM
efflandt@laptop:~> ./myshtest $TERM
xterm

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: 2 Dec 2002 17:25:11 -0800
From: jmesam@hotmail.com (Jorge Mesa)
Subject: HELP! Looking for a cgi
Message-Id: <bf29a174.0212021725.87f4dcb@posting.google.com>

I want to thank to everyone, for your posts and for your support,
This my cgi resulted:
=================
#!/usr/bin/perl
#redirect.pl

use CGI qw/:standard/;

print header(1,'301 Moved Permanently'),
print redirect('http://www.terra.es/');
==================

When I check it on: http://www.searchengineworld.com/cgi-bin/servercheck.cgi

The results:
Status: HTTP/1.1 302 Object Moved  
Location: http://www.terra.es/  
Server: Microsoft-IIS/5.0  
Content-Type: text/html  
Connection: close  
Content-Length: 153  

But if I cut the last line: print redirect('http://www.terra.es/');
The results:
Status: HTTP/1.1 301 Moved Permanently  
Server: Microsoft-IIS/5.0  
Date: Tue, 03 Dec 2002 01:22:06 GMT  
Connection: close  
HTTP/1.0 301 Moved Permanently  
Content-type: 1  

Why my cgi can not send the header and redirect???

Thank you again, and no, it is not a student exercise, it's for the
real life
;-))), my server is remote, and the administrators of my ISP, don't
want to make a server redirection, this way it will be too easy.

Best regards, and sorry for my english.

Jorge Mesa


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

Date: Tue, 03 Dec 2002 01:39:18 GMT
From: Bryan <bryan@akanta.com>
Subject: Re: HELP! Looking for a cgi
Message-Id: <3DEC0B46.6080800@akanta.com>

Jorge Mesa wrote:
> Hello!
> I'm looking for a cgi to redirect people from a page to another.
> 1) The page to be redirected is a htm file.
> 2) My remote server is windows and support Perl 5.
> 3) The cgi has to change the server status (HTTP Header) to error 301 Moved
> Permanently.
> 
> Does anybody where I could find something similar??
> 
> Thank you in advance,
> Jorge
> 
> 

Not sure why you want the 301 code... but you could also just use meta 
redirect...

http://www.netmechanic.com/news/vol2/html_no5.htm

One of many links from google....

B



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

Date: Mon, 2 Dec 2002 16:49:11 -0800
From: btam01@ccsf.edu
Subject: Re: help:  advanced html form question
Message-Id: <Pine.HPX.4.44.0212021643140.23275-100000@hills.ccsf.cc.ca.us>

On Mon, 2 Dec 2002, Fred wrote:

> I am creating an online survey, the answers to which will be sent to
a mySQL
> dbase using php.
>
> Question:  I want the answers to the first question to be included in the
> next question.  The first question will give a multiple choice answer in
> check box form like so (this is just a simplified example not actual
> survey):
>
> What is your favorite color?
> _Blue
> _Green
> _Red
> x-Yellow
> _Pink
>
> The answer the respondent gave to the first question was yellow, so the next
> question should read:
>
> Why is your favorite color yellow?
> _I like it
> _it makes me smile
> _my mother was that color
>
> So in essence, the first answer is inserted into the next question.  Is this
> possible?


I did this using a combo box instead.  Note that this script keeps calling
itself.  You can add more "elsif" statements for additional conditions.

#! /usr/local/bin/perl
## Filename : color.cgi

use CGI;
use strict;

my $query = new CGI;

print <<EOF1;
Content-type: text/html

<html>
  <head>
    <title>Color</title>
  </head>

  <body bgcolor="#ffffff">
    <font face="verdana" size="1">
EOF1

if ( $query -> param ( 'COLOR' ) )
{
   my $color = $query -> param ( 'COLOR' );

print <<EOF2;
      Why is your favorite color $color?
      <form action="http:// ... color.cgi" name="mycolor" method="post">
      #             ^^^^^^^^^^^^^^^^^^^^^
      #             Enter the absolute path to this script
      #             For example http://foobar/cgi-bin/cgiwrap/color.cgi
      #             Erase these comments when you have entered the path

        <select name="REASON">
          <option value="1" selected>I like it.
          <option value="2">It makes me smile.
          <option value="3">That's the color of my car.
        </select>

        <br><br>

        <input type="submit" value="Submit">&nbsp;&nbsp;
        <input type="reset" value="Cancel">
EOF2
}
else
{
print <<EOF3;
      Pick a color
      <form action="http:// ... color.cgi" name="mycolor" method="post">
      #             ^^^^^^^^^^^^^^^^^^^^^
      #             Enter the absolute path to this script
      #             For example http://foobar/cgi-bin/cgiwrap/color.cgi
      #             Erase these comments when you have entered the path

        <select name="COLOR">
          <option value="RED" selected>Red
          <option value="GREEN">Green
          <option value="BLUE">Blue
        </select>

        <br><br>

        <input type="submit" value="Submit">&nbsp;&nbsp;
        <input type="reset" value="Cancel">
EOF3
}

print <<EOF4;
      </form>
    </font>
  </body>
</html>
EOF4

-Bill



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

Date: Mon, 2 Dec 2002 17:18:32 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: how to get it quoted?
Message-Id: <slrnaunqi8.5i3.tadmc@magna.augustmail.com>

user <du_bing@hotmail.com> wrote:

> Subject: how to get it quoted?


Errr, by using quote marks?


> open(MAIL,"|mailx -s 'for test' c24b18d4bb4afdf052330678af9a601d+
                        ^^^^^^^^
> sent-mail\@neo.tamu.edu");


You already have an argument with a space in it there, do
the same thing for any other arguments with spaces.


> However, we have many users whose folder names have space, e.g. 'sent
> mail'.

> So the question is how should I get mail delivered to folders with space
> in name?


Put quotes around the argument that contains a space, just like
you did for the other argument that contained a space.


> open(MAIL,"|mailx -s 'for test' c24b18d4bb4afdf052330678af9a601d+sent
> mail\@neo.tamu.edu") does not work.


open(MAIL,"|mailx -s 'for test' 'c24b18d4bb4afdf052330678af9a601d+sent mail\@neo.tamu.edu'")


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 03 Dec 2002 01:27:49 GMT
From: Bob <bob@bobber.com>
Subject: How to split to scalar?
Message-Id: <3DEC0895.2070507@bobber.com>

An easy question:

How do I split a string, and instead of dumping the results into an 
array, put a specific scalar from the array into another scalar?  In one 
step?

So I have a string something like this:
my $s = "My string is 4";

And I want to do something like this:
my $num = $(split / /, $s)[3];

so that $num is 4;

Sadly, this doesn't work.   I know this is simple but I'm missing the 
syntax.  Maybe this must be a two step operation?

Thanks,
Bob



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

Date: Tue, 03 Dec 2002 01:38:16 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: How to split to scalar?
Message-Id: <slrnauo2st.4ru.mgjv@verbruggen.comdyn.com.au>

On Tue, 03 Dec 2002 01:27:49 GMT,
	Bob <bob@bobber.com> wrote:
> An easy question:
> 
> How do I split a string, and instead of dumping the results into an 
> array, put a specific scalar from the array into another scalar?  In one 
> step?
> 
> So I have a string something like this:
> my $s = "My string is 4";
> 
> And I want to do something like this:
> my $num = $(split / /, $s)[3];

ITYM

my $num = (split / /, $s)[3];

> so that $num is 4;
> 
> Sadly, this doesn't work.   I know this is simple but I'm missing the 
> syntax.  Maybe this must be a two step operation?

The perldata documentation has quite a few examples of this syntax in
the section "List value constructors", for example.

Martien
-- 
                        | 
Martien Verbruggen      | The world is complex; sendmail.cf reflects
Trading Post Australia  | this.
                        | 


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

Date: Tue, 03 Dec 2002 01:41:44 GMT
From: Bob <bob@bobber.com>
Subject: Re: How to split to scalar?
Message-Id: <3DEC0BD8.3010002@bobber.com>

Martien Verbruggen wrote:
> On Tue, 03 Dec 2002 01:27:49 GMT,
> 	Bob <bob@bobber.com> wrote:
> 
>>An easy question:
>>
>>How do I split a string, and instead of dumping the results into an 
>>array, put a specific scalar from the array into another scalar?  In one 
>>step?
>>
>>So I have a string something like this:
>>my $s = "My string is 4";
>>
>>And I want to do something like this:
>>my $num = $(split / /, $s)[3];
> 
> 
> ITYM
> 
> my $num = (split / /, $s)[3];
> 
> 
>>so that $num is 4;
>>
>>Sadly, this doesn't work.   I know this is simple but I'm missing the 
>>syntax.  Maybe this must be a two step operation?
> 
> 
> The perldata documentation has quite a few examples of this syntax in
> the section "List value constructors", for example.
> 
> Martien

Man!  Thanks, I missed that one (obvious) solution.  As usual, I was 
trying to make things too complicated.

B



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

Date: Mon, 02 Dec 2002 23:29:48 GMT
From: "Tequila" <wasadmin@optonline.net>
Subject: Re: I love you Perl!!!!!!!
Message-Id: <M1SG9.79899$Kk2.19293@news4.srv.hcvlny.cv.net>

You have issues pal...

"Luis Fernandes" <elf@ee.ryerson.ca> wrote in message
news:x08yzkjjo5.fsf@ee.ryerson.ca...
> I just wanted to publically express my eternal love for Perl, Larry
> Wall, Tom Christiansen and Nathan Torkington; the latter two being
> the authors of the _Perl Cookbook_.
>
> I just cooked up a program using recipes 4.6, 5.7 and 3.8. Total time
> 30 min. And it worked perfectly the first time!
>





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

Date: Tue, 03 Dec 2002 00:55:24 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: mask bit detection
Message-Id: <slrnauo0cg.4ru.mgjv@verbruggen.comdyn.com.au>

On Mon, 2 Dec 2002 09:15:29 -0600,
	Tad McClellan <tadmc@augustmail.com> wrote:
> Vorxion <vorxion@fairlite.com> wrote:
> 
>> Given 0751 and the like, 
> 
> 
> I assume that you mean:
> 
>    my $num = 0751;
> 
> 
>> what is the best method in perl for determining
>> which "bits" are set on each byte?
> 
>> Suggetions?
> 
> 
>    my @bits = map { $num & 1<<$_ ? 'set' : 'cleared'} 0..15;
>    print "bit number $_ is $bits[$_]\n" for 0..15;

Note that if you actually are talking about the mode as returned by
stat(), you should probably use the various S_IF* constants and S_IS*
functions from the Fcntl module. See the stat entry in perlfunc for
more information.

Martien
-- 
                        | 
Martien Verbruggen      | You can't have everything, where would you
Trading Post Australia  | put it?
                        | 


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

Date: Tue, 3 Dec 2002 10:49:47 +1100
From: "^darkage" <darkage@freeshellzzzz.org>
Subject: Re: mysql
Message-Id: <asgrjk$c5l$1@perki.connect.com.au>

jesus! it works!!!! (:   but not sue if its missing out some transactions.
Is this a reliable method?

"Avantage" <mgiga@logava.com> wrote in message
news:l%NG9.783$rv5.355936@news20.bellglobal.com...
> > ie. $mysql->query(q{
> >   INSERT INTO logs (field1, field2, field3, field4, field5, field6)
VALUES
> > ($fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5])
> >   });
>
> Why not simply use (notice the doubled "q" followed by "!") :
>
> $mysql->query(qq!
>    INSERT INTO logs (field1, field2, field3, field4, field5, field6)
VALUES
>    (@fields)
> !);
>
> have a nice one,
>
> Michel
>
>




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

Date: Mon, 2 Dec 2002 17:06:36 -0800
From: btam01@ccsf.edu
Subject: Re: Show pictures?
Message-Id: <Pine.HPX.4.44.0212021704220.27080-100000@hills.ccsf.cc.ca.us>

On Mon, 2 Dec 2002, Ireland wrote:

> Is it possible for perl to show a picture in a script?
>
> Heres the script. When i run the script can a  picture  show up for 5
> seconds, close and continue on??
> How do I do this ?
>
>
> script below-----------------
> #usr/bin/perl
>
> #would like the picture to show up here for 5 seconds
>
> #open file
> open (REPLY, ">reply.txt");
> $reply = REPLY;
>
> #clear out contents
> print clear $reply;
>
> #close file
> close (REPLY);
>
> -----------------------
>
> Thanks

If you want to read and show a text file on a web page, you can do it this
way.

#! /usr/local/bin/perl

use CGI;
use strict;

print <<EOF1;
Content-type: text/html

<html>
  <head>
    <title>Read and Show Text File</title>
  </head>

  <body bgcolor="#ffffff">
    <font face="verdana" size="1">
EOF1

my $file = "tempfile.txt";

open ( FH, "< $file" ) || die;
   while ( my $line = <FH> )
   {
      chomp ( $line );
      print "$line<br>\n";
   }
close ( FH );

print <<EOF2;
    </font>
  </body>
</html>
EOF2

-Bill




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

Date: Mon, 2 Dec 2002 17:15:41 -0800
From: btam01@ccsf.edu
Subject: Re: Show pictures?
Message-Id: <Pine.HPX.4.44.0212021713550.28003-100000@hills.ccsf.cc.ca.us>

On Mon, 2 Dec 2002, Ireland wrote:

> Is it possible for perl to show a picture in a script?
>
> Heres the script. When i run the script can a  picture  show up for 5
> seconds, close and continue on??
> How do I do this ?
>
>
> script below-----------------
> #usr/bin/perl
>
> #would like the picture to show up here for 5 seconds
>
> #open file
> open (REPLY, ">reply.txt");
> $reply = REPLY;
>
> #clear out contents
> print clear $reply;
>
> #close file
> close (REPLY);
>
> -----------------------
>
> Thanks

If you want to show a picture for 5 seconds with perl, why not do it this
way?

#! /usr/local/bin/perl

use strict;

print <<EOF1;
Content-type: text/html

<html>
  <head>
    <title>Read Text File</title>
    <meta http-equiv="refresh" content="5;url=http://www.yahoo.com">
  </head>

  <body bgcolor="#ffffff">
    <img src="http:// ... /yourlog.jpg">
  </body>
</html>
EOF1



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

Date: Tue, 03 Dec 2002 00:48:22 GMT
From: Robert Inder <robert@deadspam.com>
Subject: Re: variable & class
Message-Id: <f51adjoue0a.fsf@auk.3lg.org>


>>>>> Christophe  writes:
    > Subject: variable & class
    > Date: Wed, 20 Nov 2002 12:57:39 +0100

    > Hi,
    > I don't understand why this code doesn't work 

    > #! /usr/bin/perl
    > use strict;

    > package main;
    > classe::test();

    > package classe;
    > my $var = 'contenu de var dans classe::';
    > sub test {
    >   print "VAR=$var";
    > }

Think about the order in which things are done.

Perl starts by compiling things --- in particular, the sub for "test".

Then Perl goes to the top of the file, and does things in order.

So the first thing it does is call "classe::test", which prints the
current value of $var.  

Which is....what?  Remember that this is the first statement
to be executed....  SO the variable is still undefined...

THEN, after the call to test is completed, Perl goes on to
the next statement ... which assigns a value to $var!

In other word, because the function call is higher up the file
than the assignment to var, it is being executed BEFORE
THE ASSIGNMENT.  Which means that the variable has no value...

    > Thanks for your help..

    > Christophe

Robert.

--
__                                  To avoid the spam trap, mail me
|_) _ |_  _ ._ |-   | _  _| _ ._    at bcs.org.uk, not deadspam.com.
| \(_)|_)(-'|  |_   || |(_|(-'| '   
                                    Best viewed in Ebriated.


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.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 V10 Issue 4207
***************************************


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