Re: Multi-page CGI Form
Justin Howell wrote: > OK, I'm a newbie trying to do things in perl that are smarter than I am. > I'm working on a CGI clock-in program for where I work, and I want it > to be one CGI script with multiple pages, each a step in the clocking in > process (gathering different bits of info and confirming). use CGI::Application; http://search.cpan.org/search?dist=CGI-Application Read "Using CGI::Application" article for good explanation and examples: http://www.perl.com/pub/a/2001/06/05/cgi.html - RaFaL Pocztarski, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: user name
nayyreh atabakhsh wrote: > I am beginner at perl programming ,and I want to a > write a program that the user should not be allowed > to enter a blank name or answer. That is, continue > asking for their name until they type in at least one > character. Use something like this: my $name; do { print "Enter your name: "; $name=<>; chomp $name; } until $name=~/\S/; print "I see, your name is $name!\n"; # and now do something with $name It will keep asking ask for name (the do{} block) until it gets any non white space character (the /\S/ pattern matches) in the answer (that way it will keep asking if someone enter only space or tabulator, etc.). chomp strips the newline ("enter") character at the end of $name. - RaFaL Pocztarski, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: to activate URL
Sunthari <[EMAIL PROTECTED]> wrote: > print $q->a({href=>$urlresult},); >OR > print $q->a({href=>$results->url,"\n"}); If you want to make a link, you have to supply some link text, not just a URL. If, for example, you want the link text to be the URL itself, you need to repeat the URL like this: print $q->a({href=>$urlresult}, $urlresult); -- Keith C. Ivey <[EMAIL PROTECTED]> Washington, DC -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Multi-page CGI Form
OK, I'm a newbie trying to do things in perl that are smarter than I am. I'm working on a CGI clock-in program for where I work, and I want it to be one CGI script with multiple pages, each a step in the clocking in process (gathering different bits of info and confirming). I got the idea of doing it this way when I saw the example in the Perl Cookbook, at the end of Chapter 19. I looked it over, and started trying to generate the basics of my own program using the other as a model (read: 'borrowing' bits of that code). What I'm having trouble understanding is how, when the script is run, only one page comes up in the browser. When I did my example, using pretty much the same code, I got all my pages dumped on one page together in the browser. The part of code that worked in the example (and mine is basically identical) is: (All this code is from the Perl Cookbook by Tom Christiansen & Nathan Torkington, and this code is theirs not mine) my %States; # state table mapping pages to functions my $Current_Screen; # the current screen # Hash of pages and functions. %States = ( 'Default' => \&front_page, 'Shirt' => \&shirt, 'Sweater' => \&sweater, 'Checkout'=> \&checkout, 'Card'=> \&credit_card, 'Order' => \&order, 'Cancel' => \&front_page, ); $Current_Screen = param(".State") || "Default"; die "No screen for $Current_Screen" unless $States{$Current_Screen}; # Generate the current page. standard_header(); while (my($screen_name, $function) = each %States) { $function->($screen_name eq $Current_Screen); } standard_footer(); exit; Now, I think I know what's going on here basically, making references to the subroutines where the pages are detailed. My program just spits out all the pages at once. The example doesn't, it does it correctly. Here's one of the page subroutines: # Page to order a shirt from. sub shirt { my $active = shift; my @sizes = qw(XL L M S); my @colors = qw(Black White); my ($size, $color, $count) = (param("shirt_size"), param("shirt_color"), param("shirt_count")); # sanity check if ($count) { $color = $colors[0] unless grep { $_ eq $color } @colors; $size = $sizes[0] unless grep { $_ eq $size } @sizes; param("shirt_color", $color); param("shirt_size", $size); } unless ($active) { print hidden("shirt_size") if $size; print hidden("shirt_color") if $color; print hidden("shirt_count") if $count; return; } print h1("T-Shirt"); print p("What a shirt! This baby is decked out with all the options.", "It comes with full luxury interior, cotton trim, and a collar", "to make your eyes water! Unit price: \$33.00"); print h2("Options"); print p("How Many?", textfield("shirt_count")); print p("Size?", popup_menu("shirt_size", \@sizes ), "Color?", popup_menu("shirt_color", \@colors)); shop_menu(); } Now, I'm guessing the $active variable has something to do with my problem. Can someone explain what's happening here? I'm totally confused. Justin
Re: configuring apache to run cgi -perl on win32 system
You'll need to change your shebang line to #!c:/perl/bin/perl.exe instead of #!/usr/local/bin/perl or something like that. Search the past archives on this list (assuming there are any) as this question has definitely come up in the last 3 months before. At 01:06 AM 10/17/01, rabs wrote: >Subject: configuring apache to run cgi -perl on win32 system > > > > Hello, thank you for taking the time to read this, I hope you can help, I > > have downloaded the release of Apache/1.3.20 to run on windows 98. I >wish > > to run perl cgi so I have made the following changes to the httpd.config > > file > > > > > > > > changed #ServerAdmin to ServerAdmin [EMAIL PROTECTED] > > > > > > changed #ServerName to ServerName 127.0.0.1 > > > > > > removed the #precedding"AddHandler cgi-script .cgi > > > > > > > > I then placed the following program named "hello.cgi" in the directory > > c:/apache/cgi-bin/ > > > > > > ## > > > > #!/usr/local/bin/perl > > > > # hello.pl -- my first perl script! > > > > print "Content-type: text/html\n\n"; > > > > print "Hello, world!\n"; > > > > > > ### this script runs ok from the command >line## > > > > > > > > I then went to the url http://localhost/cgi-bin/hello.cgi > > > > > > I get this error message > > > > ## > > > > Fri Oct 12 20:48:47 2001] [error] [client 127.0.0.1] couldn't spawn child > > process: c:/apache/cgi-bin/hello.cgi > > > > ## > > > > > > what am I doing wrong? Activestate Perlis installed at > > C:\Perl\bin\perl.exe I think this has something to do with it. But I Ive > > been looking at this config file for the last eight hours and dont know > > anymore.. > > > > > > Anyway If you can help thanks in advance... > > > > Ric > > > > > > > > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] __ Gunther Birznieks ([EMAIL PROTECTED]) eXtropia - The Open Web Technology Company http://www.eXtropia.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
user name
I am beginner at perl programming ,and I want to a write a program that the user should not be allowed to enter a blank name or answer. That is, continue asking for their name until they type in at least one character. thank you for help __ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
CPAN error, MD5 is not loaded
I keep getting this error when installing modules via CPAN: #perl -MCPAN -e shell cpan> install Crypt::DSA::Key::SSH2 Can't locate object method "new" via package "MD5" (perhaps you forgot to load "MD5"?) at /usr/lib/perl5/5.6.1/CPAN.pm line 4212. It has done this for several modules now. I just recently upgrade to perl 5.6.1 via CPAN. Anyone have any ideas? Thanks, CC -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
configuring apache to run cgi -perl on win32 system
Subject: configuring apache to run cgi -perl on win32 system > Hello, thank you for taking the time to read this, I hope you can help, I > have downloaded the release of Apache/1.3.20 to run on windows 98. I wish > to run perl cgi so I have made the following changes to the httpd.config > file > > > > changed #ServerAdmin to ServerAdmin [EMAIL PROTECTED] > > > changed #ServerName to ServerName 127.0.0.1 > > > removed the #precedding"AddHandler cgi-script .cgi > > > > I then placed the following program named "hello.cgi" in the directory > c:/apache/cgi-bin/ > > > ## > > #!/usr/local/bin/perl > > # hello.pl -- my first perl script! > > print "Content-type: text/html\n\n"; > > print "Hello, world!\n"; > > > ### this script runs ok from the command line## > > > > I then went to the url http://localhost/cgi-bin/hello.cgi > > > I get this error message > > ## > > Fri Oct 12 20:48:47 2001] [error] [client 127.0.0.1] couldn't spawn child > process: c:/apache/cgi-bin/hello.cgi > > ## > > > what am I doing wrong? Activestate Perlis installed at > C:\Perl\bin\perl.exe I think this has something to do with it. But I Ive > been looking at this config file for the last eight hours and dont know > anymore.. > > > Anyway If you can help thanks in advance... > > Ric > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Error: Pseudo-terminal will not be allocated because stdin is not a terminal.
Dude, thanks a bunch. That module rocks. This provided soluitions to several other problems I had as well. Thanks man, Chuck - Original Message - From: "_brian_d_foy" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, October 16, 2001 6:56 AM Subject: Re: Error: Pseudo-terminal will not be allocated because stdin is not a terminal. > In article <017501c155cb$0c286320$[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Chuck) wrote: > > > I am having a hell of a time getting something to work; > > > my $cmd = "/bin/ssh -l cci $host \"df -b | grep root | grep -v grep\""; > > @results = `$cmd`; > > have you tried Net::SSH? > > http://search.cpan.org/search?dist=Net-SSH-Perl > -- > brian d foy <[EMAIL PROTECTED]> - Perl services for hire > CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html > Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Parsing HTTP links
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Brett W. McCoy) wrote: > On Tue, 16 Oct 2001 [EMAIL PROTECTED] wrote: > > I need to parse out all http links stored in a local file. > > How would I go about doing this? > > which modules would I need to use? > Take a look at HTML::Parser, which is available from CPAN. or even HTML::SimpleLinkExtor http://search.cpan.org/search?dist=HTML-SimpleLinkExtor -- brian d foy <[EMAIL PROTECTED]> - Perl services for hire CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Parsing HTTP links
[EMAIL PROTECTED] wrote: > I need to parse out all http links stored in a local file. > How would I go about doing this? > > which modules would I need to use? You mean HTML links. use HTML::LinkExtor from: http://search.cpan.org/search?dist=HTML-Parser or HTML::SimpleLinkExtor from: http://search.cpan.org/search?dist=HTML-SimpleLinkExtor - RaFaL Pocztarski, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Parsing HTTP links
On Tue, 16 Oct 2001 [EMAIL PROTECTED] wrote: > I need to parse out all http links stored in a local file. > How would I go about doing this? > > which modules would I need to use? Take a look at HTML::Parser, which is available from CPAN. -- Brett http://www.chapelperilous.net/ You can observe a lot just by watching. -- Yogi Berra -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Parsing HTTP links
I need to parse out all http links stored in a local file. How would I go about doing this? which modules would I need to use? TIA Greg
Re: Error: Pseudo-terminal will not be allocated because stdin is not a terminal.
In article <017501c155cb$0c286320$[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Chuck) wrote: > I am having a hell of a time getting something to work; > my $cmd = "/bin/ssh -l cci $host \"df -b | grep root | grep -v grep\""; > @results = `$cmd`; have you tried Net::SSH? http://search.cpan.org/search?dist=Net-SSH-Perl -- brian d foy <[EMAIL PROTECTED]> - Perl services for hire CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: somone please help
Gareth Londt wrote: > can someone please help me with this problem? Well... It strongly depends on your problem.. :) - RaFaL Pocztarski, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
somone please help
can someone please help me with this problem? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Auto Submit
Hi, I have a weird question and i don't know if it is possible to be done, but... let's try. I have a login page and then i send the user and the password to another script that analyse this information. What i want to do in this script is the following: If the user is not user1 or user2 i will open again the login page but i want to post a parameter to this login page telling the user that it is his/her second try. For example (this is the second script): If (($user ne 'user1') || ($user ne 'user2')) { $try = 2; #THIS IS THE WAY THAT I AM DOING BUT I DON'T WANT THE USER TO CLICK #ON THE SUBMIT BUTTON WHEN IT HAPPENS, I WANT IT TO AUTO SUBMIT... print "Content-type:text/html\n\n"; print < EndOfHTML } Thanks again, Wagner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
mail help?
hi i have a problem! i am using the Mail::Sendmail module and well i have it working all nicley and stuff but this is were it doent work the way i want it to. Firstly i have a text area that needs to filled in with a few email addresses, but when i use the regexp for this value in the text area the mail that i get has all the headers and including text in the BODY of the message and its not suppose to. MY regexp is ~ s/\n+/\, /gm i need to replace all the enters with a comma so that more than one email can be sent at one time. please help is needed as this is very urgent. thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: (simple) cgi.pm question
On Tue, 16 Oct 2001, Shannon Murdoch wrote: > So the script halves in size and now becomes: > print OUTFILE > "$entrynumber\t$params{q1_1}\t$params{q1_2}\t$params{q1_3}\t$params{q1_4}\t$ > params{q1_5}\t$params{q1_6}\t$params{q1_7}\t$params{q1_8}\t$params{q1_9}\t$p > arams{q1_10}\t$params{q1_11}\t$params{q1_12}\t$params{q1_13}\t$params{q1_14} > \t$params{q1_15}\t$params{q1_16}\t$params{q1_17}\t$params{q1_18}\t$params{q1 > _19}\t$params{q1_20}\t$params{q1_21}\t$params{q1_22}\t$params{q1_23}\t$param > s{q1_24}\t$params{q1_25}\t$params{q1_26}\t$params{q1_27}\t$params{q1_28}\t$p > arams{q1_29}\t$params{q1_30}\t$params{q1_31}\t$params{q1_32}\t$params{q1_33} > \t$params{q1_34}\t$params{q1_35}\t$params{q1_36}\t$params{q1_37}\t$params{q1 > _38}\t$params{q1_39}\t$params{q1_40}\t$params{q1_41}\t$params{q1_42}\t$param > s{q1_43}\t$params{q1_44}\t$params{q1_45}\t$params{q1_46}\t$params{q1_47}\t$p > arams{q1_48}\t$params{q1_49}\t$params{q1_50}\t$params{q1_51}\t$params{q1_52} > \t$params{q1_53}\t$params{q1_54}\t$params{q1_55}\t$params{q1_56}\t$params{q1 > _57}\t$params{q1_58}\t$params{q1_59}\t$params{q1_60}\t$params{q1_61}\t$param > s{q1_62}\t$params{q1_63}\t$params{q1_64}\t$params{q1_65}\t$params{q1_66}\t$p > arams{q1_67}\t$params{q1_68}\t$params{q1_69}\t$params{q1_70}\t$params{q1_71} > \t$params{q7_1}\t$params{q7_2}\t$params{q7_3}\t$params{q7_4}\t$params{q7_5\t > $params{q7_6}\t$params{q7_7}\t$params{q7_8}\t$params{q7_9}\n"; > close(OUTFILE); You could make it even smaller by looping through the hash: print OUTFILE $entrynumber; foreach (sort keys %params) { print OUTFILE, "\t$params{$_}" } print OUTFILE "\n"; -- Brett http://www.chapelperilous.net/ You are sick, twisted and perverted. I like that in a person. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: (simple) cgi.pm question
Shannon Murdoch wrote: > print OUTFILE > "$entrynumber\t$params{q1_1}\t$params{q1_2}\t$params{q1_3}\t$params{q1_4}\t$ > params{q1_5}\t$params{q1_6}\t$params{q1_7}\t$params{q1_8}\t$params{q1_9}\t$p > arams{q1_10}\t$params{q1_11}\t$params{q1_12}\t$params{q1_13}\t$params{q1_14} > \t$params{q1_15}\t$params{q1_16}\t$params{q1_17}\t$params{q1_18}\t$params{q1 > _19}\t$params{q1_20}\t$params{q1_21}\t$params{q1_22}\t$params{q1_23}\t$param > s{q1_24}\t$params{q1_25}\t$params{q1_26}\t$params{q1_27}\t$params{q1_28}\t$p > arams{q1_29}\t$params{q1_30}\t$params{q1_31}\t$params{q1_32}\t$params{q1_33} > \t$params{q1_34}\t$params{q1_35}\t$params{q1_36}\t$params{q1_37}\t$params{q1 > (...) You could write something like this: print join "\t", @params{'q001'..'q100'}; instead of: print "$params{q001}\t$params{q002}\t ... $params{q100}"; # 100 times "Perl is designed to give you several ways to do anything, so consider picking the most readable one." - Larry Wall - RaFaL Pocztarski, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]