Re: HOw to pass parameters to the perl script?
Hi Almond, Along with what Bob suggested, you can also try using the module GetOpt::Long, too. It should be included in the standard distribution. HTH, Simon --- Almond [EMAIL PROTECTED] wrote: Please, trying to invoke perl script from the shell and have to pass parameter to it. What is the right way to do it? Thanks - Do You Yahoo!? Yahoo! Finance - Get real-time stock quotes = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. - Albert Einstein __ Do You Yahoo!? Yahoo! Finance - Get real-time stock quotes http://finance.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: another way to show results ?
Hi Ali, I hope I understood your question correctly. A user fills out a form, and you want the results to be displayed on the same page (URL) ? If that's the case, read up on subroutines. Subroutines are kind of like bins that hold perl code. Here's some pseudocode: if (some_condition){ run_subroutine_1 } else { run_subroutine_2 } sub run_subroutine_1 { # do something } sub run_subroutine_2 { # do something } run_subroutine_1 could display a form, for example. And run_subroutine_2 could process those results. All done on the same page. HTH, simon --- alpha [EMAIL PROTECTED] wrote: hi all i am new in perl and want to know can a perl cgi , return results in other way ? i know cgi script return result in new webpage . but i dont want a new page open . i want it return result in same page and in row i call it . like a counter or other web tools thank u in advance ali = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. - Albert Einstein __ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Newbie about STDIN
Hi Mark, the chomp function will take care of that problem for you. chomp removes carriage returns, if any, from the input. you might have also heard of chop which removes the last character of a string, which may or may not be a return. So, use chomp instead. #!/usr/local/bin/perl -w @array = STDIN; # or $scalar = STDIN; chomp @array; Hope that helps, Simon --- Mark Thumper Weisman [EMAIL PROTECTED] wrote: Hello List, I've got an easy one probably, however, I can't figure it out. I'm writing a command line script which asks the user to complete some simple information. I use the STDIN pushing the value into a variable, however when I got to post the variable to another variable or array, it has a carraige return in it so instead of posting the way it should it adds lines vertically. Can anyone help me get the Carriage returns out of the STDIN? Thanks, Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. - Albert Einstein __ Do You Yahoo!? Yahoo! Autos - Get free new car price quotes http://autos.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cgi script that takes in data then runs script on different host
Hi All, I've got a cgi form that takes in data. Then, I want the data to be passed to a script that's waiting on a DIFFERENT host. So, say I have this pseudo-code: cgi script on host 1pass $name to host 2 script on host 2 # get $name --- print hi there $name!\n; Obviously, I'll be doing something a little more in-depth than printing the variables, but you get the idea! I went through perlfaq 8 in the perldocs, but I didn't understand the networking jargon :-( Thanks! Simon = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. - Albert Einstein __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cgi script that takes in data then runs script on different host
Hi All, I've got a cgi form that takes in data. Then, I want the data to be passed to a script that's waiting on a DIFFERENT host. So, say I have this pseudo-code: cgi script on host 1pass $name to host 2 script on host 2 # get $name --- print hi there $name!\n; Obviously, I'll be doing something a little more in-depth than printing the variables, but you get the idea! I went through perlfaq 8 in the perldocs, but I didn't understand the networking jargon :-( Thanks! Simon = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. - Albert Einstein __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
running system command on another host
Hi All, I've never tried something like this before, so my apologies if it's easy We all know about the system command: my $program = some_script.pl; system(perl,$program); This would execute the program some_script.pl on the current host. But what if I wanted to run a script on another host? Should I create a socket? use IO::Socket; my $socket = IO::Socket::INET-new(PeerAddr = $remote_host, etc. I'm trying to run a BLAST program on the other machine. Many thanks all :-) Simon = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. - Albert Einstein __ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
extracting elements from arrays of arrays of arrays ;-)
Hiya All, I hope you'll forgive this oo perl rookie for asking a routine question. I'm not new to perl, but the bioperl module I'm working on is giving me a headache! ;-) Let's say I have this: my @array = qw(12 56 41 23); my $array_ref = \@array; # where $var1, $var2, and $var3 are other array references. my $ref = [$var1, $var2, $array_ref, $var3 ]; my @object = (); push @object, $ref; QUESTION: How do I obtain the array $array_ref refers to in this situtation? Let's say I want to give @new the values in @array. Thank many thanks for your time and help! = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. - Albert Einstein __ Do You Yahoo!? Yahoo! Sports - live college hoops coverage http://sports.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
unique elements in array
Hi All, The solution to my question is probably dead easy, but the bioperl module I'm working on right now has sucked up all by brain juice! ;-) Let's say I have this array: @food = qw(milk ham eggs bread eggs milk); How can I write a script that sticks all UNIQUE elements (occurs only once) into another array? So, in the above case, @another_array would receive ham and bread Many thanks for your time, Everybody! = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. - Albert Einstein __ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
recommend oo tut
Hi All, I'm not new to perl, however I would like to pick up some object-oriented perl. Can anyone out there recommend a good BEGINNER'S tutorial out there? I've spent some time searching on Google, couldn't find much for a oo newbie. Right now, I reading Randal's oo tutorial on CPAN. Thanks for your time, All! ;-) = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. - Albert Einstein __ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tables in CGI
Hiya Gerry, Is this db a relational database (like MySQL) ?? If so, have you heard of the DBI module? Using it, you can query the db and return the info in an array. Then, using a while loop, your script can determine how many TD's in the table to have. Like most of the other modules in Perl, the DBI module is quite well documented. Hope this helps. Try posting a snippet of what you've got and the rest of us can probably provide more specific help. ## --- Gerry Jones [EMAIL PROTECTED] wrote: I've been tormented by a very small problem. I'm trying to display the results of a database query using CGI. What I've done is create subroutines to return the names of the table columns and another to return the data, both of which are stored in seperate arrays. So I have my data, but the table just doesn't come out right. The problem is the arrays can be of different sizes, and I'm finding it really difficult to code a dynamic table using CGI. I could do it in pure HTML easily, but that's not the point: I'm trying to keep my code consistent. I've searched the 'net but the solutions I found didn't work. Thanks in advance, Gerry. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. -Albert Einstein __ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Question!! number of line....
Hiya Mark, Something like this should work: #!/usr/local/bin/perl -w use strict; my $file = file.txt; open (READ, $file) || die Can\'t open file: $!; my @list_of_words = READ; close (READ) || die Can\'t close file: $!; my $counter = 1; foreach my $word (@list_of_words){ ++$counter; if ($word eq Apple){ my $counter2 = $counter; last; } } print Found \'Apple\' in line $counter2; exit; ### Each cycle in the foreach loop increases the value of $counter by 1. When the word is located, the loop exited due to the last command. So, if the word is in line number 5, $counter will have a value of 5. I hope this helps. Simon ## --- Mark Mclogan [EMAIL PROTECTED] wrote: How I can know in that I number of line finds a word in a text file?. For example, a file file.txt contains the following list: Chocolate Cake Cheese Apple orange melon lemon How I can know in that line number is the Apple word? Over MMClogan _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. -Albert Einstein __ Do You Yahoo!? Send your FREE holiday greetings online! http://greetings.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
options for the checkbox...?
Hi Everyone, Let's say I have this snippet of code for a checkbox: input type=checkbox name=bill $name = param('bill'); If the box is checked, $name will have a value of on If the box is NOT checked, $name will be undefined (have no value). My Question: Is there a way to make $name have a value of off when the box is UNCHECKED? Many thanks for your time, Everyone. = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. -Albert Einstein __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
param('$name') syntax......?
Hey Everybody, I have the following code: $k = 0; foreach $item (@array){ print $item; print qq{input type=checkbox name=$k}; ++$k; } print qq{input type=hidden name=kvalue value=$k}; What is the proper syntax to see if the checkbox had been checked or not? I've tried this: my $check = param('$k'); if ($check eq on){ print check!; } Doesn't seem to work. Many thanks for your time. = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. -Albert Einstein __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sending @array as hidden variable
Curtis, Your suggestion does not seem to work for me. My apologies for sending you the script, but the my @food = param('food'); does not work for me! Any and all suggestions would be much appreciated. here is the ovid1.cgi: #!/usr/local/bin/perl use CGI qw/:standard/; print Content-type:text/html\n\n; @food = (bread, ham, eggs); print EndHTML; form method=post action=http://cgi.sfu.ca/~skchan/cgi-bin/ovid2.cgi; input type=submit value=click EndHTML foreach $item (@food){ print qq{input type=hidden name=food value=$item}; } print /form; And here is ovid2.cgi: #!/usr/local/bin/perl use strict; use CGI qw/:standard/; print Content-type:text/html\n\n; ReadParse(*input); my @array = param('food'); my $array; foreach $array (@array){ print $array print BR;} ### ReadParse # sub ReadParse { local (*in) = @_ if @_; ###reads the form inputs and sorts. DON'T CHANGE!!! local ($i, $loc, $key, $val); if ($ENV{'REQUEST_METHOD'} eq GET) { $in = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq POST) { read(STDIN,$in,$ENV{'CONTENT_LENGTH'});} @in = split(//,$in); foreach $i (0 .. $#in) { $in[$i] =~ s/\+/ /g; ($key, $val) = split(/=/,$in[$i],2); # splits on the first =. $key =~ s/%(..)/pack(c,hex($1))/ge; $val =~ s/%(..)/pack(c,hex($1))/ge; $in{$key} .= \0 if (defined($in{$key})); # \0 is the multiple separator $in{$key} .= $val; } return 1; # just for fun } --- Curtis Poe [EMAIL PROTECTED] wrote: --- Simon K. Chan [EMAIL PROTECTED] wrote: Hi Everybody, I am trying to send an array as a hidden value in my script as follows: @array = (eggs, ham, bread, pop); foreach $food (@array){ print INPUT TYPE=\hidden\ NAME=\food\ VALUE=\$food\; } My two questions are: 1. Is this the most efficient way of sending an array as a hidden value? Hello Simon, What do you mean by 'efficiency'? You could mean most efficient in terms of program speed, bandwidth, or ease of use. I am assuming that you mean ease of use. If so, I would say yes, you have the most efficient method. However, it's not very robust. Consider the following: use strict; my @array = ( 'Ovid', 'Fred Flintstone', 'Barney the wimp Rubble' ); foreach my $name ( @array ) { print qq{INPUT TYPE=hidden NAME=name VALUE=$name\n}; } In the above example, the HTML will be broken by the quotes marks embedded in Barney Rubble's name. To deal with that, use HTML::Entities. That will encode your data so it doesn't mess up your forms. use strict; use HTML::Entities; my @array = ( 'Ovid', 'Fred Flintstone', 'Barney the wimp Rubble' ); foreach my $name ( @array ) { $name = encode_entities( $name ); print qq{INPUT TYPE=hidden NAME=name VALUE=$name\n}; } 2. And if so, what is the corresponding $input{''} syntax? use strict; use CGI qw/:standard/; my @food = param( 'food' ); Note that when using CGI.pm, the CGI::param function uses 'wantarray' to see if you're expecting a scalar or an array returned. If you were to do this: my $food = param( 'food' ); CGI.pm would only give you the first food item. Using '@food' gives you all foods listed. Cheers, Curtis Poe = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) Ovid on http://www.perlmonks.org/ __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. -Albert Einstein __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
sending @array as hidden variable
Hi Everybody, I am trying to send an array as a hidden value in my script as follows: @array = (eggs, ham, bread, pop); foreach $food (@array){ print INPUT TYPE=\hidden\ NAME=\food\ VALUE=\$food\; } My two questions are: 1. Is this the most efficient way of sending an array as a hidden value? 2. And if so, what is the corresponding $input{''} syntax? Many thanks for your time, everybody! = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. -Albert Einstein __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
executing a cgi-script continously
Hey all, Is it possible to have a CGI script that, at the end of doing all the stuff you want, re-executes itself (executes itself again)? I'm writing this for a CGI script that uses a DBI script to connect and return queries from a Mysql database. Many thanks! = # Simon K. Chan [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. -Albert Einstein __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]