Expire a page using CGI.pm doesn't work for IE 5
Hi all, I have been using CGI.pm to code my PERL cgi scripts and I want to set a time for the webpage to expire. I coded the expire parameter as below but it never worked in Microsoft Internet Explorer! print header(-expires=+5s); I found out that the expire parameter works for me in Netscape but not in Internet Explorer 5 which I have been mainly using. Any help will be greatly appreciated! Best Regards, John L -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[Q]Setting global variables.
Perl Gurus, How can I set global variables in perl.? I'm trying to do something like.. if(param()) { my $myvar=param(myvar); if(param(myvar2){ use $myvar here.. Has some script to show a form.. } else { On submitting the form, user enters here.. someother use of $myvar.. Here, my script is showing value of $myvar as null. I wanted to use the same value of myvar which I had before submitting the form. } Am I missing something? Or should I set a global variable for myvar?! Thanks Bhanu. = Bhanu Prakash G V S __ 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]
Printing a file from the print statement
How can I make the Open File and print content statements work from my sub make_body when called from sub create_file? The output I get is open message.txt; while () { = . } print The contents of message.txt is Hello this is a message The output I want is Hello this is a message The problem is how do I get this to work sub make_body { $cardbody =__END_OF_CARD_BODY__; open TEXT, message.txt; while (TEXT) { print $_BR; } close TEXT; __END_OF_CARD_BODY__ } The way I print the make_body function #Write out our HTML FILE sub create_file { open(OUTFILE,$FILE_NAME) ; print OUTFILE $cardbody\n; close (OUTFILE); }
Problem with caching/expiry
Hi all, I'm trying to stop browsers from caching a page that I'm using CGI.pm to output. According to what I've read about CGI.pm, the way I do this is with: print header(-expires='-1d'); which sends a header that says the page expired yesterday (and needs to be reloaded). However, the page still gets cached - and when I hit View Source I can't see any evidence that the header has been changed for the file I'm outputting. Which means that the -expires part of the line above is being completely ignored. Since CGI.pm is well tested, I'd consider this fairly unlikely... Any ideas ? Steve. /. Stephen Hurley, Room CS2-034, IDC, University Of Limerick. P. 087-6701459 E. [EMAIL PROTECTED] A. Apt.10, Charlotte Q, Limerick City. I'm not a conspiracy theorist, but there are people here who are trying to make me look like one... ../ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with caching/expiry
Update to the info below, when I hit view source I don't see the http headers in IE. However, they are being generated - so they're either being stripped out by my servee (unlikely) or IE doesn't show them (hmmm). Either way, IE is still caching pages I set to expire yesterday... -Original Message- From: Stephen.Hurley [mailto:[EMAIL PROTECTED]] Sent: 22 February 2002 17:14 To: '[EMAIL PROTECTED]' Subject: Problem with caching/expiry Hi all, I'm trying to stop browsers from caching a page that I'm using CGI.pm to output. According to what I've read about CGI.pm, the way I do this is with: print header(-expires='-1d'); .which sends a header that says the page expired yesterday (and needs to be reloaded). However, the page still gets cached - and when I hit View Source I can't see any evidence that the header has been changed for the file I'm outputting. Which means that the -expires part of the line above is being completely ignored. Since CGI.pm is well tested, I'd consider this fairly unlikely... Any ideas ? Steve. /. Stephen Hurley, Room CS2-034, IDC, University Of Limerick. P. 087-6701459 E. [EMAIL PROTECTED] A. Apt.10, Charlotte Q, Limerick City. I'm not a conspiracy theorist, but there are people here who are trying to make me look like one... .../ -- 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]
ping
Hi, I am having difficulty getting the Net::Ping module to work properly. I am using ActivePerl 5.6.1.631 on a win32 platform. I can ping a server in a dos prompt ok, but when I try to get the Perl Net::Ping to work it always returns a failure. It seems to ponder over pinging the host for a couple of seconds, and then return a zero as a result, which means that it could not reach the host, if my interpretation of the docs is correct. Here is the snippet in question: my ($pingThing, $host, $pingResult); $host = 'www.google.com'; $pingThing = Net::Ping-new(tcp, 1); $pingResult = $pingThing-ping($host); print $pingResult\n; if($pingResult == 1){print $host is alive.\n;} else{print $host could not be pinged\n;} $pingThing-close(); Am I doing something wrong here, or do I need some other module that I am unaware of? I find this sort of bizarre, as I have LWP doing a successful page fetch, so the module can obviously access the web. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.325 / Virus Database: 182 - Release Date: 2/20/02 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Q] Validating Forms?!
And then you can also write an entire validate routine in Javascript,say 'validateForm' and associate that with onSubmit event. Pass the form object itself, by invoking the function as FORM name... onSubmit=return validateForm(this); Lets make the headline short: ALWAYS VALIDATE IN PERL, BUT MAYBE VALIDATE IN JAVASCRIPT ALSO Why? Because some really annoying person is going to avoid using your Javascript, and send you bogus information. Don't think that because you use Javascript that you're safe! Always double check, as even normal users switch Javascript off. Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
$ENV{remote_user} - solved
Thanks to all who sugested that I needed to Define an authentication realm for my CGI directory That did the trick! terry On Thu, Feb 21, 2002 at 02:42:31PM -, IT Workflow - Terry Honeyford wrote: but when I use Apache 1.3.22 I don't get as many $ENV's back from the server, in particular the one my script is looking for - ($ENV{remote_user}) In apache's httpd.conf, you should enable these lines: LoadModule auth_module modules/mod_auth.so AddModule mod_auth.c and define an authentication realm for your cgi directory, like this: Directory /var/www/cgi-bin Options ExecCGI Order allow,deny Allow from all AuthType Basic AuthName World Administration AuthUserFile /etc/httpd/conf/htpasswd require valid-user Satisfy all /Directory
Re: ping
The problem is that your web page needs to be specified as http://www.google.com You left off the http:// However, when I tried to run this using activestate 5.6.1.631 on Windows 98, I got an error saying that alarm was Unimplemented. I had to change to udp to get rid of that error. Does anyone know why alarm is unimplemented in my version? Also, what can I do to add it? Thanks! Tanton - Original Message - From: Lanceo [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 22, 2002 4:19 AM Subject: ping Hi, I am having difficulty getting the Net::Ping module to work properly. I am using ActivePerl 5.6.1.631 on a win32 platform. I can ping a server in a dos prompt ok, but when I try to get the Perl Net::Ping to work it always returns a failure. It seems to ponder over pinging the host for a couple of seconds, and then return a zero as a result, which means that it could not reach the host, if my interpretation of the docs is correct. Here is the snippet in question: my ($pingThing, $host, $pingResult); $host = 'www.google.com'; $pingThing = Net::Ping-new(tcp, 1); $pingResult = $pingThing-ping($host); print $pingResult\n; if($pingResult == 1){print $host is alive.\n;} else{print $host could not be pinged\n;} $pingThing-close(); Am I doing something wrong here, or do I need some other module that I am unaware of? I find this sort of bizarre, as I have LWP doing a successful page fetch, so the module can obviously access the web. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.325 / Virus Database: 182 - Release Date: 2/20/02 -- 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]
YAPE::Regex::Explain pt 2
Sorry...mail program went bonkers prints out NODE EXPLANATION -- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): -- ^the beginning of the string -- [A-Za-z_]any character of: 'A' to 'Z', 'a' to 'z', '_' -- \w* word characters (a-z, A-Z, 0-9, _) (0 or more times (matching the most amount possible)) -- $before an optional \n, and the end of the string -- )end of grouping -- This is a great module for people trying to understand other people's regexes as well as their own. The only complaint I have is if you put in an ill formed regex, it will print up to the point where the regex is corrupt, but then will just stop and not inform you of a bad regex. Other than that, it is great! Thanks Japhy! Tanton - Original Message - From: Tanton Gibbs [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 22, 2002 5:50 AM Subject: YAPE::Regex::Explain I just found Jeff Pinyan's YAPE::Regex::Explain module and I must say that it is a beginners dream. Now, you can put any cryptic regular expressio n into his module and it will come out with a dazzling explanation. For example: print YAPE::Regex::Explain-new( '^[A-Za-z_]\w*$')-explain(); prints out: -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: What would take care of this?...
Daniel == Daniel Falkenberg [EMAIL PROTECTED] writes: Daniel Would I now have to go ahead and use HTML::parser or Daniel something of similar nature to extract headings? Yeah, go with HTML::TokeParser. Daniel !DOCTYPE HTML PUBLIC -//IETF//DTD HTML//EN Daniel HTMLHEADTITLEGet all data from H1/TITLE /HEADBODY Daniel BGCOLOR=FFh1I want all if this data extracted from Daniel heading 1 (h1)/h1 /BODY/HTML while ($stream-get_tag(h1)) { $data = get_trimmed_text(/h1); } (Also see perldoc HTML::TokeParser, once it's installed.) - Chris. -- $a=printf.net; Chris Ball | chris@void.$a | www.$a | finger: chris@$a In the beginning there was nothing, which exploded. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
convert array to integer
how to convert array to integer $array[0]=5 $array[1]=6 $array[2]=7 $array[3]=8 change to integer 5678 for calculate 5678+2=5680 thanks,
Re: convert array to integer
kitti wrote: how to convert array to integer $array[0]=5 $array[1]=6 $array[2]=7 $array[3]=8 one way to do it is: my @array = (5, 6, 7, 8); my $some_val; $some_val .= $_ for (@array); another is: my @array = (5, 6, 7, 8); my $some_val = @array; $some_val =~ s/[^\d]//g; a third is my @array = (5, 6, 7, 8); my $some_val = 0; my $i = 1; for (reverse @array) { $some_val += $i * $_; $i *= 10; } a fourth, is problay both better, quicker, more efficent and shorter but i leave that to someone else :) /Jon change to integer 5678 for calculate 5678+2=5680 thanks, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: convert array to integer
kitti wrote: how to convert array to integer $array[0]=5 $array[1]=6 $array[2]=7 $array[3]=8 change to integer 5678 for calculate 5678+2=5680 thanks, In not much elegant... foreach(@array){ $num.=$_; } $num=$num-0; Walter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: convert array to integer
You want to take a sum of all the array elements?? You don't need to convert the array to an interger. Perl handles this internally. For instance, if you want to treat a text string as a number, or a number as a text string, perl allows it. This does what you are after use strict; my @array = qw(5 6 7 8); my $total; foreach (@array) { $total .= $_; } $total += 2; print $total; HTH John -Original Message- From: kitti [mailto:[EMAIL PROTECTED]] Sent: 22 February 2002 11:47 To: [EMAIL PROTECTED] Subject: convert array to integer how to convert array to integer $array[0]=5 $array[1]=6 $array[2]=7 $array[3]=8 change to integer 5678 for calculate 5678+2=5680 thanks, --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: convert array to integer
$num=$num-0; You don't need to do this in Perl. There is no distinction between an integer and a string. It's just a scalar. OTThis is something you would have to do in Javascript though./OT John -Original Message- From: walter valenti [mailto:[EMAIL PROTECTED]] Sent: 22 February 2002 12:12 To: kitti Cc: [EMAIL PROTECTED] Subject: Re: convert array to integer kitti wrote: how to convert array to integer $array[0]=5 $array[1]=6 $array[2]=7 $array[3]=8 change to integer 5678 for calculate 5678+2=5680 thanks, In not much elegant... foreach(@array){ $num.=$_; } $num=$num-0; Walter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: convert array to integer
Kitti wrote: how to convert array to integer $array[0]=5 $array[1]=6 $array[2]=7 $array[3]=8 change to integer 5678 for calculate 5678+2=5680 $ perl -le' @array = qw(5 6 7 8); print 5678 + 2; print join( , @array ) + 2; ' 5680 5680 John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ping
Hi If you are looking to find out is a host is alive try this bit of code. $host = www.google.com; $ip=join .,unpack(C4,(gethostbyname($host))[4]); $ip will be empty if host is dead from command line perl -e print join \.\,unpack(\C4\,(gethostbyname(@ARGV[0]))[4]); www.google.com hope this helps Regards Mark - Original Message - From: Tanton Gibbs [EMAIL PROTECTED] To: Lanceo [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, February 22, 2002 10:27 AM Subject: Re: ping The problem is that your web page needs to be specified as http://www.google.com You left off the http:// However, when I tried to run this using activestate 5.6.1.631 on Windows 98, I got an error saying that alarm was Unimplemented. I had to change to udp to get rid of that error. Does anyone know why alarm is unimplemented in my version? Also, what can I do to add it? Thanks! Tanton - Original Message - From: Lanceo [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 22, 2002 4:19 AM Subject: ping Hi, I am having difficulty getting the Net::Ping module to work properly. I am using ActivePerl 5.6.1.631 on a win32 platform. I can ping a server in a dos prompt ok, but when I try to get the Perl Net::Ping to work it always returns a failure. It seems to ponder over pinging the host for a couple of seconds, and then return a zero as a result, which means that it could not reach the host, if my interpretation of the docs is correct. Here is the snippet in question: my ($pingThing, $host, $pingResult); $host = 'www.google.com'; $pingThing = Net::Ping-new(tcp, 1); $pingResult = $pingThing-ping($host); print $pingResult\n; if($pingResult == 1){print $host is alive.\n;} else{print $host could not be pinged\n;} $pingThing-close(); Am I doing something wrong here, or do I need some other module that I am unaware of? I find this sort of bizarre, as I have LWP doing a successful page fetch, so the module can obviously access the web. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.325 / Virus Database: 182 - Release Date: 2/20/02 -- 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Postgres Module in Windows?
I've searched high and low for a module, any module, that would allow me to make called to the postgres database in Windows, but have come up empty. use DBI; There doesn't even seem to be a way to do it from DBI. Does anyone have any experience with this? I would love it if someone could prove to me I didn't search hard enough. You might have to use the OBDC driver, not the pg one. Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: What would take care of this?...
--- Daniel Falkenberg [EMAIL PROTECTED] wrote: Hey All, Just wondering how I would go about extracting all the data from heading 1 (h1) in the following HTML code. I figured I could have used HTML::TableExtract but then I realized ( :) ) there are not tables in the following HTML. Would I now have to go ahead and use HTML::parser or something of similar nature to extract headings? Yes, unless its a one off... you are looking for: h1I want all if this data extracted from heading 1 (h1)/h1 which can be matched by the regular expression: /h1([^]*?)\/h1/ Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: What would take care of this?...
Jonathan == Jonathan E Paton [EMAIL PROTECTED] writes: Jonathan /h1([^]*?)\/h1/ Please don't ever try and parse HTML with regexps - I've had to work with way too much code that did. There are many situations where your regex would break, and the TokeParser code wasn't much longer. It's effectively impossible to parse HTML accurately with regexps. - Chris. -- $a=printf.net; Chris Ball | chris@void.$a | www.$a | finger: chris@$a In the beginning there was nothing, which exploded. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Postgres Module in Windows?
From: Agustin Rivera [EMAIL PROTECTED] I've searched high and low for a module, any module, that would allow me to make called to the postgres database in Windows, but have come up empty. There doesn't even seem to be a way to do it from DBI. Does anyone have any experience with this? I would love it if someone could prove to me I didn't search hard enough. Agustin Rivera http://search.cpan.org/search?dist=DBD-Pg Or if Postgres has ODBC drivers you coud use DBD::ODBC. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl subroutines using array hash????
From: Bruce Ambraal [EMAIL PROTECTED] JON MOLIN many thanks to you too..., if that's what you want to hear. Don't have time for these question need to get myself skilled in Perl soonest. I see ... so you don't have enough time to answer a simple question like Is this a homework? ? I surpose the name [EMAIL PROTECTED] is meant for people like me No. It's meant for people who want to learn or that need help with what they are doing ... not for those who want us to do their homework for them. You have been killfiled. Jenda == [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == : What do people think? What, do people think? :-) -- Larry Wall in [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
file size
Hi, I have an upload script, and i want to check the file size before it uploads. Any suggestion is appreciated Anthony -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: file size
Upload via FTP? Via a web based form? 18 questions left... John -Original Message- From: anthony [mailto:[EMAIL PROTECTED]] Sent: 22 February 2002 14:22 To: [EMAIL PROTECTED] Subject: file size Hi, I have an upload script, and i want to check the file size before it uploads. Any suggestion is appreciated Anthony -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: file size
anthony wrote: Hi, I have an upload script, and i want to check the file size before it uploads. Any suggestion is appreciated Anthony here's some old code that does that, might be something built-in in CGI.pm as well: my $tempFile = CGI::tmpFileName($img_filename); my @file_info = stat ($tempFile); if ($#file_info 0 $file_info[7] $max_size $file_info[7] 0) { copy($tempFile, $path.$filename); } else { error_msg (Max size is $max_size); } } -- 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]
[Q]How can I pass Perl variables into shell?
Thanks japhy and Wags ;) It works fine now with the backslashes! Bhanu On Feb 21, Wagner-David said: The $1 and $2 come out of reqex with parens. That's not helping, though. The answer he seeks is: backslash the $ signs. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Bhanu Prakash G V S __ 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: file size
Anthony == awards anthony writes: Anthony Hi, I have an upload script, and i want to check the file Anthony size before it uploads. The stat() function returns a list that includes file size as the seventh element. You can use: $size = (stat($filename))[7]; ... to retrieve the size of $filename in bytes. More information at perldoc -f stat, - Chris. -- $a=printf.net; Chris Ball | chris@void.$a | www.$a | finger: chris@$a In the beginning there was nothing, which exploded. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ping
On Fri, 2002-02-22 at 15:18, insomniak wrote: Hi If you are looking to find out is a host is alive try this bit of code. $host = www.google.com; $ip=join .,unpack(C4,(gethostbyname($host))[4]); $ip will be empty if host is dead from command line perl -e print join \.\,unpack(\C4\,(gethostbyname(@ARGV[0]))[4]); www.google.com This will not work if the host can be resolved, but is not up. gethostbyname does a DNS lookup, DNS lookups depends on an entry in the nameserver, not the host being available. Unfortunately I cant supply a working method... :( Kind regards Johan. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: file size
On Feb 22, Chris Ball said: Anthony == awards anthony writes: Anthony Hi, I have an upload script, and i want to check the file Anthony size before it uploads. The stat() function returns a list that includes file size as the seventh element. You can use: $size = (stat($filename))[7]; Or the -s file test as a shortcut to this same information: $size = -s $filename; More information at perldoc -f stat, And perldoc -f -X. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ping
Lanceo wrote: Hi, I am having difficulty getting the Net::Ping module to work properly. I am using ActivePerl 5.6.1.631 on a win32 platform. I can ping a server in a dos prompt ok, but when I try to get the Perl Net::Ping to work it always returns a failure. It seems to ponder over pinging the host for a couple of seconds, and then return a zero as a result, which means that it could not reach the host, if my interpretation of the docs is correct. Here is the snippet in question: my ($pingThing, $host, $pingResult); $host = 'www.google.com'; $pingThing = Net::Ping-new(tcp, 1); $pingResult = $pingThing-ping($host); print $pingResult\n; if($pingResult == 1){print $host is alive.\n;} else{print $host could not be pinged\n;} $pingThing-close(); Am I doing something wrong here, or do I need some other module that I am unaware of? I find this sort of bizarre, as I have LWP doing a successful page fetch, so the module can obviously access the web. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.325 / Virus Database: 182 - Release Date: 2/20/02 Here is what I did, as my needs were to explicitly as possible, recreate the DOS Ping's output.. :) #*** #* #* This routine will ping that passed hostname, and send its #* results to the output file... #* #*** sub ping { #*** #* #* First we need to re-open the output file, as we closed #* it after the header was created. #* #*** open (DUMPFILE,$filename); print DUMPFILE PINGing $hostname\n; #*** #* #* ping the hostname #* #*** @result =`ping $hostname`; #*** #* #* Output the results of the ping and add the bottom of the #* pretty border... #* #*** my $aPing = @result; my $Pcount = 0; while ($aPing 0){ print DUMPFILE @result[$Pcount]; $Pcount++; $aPing --; } print DUMPFILE \n; #*** #* #* Close the output file. This way, if there is a problem, #* at least the currect results are saved. Leaving it open #* would allow it to be corrupted, in case of a problem. #* #*** close (DUMPFILE); } I am reading in a list of IPs/URLs via an INI file, and passing the IP/URL to it... I need the IPs/URLs elsewhere, so I am using a global declaration... :) I am sure it could be done easier by making the sub take a parameter, but I am not at that point in learning Perl yet.. :) Hope this can help... Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Creating a valid directory.
Hi all, I want to create a new directory but I need to make sure that it's valid. Here is what I want to do. Given a starting file hierarchy of something like this Top Level .hidden Sub Level 1a .hidden2 Sub Level2a Sub Level2b Sub Level 1b Sub Level2c Sub Level 1c Sub Level 2c I need a perl script that using a variable $levels can return all of the directories for the given level. (Think of this like a find -maxdepth $level) The problem with find is that it returns hidden values and is not system independant. So In theory this function would be called like my $level = 2; my $start = /home; $dir = GetDirectory($start, $level) sub GetDirectory { my $dir; while ( -d $dir) { system ls? # I only want it to list the directories for the level # Example # /home/SubLevel1a/SubLevel2a # /home/SubLevel1a/SubLevel2b # . # . # /home/SubLevel2c print plese enter in the directory for the new directory: ; Functionhere Functionhere Functionhere if ( ! -d $dir ) { $dir= ; } else { return $dir; } } Does anyone have any ideas for this? Thanks so much -- Steven M. Klass Physical Design Manager National Semiconductor Corp 7400 W. Detroit Street Suite 170 Chandler AZ 85226 Ph:480-753-2503 Fax:480-705-6407 [EMAIL PROTECTED] http://www.nsc.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[Q]Setting global variables.
Perl Gurus, How can I set global variables in perl.? I'm trying to do something like.. if(param()) { my $myvar=param(myvar); if(param(myvar2){ use $myvar here.. Has some script to show a form.. } else { On submitting the form, user enters here.. someother use of $myvar.. Here, my script is showing value of $myvar as null. I wanted to use the same value of myvar which I had before submitting the form. } Am I missing something? Or should I set a global variable for myvar?! Thanks Bhanu. = Bhanu Prakash G V S __ 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: file size
Hi, But i tried this i didn't $size= -s $filename but it didn't work, anyways i want my upload script not to upload files that are bigger than 250Kb Anthony -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: renaming files (versioning)
On Tue, Feb 19, 2002 at 11:52:24PM -0500, Bill Akins wrote: I have to keep all versions of the existing files and oldest must have the highest -v## (version number) and newest is just data.txt. Is this a job better done in bash or perl? what about rcs? (that's revision control system and a professional in it's class...) Features: - ci -l data.txt checks in a new version to some archive stack (automatically incrementing current version number, documenting date+time, your username and a comment if you like) - At any time you can fall back to an old version by co -l -r versionnumber data.txt - rcsdiff -r1.30 -r1.25 would show you the lines that had changed between those two versions. - lots more to see. -- Johannes Franken Professional unix/network development mailto:[EMAIL PROTECTED] http://www.jfranken.de/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Need help with if statement - please
Chris [EMAIL PROTECTED] wrote on 21 Feb 2002: print 4 pings, $count were successful\n; Not sure if the Net::Ping will give me what I really need... What you saw is a VERY small part of the program, and all I wanted to do was give some realistic status, visually, realtime. It is all being logged to a file, and that output MUST be exactly like standard PING output. Thus, as I was tasked to keep it within I can read this because this is what I am used to seeing guidelines, I system commanded it out! :) You could always rewrite the print() to make it exactly like the standard ping output. But whatever, it's your program; I was just making a suggestion -- David K. Wall - [EMAIL PROTECTED] Oook. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[Q]Validating Forms?!
And then you can also write an entire validate routine in Javascript,say 'validateForm' and associate that with onSubmit event. Pass the form object itself, by invoking the function as FORM name... onSubmit=return validateForm(this); Jonathan, Validating in Perl?!I'm interested.! Can you send me some sample scripts which validates in perl?! Thanks Bhanu. Lets make the headline short: ALWAYS VALIDATE IN PERL, BUT MAYBE VALIDATE IN JAVASCRIPT ALSO Why? Because some really annoying person is going to avoid using your Javascript, and send you bogus information. Don't think that because you use Javascript that you're safe! Always double check, as even normal users switch Javascript off. Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Bhanu Prakash G V S __ 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: Perl calling Visual Basic
Joanne Kowalinski wrote: Hi, I am thoroughly lost and do not know how to do this, or even if it is possible to do. We want to have an activestate perl program running on one of our NT gateways call a Visual Basic application. The return code from the VB app will then control the path the Perl program takes. I have searched the internet for anything about Perl calling VB and can find nothing. Any help would be appreciated! Thank you - Joanne Kowalinski Calling the VB app should be fairly straight, if it is local to the Perl program... @result = `myCompiledVBApp AnyArgs`; If the VB App returns anything, the @result should (hopefully???) catch it... Anyone think I have lost my mind, or did I get one right??? :P Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Sorting situation on how to handle a sort where some items may no t be numeric
Very slick on second method. Worked and no warnings. Thanks much. Wags ;) -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 00:06 To: Wagner-David Cc: 'Beginners' Subject: Re: Sorting situation on how to handle a sort where some items may no t be numeric On Feb 21, Wagner-David said: Key CPU Mirror $AUDIT 8 Y $AUDIT1 7 Y $DATA1 7 Y $DATA2 7 Y $DATA3 6 Y This data has already been sorted, but I have a couple of disks which do not end in a number. I have the following setup to sort the data: foreach my $MyKey ( sort { $a-[1] cmp $b-[1] || $a-[2] = $b-[2] } map { [ $_, /^([a-z\-]+)(\d*)/i ] } keys %MyDisks ) { ... } where I have [0] as the key, [1] is alpha portion, [2] is number I get two warnings: one for audit above and another for system. Both without numbers. What can be done as it now stands or do I need to break out differently (ie, if no numeric add a 0 to the key since I have no zero items? You could just say ($a-[2] || 0) = ($b-[2] || 0) or you be super sneaky and do map { [ $_, ${_}0 =~ /^([a-z-]+)(\d+)/i ] } The appended 0 assures that a digit will be matched, but won't end up affecting the actual order of numeric comparisons. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl calling Visual Basic
From: Chris [EMAIL PROTECTED] Calling the VB app should be fairly straight, if it is local to the Perl program... @result = `myCompiledVBApp AnyArgs`; If the VB App returns anything, the @result should (hopefully???) catch it... I don't think the VB application will print anything to STDOUT. Maybe he should use system() : system 'myCompiledVBApp AnyArgs' == 0 or die system('myCompiledVBApp AnyArgs') failed: $?; $exit_value = $? 8; Depends on HOW does the VB app return the result. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl calling Visual Basic
chris == chris [EMAIL PROTECTED] writes: chris @result = `myCompiledVBApp AnyArgs`; chris Anyone think I have lost my mind, or did I get one right??? Close. I don't see why you're passing the return to an array rather than scalar (@ rather than $), since it should just be an integer. You're also capturing the output of the program when you use backticks, rather than the return code, which is captured using system(). To execute and capture the return code of a program, I'd use: $return_code = system('program'); ... but that assumes that the 'program' is something that can be entirely executed from the command line and returns a useful return code - I don't have familiarity with VB, but my short experiences seem to suggest that this would be rare. *awaits correction from Japhy* :-) - Chris. -- $a=printf.net; Chris Ball | chris@void.$a | www.$a | finger: chris@$a In the beginning there was nothing, which exploded. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Opposite of $respose-is_success
At 05:26 PM 2/21/02 -0800, I wrote: At 02:00 PM 2/21/02 +1030, Daniel Falkenberg wrote: Hey all, Just wondering if any one know what the oposite of $response-is_success in the code below? I have tried $response-is_fail and $response-is_failure. Oh so close :-) $response-is_error I have also RTFM but I can't find anywhere what the opposite is. It was in the same place as is_success: % perldoc HTTP::Rersponse Oops. In case it wasn't obvious, that should have been % perldoc HTTP::Response I did cut paste it, must have hit a key after the fact... [snip] $r-is_info $r-is_success $r-is_redirect $r-is_error These methods indicate if the response was informational, sucessful, a redirection, or an error. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ping
At 09:19 AM 2/22/02 +, Lanceo wrote: Hi, I am having difficulty getting the Net::Ping module to work properly. I am using ActivePerl 5.6.1.631 on a win32 platform. I can ping a server in a dos prompt ok, but when I try to get the Perl Net::Ping to work it always returns a failure. It seems to ponder over pinging the host for a couple of seconds, and then return a zero as a result, which means that it could not reach the host, if my interpretation of the docs is correct. Here is the snippet in question: my ($pingThing, $host, $pingResult); $host = 'www.google.com'; $pingThing = Net::Ping-new(tcp, 1); $pingResult = $pingThing-ping($host); I've seen this sooo many times. The answer: www.google.com responds to ICMP ping packets (which are what the ping program sends) but has chosen (or some router in between has chosen) not to respond to TCP ping packets (which are what Net::Ping sends). Don't need to be on DOS to find this out, here's Linux: $ ping www.google.com PING www.google.com (216.239.51.100) from 24.67.203.181 : 56(84) bytes of data. 64 bytes from www.google.com (216.239.51.100): icmp_seq=0 ttl=52 time=119.7 ms 64 bytes from www.google.com (216.239.51.100): icmp_seq=1 ttl=52 time=116.1 ms ^C $ perl -MNet::Ping -le 'print #5 is alive if Net::Ping-new-ping(www.google.com)' $ Okay, so let's use ICMP packets. On Unix, we have to be root: $ su Password: # perl -MNet::Ping -le 'print #5 is alive if Net::Ping-new(icmp)-ping(www.google.com)' #5 is alive But on DOS, you don't (security? what's that): C:\WINDOWS\Desktopperl -MNet::Ping -le print qq(#5 is alive) if Net::Ping-new(qq(icmp))-ping(qq(www.google.com)) #5 is alive -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
php and perl
I have a php form and I need to do some data validation either before inserting data into the database or comparing data in a textfield to data in the database. It seems like the easiest way to do this is using perl. How do you call a perl script from a php script. Thanks, Joyce -- ÐÏࡱá -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ping
I had the same problem at first, but I've found that if you want the Net::Ping module to work on a Win32 platform, you might have better luck sticking to the ICMP protocol (which is what your command-line ping is using). Something like this usually works for me: my $p = Net::Ping-new('icmp',2); foreach(@clients){ if($p-ping($_) == 1){ print $_ is alive.\n; }else{ print $_ is not responding!\n; } } Here's the catch, though. You should use one of the other methods to find out whether an Internet host is alive because many of them have their servers set to not respond to ping requests from the outside. -Original Message- From: Lanceo To: [EMAIL PROTECTED] Sent: 2/22/02 1:19 AM Subject: ping Hi, I am having difficulty getting the Net::Ping module to work properly. I am using ActivePerl 5.6.1.631 on a win32 platform. I can ping a server in a dos prompt ok, but when I try to get the Perl Net::Ping to work it always returns a failure. It seems to ponder over pinging the host for a couple of seconds, and then return a zero as a result, which means that it could not reach the host, if my interpretation of the docs is correct. Here is the snippet in question: my ($pingThing, $host, $pingResult); $host = 'www.google.com'; $pingThing = Net::Ping-new(tcp, 1); $pingResult = $pingThing-ping($host); print $pingResult\n; if($pingResult == 1){print $host is alive.\n;} else{print $host could not be pinged\n;} $pingThing-close(); Am I doing something wrong here, or do I need some other module that I am unaware of? I find this sort of bizarre, as I have LWP doing a successful page fetch, so the module can obviously access the web. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.325 / Virus Database: 182 - Release Date: 2/20/02 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Timestamp and File::find
On Wed, Feb 20, 2002 at 04:32:40PM -0500, [EMAIL PROTECTED] wrote: can one specicify a time stamp when using FileFind? sure, just do the timerange comparison within the wanted() subroutine: #!/usr/bin/perl use File::Find; use File::stat; sub isnew { # tells if the given filename has been modified lately my $st = stat(shift); return $st-mtime time()-60*60*24; # 24h ago } sub wanted { isnew($_) or return; # drop processing for older files print $File::Find::name\n; } find( \wanted, /tmp/); -- Johannes Franken Professional unix/network development mailto:[EMAIL PROTECTED] http://www.jfranken.de/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: convert array to integer
This may not be a better way, but another way is: my(@array) = (5, 6, 7, 8); my($integer) = sprintf(%1d%1d%1d%1d, @array[0], @array[1], @array[2], @array[3]); -_-Aaron -Original Message- From: Jon Molin [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 4:06 AM To: kitti Cc: [EMAIL PROTECTED] Subject: Re: convert array to integer kitti wrote: how to convert array to integer $array[0]=5 $array[1]=6 $array[2]=7 $array[3]=8 one way to do it is: my @array = (5, 6, 7, 8); my $some_val; $some_val .= $_ for (@array); another is: my @array = (5, 6, 7, 8); my $some_val = @array; $some_val =~ s/[^\d]//g; a third is my @array = (5, 6, 7, 8); my $some_val = 0; my $i = 1; for (reverse @array) { $some_val += $i * $_; $i *= 10; } a fourth, is problay both better, quicker, more efficent and shorter but i leave that to someone else :) /Jon change to integer 5678 for calculate 5678+2=5680 thanks, -- 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: php and perl
In my humble opinion, it doesn't make sense to break up the script that generates the form and the one that validates it. Its hard enough to maintain an application without having to worry about two scripts in two different languages for something as simple as presenting and validating a form. You have access to all the form validation you should need using PHP. PHP supports both POSIX and Perl style regular expressions. You can find information about regular expressions in PHP at http://www.php.net If you are simply looking for an excuse to bring perl into a project, then you should consider rewriting your form with perl, unless you have some grudge against the poor soul who will have to maintain the code. ;-) - Johnathan Joyce Harris wrote: I have a php form and I need to do some data validation either before inserting data into the database or comparing data in a textfield to data in the database. It seems like the easiest way to do this is using perl. How do you call a perl script from a php script. Thanks, Joyce -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Time to ask for help
Ok. Time to ask for help. Remember me, they guy who wanted to make the goalies stats module? Well, I have learned enough perl to do it (pat myself on the back). I got a script that runs and essentially does what I want it to do, but has a couple problems. For now, Im settling for a simple program where I input the stats by hand and the program updates the stats and prints the HTML for me to cut and paste to the site. This will make it much easier for me than updating the HTML by hand every time. since im at the most basic of beginner levels, im sure its very simple and im just overlooking something. if any of you could take a look at this script and tell my why this doesnt work, id appreciate it. 1 - when I make an update, it saves to a different file and if you make more that one update, the database starts making new entries rather than editing the existing one. 2 - the HTML output is what it should look like. but i cant figure out how to make it loop through and print a line for each entry according to rank. Thanks in advance. -Michael #39 __ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com Stats Pearl Script Description: Stats Pearl Script Michael#39 Chelsea Piers GP W L T SO GAA 0 Password0 mike Rich#31Chelsea Piers GP W L T SO GAA 0 Password0 rich Dan#61 Chelsea Piers 0 0 0 0 0 0 0 Pass0 dan Jeff#35 Chelsea Piers 0 0 0 0 0 0 0 password 0 jeff Charlie#12 Chelsea Piers 0 0 0 0 0 0 0 password0 charlie Joker#35Chelsea Piers 0 0 0 0 0 0 0 password0 joker Mitch#1 Chelsea Piers 0 0 0 0 0 0 0 password 0 mitch -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: php and perl
I wonder why you need perl at all if you are using php? Unless you want to use a prewritten perl module, there is no reason to not continue using php. However, if you do plan on using perl, I would recommend changing completely to perl as it does get very complicated to have to maintain a two server side language website. - Original Message - From: Joyce Harris [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 22, 2002 11:55 AM Subject: php and perl I have a php form and I need to do some data validation either before inserting data into the database or comparing data in a textfield to data in the database. It seems like the easiest way to do this is using perl. How do you call a perl script from a php script. Thanks, Joyce -- ÐÏࡱá -- 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]
TIme to ask for help
Ok. Time to ask for help. Remember me? The guy who wanted to write a program to update goalie stats? Well, I wrote a script that runs and essentially does what I want it to do, but has a couple problems. For now, Im settling for a simple program where I input the stats by hand and the program updates the stats and prints the HTML for me to cut and paste to the site. This will make it much easier for me than updating the HTML by hand every time. since im at the most basic of beginner levels, im sure its very simple and im just overlooking something. if any of you could take a look at this script and tell my why this doesnt work, id appreciate it. 1 - when I make an update, it saves to a different file and if you make more that one update, the database starts making new entries rather than editing the existing one. 2 - the HTML output is what it should look like. but i cant figure out how to make it loop through and print a line for each entry according to rank. Thanks in advance. Here is the script: #!/usr/local/bin/perl ## # This program checks my email box via POP3, then get the updates # from the emails. then run the numbers, then output to a text file # of the HTML that I can then cut/paste to the site. Easy. ## #declatations (cuz im a VB guy) # this actually came from an email from the form. #NewPass: new password, if they want one, if there is nothing here, then ignore this variable #TIME: 1011637980 This is totally irrelevent. Ignore this #Email: [EMAIL PROTECTED] #InGA: 3 - this is the goals allowed in the game you are adding to your stats #InIR: Roller - was this a roller game, or an ice game #Ingoalie: mike - the user name of the person updating thier stats #Inpass: potato - Password, must match password in database #Inwlt: clearMeOut - Win = A win, Loss = A loss, Tie = a tie, clearMeOut = clear all stats for new season. variables in DB #GA = goals allowed #IR = ICE or ROLLER #Goalie = name as it appears on the website #Password = Password #Wlt = Win, Loss, Tie, or clear #chapter = Which chapter of the brotherhood you are in #username = the goalies user name #rank = rank based on GAA. lowest GAA will be ranked 1 though highest GAA ranked whatever the highest is #Variables in the list #@stats = ('Goalie', 'chapter', 'GP', 'W', 'l', 'T', 'SO', 'GAA', 'GA', 'Password', 'Rank', 'Username') #Positions = 0 1 2345 6 7 8 9 10 11 # master Db's # %mastercombined [ ] # %masterice [ ] # %masterroller [ ] # The name of the total (ice and roller) combined database file # $CDB = 'goaliestats.txt'; $CDB = 'goaliestatstest.txt'; # The name of the Ice database file $IDB = 'icegoaliestats.txt'; # The name of the roller database file $RDB = 'rollergoaliestats.txt'; ## ## Open email and get info from update messages ## ## # I will do this when I get the actual program working ### ## Get Stats From User (Becomes obsolete when email input works ## ## see above) ## ### ### ask if they want to enter or quit. while(1) { # Loop forever print \nDo you want to Enter a new stat (E), . or quit and print (Q): ; $DoSearch = STDIN; chomp($DoSearch); $DoSearch =~ tr/A-Z/a-z/; # Check if they want to quit if($DoSearch eq 'q') { last } # Check if they did *not* say e or E unless($DoSearch eq 'e') { print You must enter either E or Q.\n; next; # Go out to the while loop } ### ask if the game was Ice or Roller. print \n(I)ce or (R)oller Game: ; $InIR = STDIN; chomp($InIR); $InIR =~ tr/A-Z/a-z/; # if uppercase, change to lowercase ### ask what goalie. print \nEnter Goalie username: ; $Ingoalie = STDIN; chomp($Ingoalie); $Ingoalie =~ tr/A-Z/a-z/; # if uppercase, change to lowercase ### ask For password print \nEnter Goalie Password: ; $Inpass = STDIN; chomp($Inpass); $Inpass =~ tr/A-Z/a-z/; # if uppercase, change to lowercase ### ask Win Loss or Tie. print \n(W)in, (L)oss, (T)ie, or (C)lear: ; $Inwlt = STDIN; chomp($Inwlt); $inwlt =~ tr/A-Z/a-z/; # if uppercase, change to lowercase ### ask how many Goals allowed. print \nGoals allowed: ; $InGA = STDIN; chomp($InGA); ## Get Original Numbers from Database ## # Open the database file but quit if it doesn't exist open(INDB, $CDB) or die The database $CDB could . not be found.\n; # Loop through the records in the file while(INDB) { $TheRec = $_; #chomp($TheRec); push (@mastercombined, $TheRec); } # End
using perl to generate a simple report.
Hello All, I've written a very simple script where the user inputs data, from which a report is generated. My problem is that some of this data is in rows and columns and every time the user hits enter to start a new line, the script thinks they are done and moves on to the next part of the script. Can anyone tell me How I can have the user start a new line without terminating this part of the program. What I presently have: print \n\nPlease state below product name and ID code.\n\n; What they would normally input: RAX-23419853 RAX-234b 19854 Thank you, -C -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to split on case boundries?
Hey Jeff, My MUA believes you used (X-Mailer not set) to write the following on Thursday, February 21, 2002 at 2:13:31 PM. JjP On Feb 20, Tim Musson said: The people who control the data want to remove the _ chars and make the delimiter based on the case of the chars (first char of each part is uc, all others are lc)... So the source would look like this UaBitEssdSi I still need to put the same elements into @dpt, so $dpt[0]=Ua $dpt[1]=Bit $dpt[2]=Essd $dpt[3]=Si After I get the data into the array, I will change the case. JjP @dpt = UaBitEssdSi =~ /[A-Z][a-z]*/g; Thanks Japhy Mark. I think that will work. -- [EMAIL PROTECTED] MUA = TB! v1.53d (www.RitLabs.com/The_Bat) Windows NT 5.0.2195 (Service Pack 1) Consciousness: That annoying time between naps. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Need help with if statement - please
Not sure if the Net::Ping will give me what I really need... What you saw is a VERY small part of the program, and all I wanted to do was give some realistic status, visually, realtime. It is all being logged to a file, and that output MUST be exactly like standard PING output. Thus, as I was tasked to keep it within I can read this because this is what I am used to seeing guidelines, I system commanded it out! :) Not sure if this is quite what you're after, but if you're on a unix system you can try this. It's not exactly realtime, but it will give you a realistic visual status. $Count = 4; # or any desired number of ICMP requests print `ping -c$Count domain.tld`; === Shaun Fryer === London Webmasters http://LWEB.NET PH: 519-858-9660 FX: 519-858-9024 === -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: To create a hash of lists
Thanks for the quick and excellent response. I quoted your answer for the benefit of others. Perl's syntax to work with references is giving me a few growing pains I suppose, though I'm not opposed to working with it once I get it through my head what is required to make Perl understand what I want. I did want to add one additional comment to your response however: push() requires an array. $foo{bar} is a scalar. @{ $foo{bar} } is an array. push($printQueue{A}, 'This is the first line in A'); push($printQueue{A}, 'This is the second line in A'); push($printQueue{A}, 'This is the third line in A'); push($printQueue{A}, 'This is the fourth line in A'); push($printQueue{A}, 'This is the fifth line in A'); push @{ $printQueue{A} }, ...; You could just declare your hash as my %printQueue = ( A = [ 'first', 'second', ... ], B = [ ... ], C = [ ... ], ); Then, to loop over the array references, use foreach my $text (@{ $printQueue{$key} }) { ... } While you are correct, I could define the hash per your example. The implementation I am working on requires the hash be built dynamically during execution. I have a file that contains approx. 12000 mapping enumerations for different types of simulation entities. My script sorts the list of enumerations, culls where appropriate, and then produces output based on entity types. The code you helped me with allows me to toss individual enumerations into bins for queued output. Thanks again. Will -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Converting windows txt file format to Linux txt file format
You don't need perl for this. The easiest approach is to use the dos2unix utility. Use man dos2unix for more information. - Johnathan Lilian Alvarenga Caravela Godoy wrote: Hi everyone I am trying to upload a windows txt file to a Linux server. There are an application running in my Linux server that reads the txt file to extract some information. But the application doesn't recognize the file because it's originally from windows. I know that I could solve it changing the end of line caracters such as line feed and carriage return, but I don't know how to do it. Does anyone know a way to do it using Perl? Thanks in advance. Lilian. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RES: Converting windows txt file format to Linux txt file format
Yes, Johnathan Now I know it. I didn't know it because Linux and perl are really new to me. Then I thought that I should write a perl script to do it. Thank you. -Mensagem original- De: Johnathan Kupferer [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 22 de fevereiro de 2002 16:07 Para: Lilian Alvarenga Caravela Godoy Cc: [EMAIL PROTECTED] Assunto: Re: Converting windows txt file format to Linux txt file format You don't need perl for this. The easiest approach is to use the dos2unix utility. Use man dos2unix for more information. - Johnathan Lilian Alvarenga Caravela Godoy wrote: Hi everyone I am trying to upload a windows txt file to a Linux server. There are an application running in my Linux server that reads the txt file to extract some information. But the application doesn't recognize the file because it's originally from windows. I know that I could solve it changing the end of line caracters such as line feed and carriage return, but I don't know how to do it. Does anyone know a way to do it using Perl? Thanks in advance. Lilian.
Re: using perl to generate a simple report.
What is the code you're using to accept the user input? On 2/22/02 1:40 PM, Carlo Sayegh [EMAIL PROTECTED] wrote: I've written a very simple script where the user inputs data, from which a report is generated. My problem is that some of this data is in rows and columns and every time the user hits enter to start a new line, the script thinks they are done and moves on to the next part of the script. Can anyone tell me How I can have the user start a new line without terminating this part of the program. What I presently have: print \n\nPlease state below product name and ID code.\n\n; What they would normally input: RAX-23419853 RAX-234b 19854 Thank you, -C -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Looping
The following script needs to loop through a file identifying users in each user group and the outputting that to a specific file. In the end if I have 15 groups I should have 15 files. However, when I loop I only get the last group outputted to the correct file. What I think is happening is I am looping through Index 0 which is the group, but not index 1, which is the file. I am sure it is printing only overwriting the file each time until it gets to the end. I assume I need to use some sort of nested loop, but I am confused on which one (while, for foreach etc) and how to write it. Here is the code and any help would be greatly appreciated. Thanks #!/usr/bin/perl -w open FILEIN, /usr/local/scripts/security/sybase/user/groups_f iles.txt; open ACCESSIN, /usr/local/scripts/security/sybase/user/user_a ccess_all.txt; while (FILEIN) { chomp (); @file = split /:/; } open OUT, $file[1]; select OUT; while (ACCESSIN) { chomp(); $user_access = $_; if (/$file[0]/) { print OUT $user_access \n; }} -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
system() output question.
I would like to be able to take the output of system(some cmd) and send it to a filehandle. How is this possilbe? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: system() output question.
Maybe system() isn't really what you want then. Try using backticks: $scalar = `some cmd`; print OUTFILE $scalar; -Original Message- From: Wert, Nathaniel [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 12:11 PM To: [EMAIL PROTECTED] Subject: system() output question. I would like to be able to take the output of system(some cmd) and send it to a filehandle. How is this possilbe? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: system() output question.
man perlipc line 308 Using open() for IPC use open(COMMAND, your command | ); now you can read from COMMAND besure to close COMMAND; -Original Message- From: Wert, Nathaniel [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 3:11 PM To: [EMAIL PROTECTED] Subject: system() output question. I would like to be able to take the output of system(some cmd) and send it to a filehandle. How is this possilbe? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Looping
Hi, DO NOT CROSS-POST PLEASE Many who read PBML also read [EMAIL PROTECTED], and won't appreciate answering questions answered elsewhere, it creates duplicate effort on behalf of those providing free answers (by their own, unpaid, freewill). Crossposting is one of the few ways to lose hospitality with mailing list subscribers... you've been warned! Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Logic rewrite help...
Quick help pls.. I want to use only 'and' statements. How can I get rid of this OR ?? My Boolean algebra is not functional at the moment... where ((A) or (not B ) ) TIA.. Frank -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using perl to generate a simple report.
On 2/22/02 10:40 AM, Carlo Sayegh [EMAIL PROTECTED] wrote: Hello All, Hi Carlo, I've written a very simple script where the user inputs data, from which a report is generated. My problem is that some of this data is in rows and columns and every time the user hits enter to start a new line, the script thinks they are done and moves on to the next part of the script. Can anyone tell me How I can have the user start a new line without terminating this part of the program. Assuming you're using something like $input = STDIN; chomp($input); to get your data now, you can do this @input = STDIN; chomp(@input); to get an array, with each element corresponding to each line the user entered. Users type ^D (control-d; or their EOF character, if it's not ^D) when they are finished entering data. Note that once you hit return, you can't go back and edit the previous line. Hope that helps, -- Michael -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Logic rewrite help...
--- Frank Newland [EMAIL PROTECTED] wrote: Quick help pls.. I want to use only 'and' statements. How can I get rid of this OR ?? My Boolean algebra is not functional at the moment... where ((A) or (not B ) ) = _ _ _- _ = _ = = A + B = A + B = A * B = A * B = A * B So it is going to be: not (B and not A) Or in Perl: unless (B and not A) { } unless (B ! A) { } __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: using perl to generate a simple report.
If he's using Windows, ^Z is the EOF character. -Original Message- From: Michael Kelly [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 12:35 PM To: [EMAIL PROTECTED] Subject: Re: using perl to generate a simple report. On 2/22/02 10:40 AM, Carlo Sayegh [EMAIL PROTECTED] wrote: Hello All, Hi Carlo, I've written a very simple script where the user inputs data, from which a report is generated. My problem is that some of this data is in rows and columns and every time the user hits enter to start a new line, the script thinks they are done and moves on to the next part of the script. Can anyone tell me How I can have the user start a new line without terminating this part of the program. Assuming you're using something like $input = STDIN; chomp($input); to get your data now, you can do this @input = STDIN; chomp(@input); to get an array, with each element corresponding to each line the user entered. Users type ^D (control-d; or their EOF character, if it's not ^D) when they are finished entering data. Note that once you hit return, you can't go back and edit the previous line. Hope that helps, -- Michael -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Q]Setting global variables.
Perl Gurus, How can I set global variables in perl.? I'm trying to do something like.. The logic is broken, I believe this is more appropriate: my $myvar = param(myvar); unless ($myvar) { # Show form } else { # Process form } Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Logic rewrite help...
From: Frank Newland [EMAIL PROTECTED] I want to use only 'and' statements. How can I get rid of this OR ?? My Boolean algebra is not functional at the moment... where ((A) or (not B ) ) Anything you wish ... not( not(A) and B) #!perl sub good { my ($a,$b) = @_; print (($a || !$b) ? 1 : 0, \n); } sub mine { my ($a,$b) = @_; print (! (!$a $b) ? 1 : 0, \n); } good 0,0; mine 0,0; good 0,1; mine 0,1; good 1,0; mine 1,0; good 1,1; mine 1,1; __END__ Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Q]Validating Forms?!
Validating in Perl?! I'm interested! Of course, perl has regular expressions far superiour to anything Javascript offers. In fact, I once looked at validating in Javascript and decided the character manipulation was far too much effort. You seem surprised... why? Can you send me some sample scripts which validates in perl?! Assuming CGI and param() is in use: use CGI::Carp; my $username = param(username) || ; my $email= param(email)|| ; carp Invalid username\n unless $username =~ /^[a-zA-Z_]{2,8}$/; carp Invalid email\n unless email_ok($email); --- This seems too easy... another variation on this allows much more secure scripts - again by using regular expressions and perl taint mode. BTW, you must be fairly proficient with regular expressions to get the most out of Perl. Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Sockets in an array
Hi, I have the following problem. Context: I am trying to open multiple sockets to multiple IP address. I want to use the same piece of code to do that. The IP addresses and port numbers are stored in a file. The program: I read the file, open the sockets in sequence. The sockets (globs/handles) are stored in an array. The error: However when I try to write to the sockets by using the array index, I get an error. Here is the code snippet. use IO::Socket ; $i = 0; foreach $line (@address){ chop ($line); ($host, $port) = split(/\|/, $line); $address = $host. : .$port; $newsocket[$i] = IO::Socket::INET-new($address) or die $@; # The sockets are opened fine. # Print a command to the socket. print $newsocket[$i] $command; $i++; } It is the print command that give a compile error, saying Scalar found where an operator expected Can you please tell me what I am doing wrong. Thanks in advance. Girish -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Sockets in an array
I have run into this situation before, but never found a solution.. But now that I see the problem try the following prints: print ${$newsocket[$i]} $command; print *{$newsocket[$i]} $command; print *newsocket[$i] $command; I think the second one might work... let us know how it goes. -Original Message- From: Girish Chandran [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 4:53 PM To: [EMAIL PROTECTED] Subject: Sockets in an array Hi, I have the following problem. Context: I am trying to open multiple sockets to multiple IP address. I want to use the same piece of code to do that. The IP addresses and port numbers are stored in a file. The program: I read the file, open the sockets in sequence. The sockets (globs/handles) are stored in an array. The error: However when I try to write to the sockets by using the array index, I get an error. Here is the code snippet. use IO::Socket ; $i = 0; foreach $line (@address){ chop ($line); ($host, $port) = split(/\|/, $line); $address = $host. : .$port; $newsocket[$i] = IO::Socket::INET-new($address) or die $@; # The sockets are opened fine. # Print a command to the socket. print $newsocket[$i] $command; $i++; } It is the print command that give a compile error, saying Scalar found where an operator expected Can you please tell me what I am doing wrong. Thanks in advance. Girish -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl calling Visual Basic
Of course, you can always have VB output the results to a text file and then have Perl read it. I think that would probably be the simplest way to do it. Dean Theophilou -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Chris Ball Sent: Friday, February 22, 2002 8:27 AM To: Chris Cc: [EMAIL PROTECTED] Subject: Re: Perl calling Visual Basic chris == chris [EMAIL PROTECTED] writes: chris @result = `myCompiledVBApp AnyArgs`; chris Anyone think I have lost my mind, or did I get one right??? Close. I don't see why you're passing the return to an array rather than scalar (@ rather than $), since it should just be an integer. You're also capturing the output of the program when you use backticks, rather than the return code, which is captured using system(). To execute and capture the return code of a program, I'd use: $return_code = system('program'); but that assumes that the 'program' is something that can be entirely executed from the command line and returns a useful return code - I don't have familiarity with VB, but my short experiences seem to suggest that this would be rare. *awaits correction from Japhy* :-) - Chris. -- $a=printf.net; Chris Ball | chris@void.$a | www.$a | finger: chris@$a In the beginning there was nothing, which exploded. -- 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]
Anyone still use cgi-lib.pl?
Hello all, I was wondering if anyone still used cgi-lib.pl anymore or used any of its subroutines for processing data in their applications. I am writing a secure application and don't see any harm in using the ReadParse subroutine for processing the data, but since checking with the URL it once had (http://cgi-lib.stanford.edu/cgi-lib/) and nothing being there, I've just wondered if anyone had come up with something better. I've been out of the CGI part of perl for quite a while and have been mainly doing other work with perl and just wonder if anyone has something that works good for them that they'd be willing to share. All comments and suggestions are appreciated. Thanks, Kevin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Anyone still use cgi-lib.pl?
My (admittedly inexperienced) advice: use CGI.pm http://stein.cshl.org/WWW/software/CGI/ It's been included with the standard Perl distribution for a while now - geoff On 2/22/02 6:21 PM, Kevin Old [EMAIL PROTECTED] wrote: I was wondering if anyone still used cgi-lib.pl anymore or used any of its subroutines for processing data in their applications. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Anyone still use cgi-lib.pl?
I was wondering if anyone still used cgi-lib.pl anymore or used any of its subroutines for processing data in their applications. Nope, don't use Perl4 stuff in Perl5 stuff... I am writing a secure application and don't see any harm in using the ReadParse subroutine for processing the data, but since checking with the URL it once had (http://cgi-lib.stanford.edu/cgi-lib/) cgi-lib.pl has been gathering dust, a good rule of writing secure applications is use modules that are proven AND still in common usage. and nothing being there, I've just wondered if anyone had come up with something better. The most significant is the CGI.pm module, which is a huge thing that just about everything can be done with. There are other entire methologies/frameworks for CGI have arisen in conjunction with Perl. Assuming you bothered to upgrade to version 5.005 (minimum), try: perldoc CGI Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: convert array to integer
Try this little baby. @array = (5, 6, 7, 8); $integer = print(@array); chop($integer); === Shaun Fryer === London Webmasters http://LWEB.NET PH: 519-858-9660 FX: 519-858-9024 === -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sockets in an array
Girish Chandran wrote: Hi, I have the following problem. Context: I am trying to open multiple sockets to multiple IP address. I want to use the same piece of code to do that. The IP addresses and port numbers are stored in a file. The program: I read the file, open the sockets in sequence. The sockets (globs/handles) are stored in an array. The error: However when I try to write to the sockets by using the array index, I get an error. Here is the code snippet. use warnings; use strict; use IO::Socket ; $i = 0; my $i = 0; foreach $line (@address){ for my $line ( @address ) { chop ($line); chomp $line; ($host, $port) = split(/\|/, $line); my ( $host, $port ) = split /\|/, $line; $address = $host. : .$port; my $address = $host:$port; $newsocket[$i] = IO::Socket::INET-new($address) or die $@; $newsocket[$i] = IO::Socket::INET-new( $address ) or die $@; # The sockets are opened fine. # Print a command to the socket. print $newsocket[$i] $command; perldoc -f print [snip] Note that if you're storing FILEHANDLES in an array or other expression, you will have to use a block returning its value instead: print { $files[$i] } stuff\n; print { $OK ? STDOUT : STDERR } stuff\n; print { $newsocket[$i] } $command; $i++; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Anyone still use cgi-lib.pl?
On Fri, 22 Feb 2002, Kevin Old wrote: I was wondering if anyone still used cgi-lib.pl anymore or used any of its subroutines for processing data in their applications. I am writing a secure application and don't see any harm in using the ReadParse subroutine for processing the data, but since checking with the URL it once had (http://cgi-lib.stanford.edu/cgi-lib/) and nothing being there, I've just wondered if anyone had come up with something better. I've been out of the CGI part of perl for quite a while and have been mainly doing other work with perl and just wonder if anyone has something that works good for them that they'd be willing to share. perldoc CGI If you are used to using cgi-lib, you'll be pleasnalty surprised at what the CGI module provides. It comes standard with Perl now. -- Brett http://www.chapelperilous.net/ Wedding rings are the world's smallest handcuffs. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Book suggestion
Hi team, I am unix admin trying to learn perl. How is the book LEARNING PERL BY EXAMPLE by Ellie Quigley regs Anidil Rajendran (raj) Netliant,Inc 3600,Brigde Parkway Suite 102 Redwood City,CA 94065-1170 (650) 730 8271 www.netliant.com
Re: Time sensative Sub Routine
I did this by storing the data as an associative array within a database. The HTML form where the person inputs their message POSTS the data to a CGI which then inputs it into a database with the current localtime(time) used as a unique key. The date the person selected for delivery is also converted into Perl's localtime(time) format as one of the associated array elements. Cron then periodically executes another CGI which checks the database, and if the timestamp in the array is in the past, it prints the corresponding data to |sendmail -t. Doing the localtime(time) conversion in reverse is a little tedious to work out, but it functions very reliably once you get it down. === Shaun Fryer === London Webmasters http://LWEB.NET PH: 519-858-9660 FX: 519-858-9024 === -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Book suggestion
I would suggest Learning Perl by O'Reilly -Paresh. At 04:28 PM 2/22/2002 -0800, Anidil Rajendran-Raj wrote: Hi team, I am unix admin trying to learn perl. How is the book LEARNING PERL BY EXAMPLE by Ellie Quigley regs Anidil Rajendran (raj) Netliant,Inc 3600,Brigde Parkway Suite 102 Redwood City,CA 94065-1170 (650) 730 8271 www.netliant.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Book suggestion
Hi, I would suggest going for the O'Reilly Books. Best choice in my eyes. Best regards, Oliver -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
sharing subroutines
is there a way to share uncompiled perl scripts? that is, to include the subroutines of one script file into another script file. failing that, can i easily compile a perl script and use it in a script? why am i having trouble figuring this out? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Book suggestion
Anidil Rajendran-Raj [[EMAIL PROTECTED]] quoth: *Hi team, * *I am unix admin trying to learn perl. How is the book LEARNING PERL BY *EXAMPLE by Ellie Quigley http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlfaq2/Perl_Books.html Though that book isn't mentioned specifically, I recall that Dave Cross helped to improve the book immensely and is a good book from what I've heard. e. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: sharing subroutines
I take it you mean besides cutting and pasting the text? I'm not sure exactly what you're asking. If your subroutine is not part of a compiled script, why not just copy the subroutine's code into your script? As for an easy way to compile a perl script, there are two well-known products for doing this: perl2exe http://www.perl2exe.com, and ActiveState's perlapp, which is part of the Perl Dev Kit (I'm not sure if you can buy it separately) http://www.activestate.com. Both of them basically just incorporate the perl interpreter and all required modules into an executable, so they can be fairly large (1+MB) compared to the original scripts. I've been using perlapp for a while now and have no complaints. If you cust want to call one perl script from another, though, you can just use the system() command or backticks. Again, I'm not 100% sure what you're asking, but I hope that helps. -Original Message- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 5:03 PM To: [EMAIL PROTECTED] Subject: sharing subroutines is there a way to share uncompiled perl scripts? that is, to include the subroutines of one script file into another script file. failing that, can i easily compile a perl script and use it in a script? why am i having trouble figuring this out? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sharing subroutines
On Fri, 22 Feb 2002, bob ackerman wrote: is there a way to share uncompiled perl scripts? that is, to include the subroutines of one script file into another script file. failing that, can i easily compile a perl script and use it in a script? why am i having trouble figuring this out? Take a look at the perlmod document via perldoc. It describes the standard way that you can create packages and modules and be able to use the code in other scripts. -- Brett http://www.chapelperilous.net/ He jests at scars who never felt a wound. -- Shakespeare, Romeo and Juliet, II. 2 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sharing subroutines
fine, except that creating a module seems like a big deal. you are minimizing the effort when you show me one subroutine as a module. there is a heap of bookkeeping to attend to. the docs indicate that modules are meant to be created and put in public use - i.e., generally of use. i just want a create an application where a few different scripts can all call on some common subroutines. am i making to big a fuss? is creating a module a trivial task? On Friday, February 22, 2002, at 05:12 PM, Aaron Shurts wrote: I am not exactly sure what you are asking, but if I give out the answer yes, in a module. Does that make sense? Kind of like this... # # contents of HelloName.pm # sub hello_name { ($name) = @_; printf(Hello %s\n, $name); } Then in your script you would have something like this... use lib '/src/common'; use HelloName.pm; use strict; my $name = 'Joe'; hello_name($name); -Original Message- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 5:03 PM To: [EMAIL PROTECTED] Subject: sharing subroutines is there a way to share uncompiled perl scripts? that is, to include the subroutines of one script file into another script file. failing that, can i easily compile a perl script and use it in a script? why am i having trouble figuring this out? -- 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: convert array to integer
Shaun Fryer wrote: Try this little baby. Why? @array = (5, 6, 7, 8); $integer = print(@array); chop($integer); John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sharing subroutines
I don't think creating a module is a big deal...how about file Utility.pm: package Utility; sub trim { my $val = shift; $val =~ s/^\s+//; $val =~ s/\s+$//; return $val; } In file user.pl use Utility; while( ) { print Utility::trim( $_ ); } There is a module containing a utility function that is then used by a user script...seems pretty straight forward to me. Naturally, there can be more to it than that, but there doesn't have to be or even need to be in a case like the above. Tanton - Original Message - From: bob ackerman [EMAIL PROTECTED] To: Aaron Shurts [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, February 22, 2002 11:22 PM Subject: Re: sharing subroutines fine, except that creating a module seems like a big deal. you are minimizing the effort when you show me one subroutine as a module. there is a heap of bookkeeping to attend to. the docs indicate that modules are meant to be created and put in public use - i.e., generally of use. i just want a create an application where a few different scripts can all call on some common subroutines. am i making to big a fuss? is creating a module a trivial task? On Friday, February 22, 2002, at 05:12 PM, Aaron Shurts wrote: I am not exactly sure what you are asking, but if I give out the answer yes, in a module. Does that make sense? Kind of like this... # # contents of HelloName.pm # sub hello_name { ($name) = @_; printf(Hello %s\n, $name); } Then in your script you would have something like this... use lib '/src/common'; use HelloName.pm; use strict; my $name = 'Joe'; hello_name($name); -Original Message- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 5:03 PM To: [EMAIL PROTECTED] Subject: sharing subroutines is there a way to share uncompiled perl scripts? that is, to include the subroutines of one script file into another script file. failing that, can i easily compile a perl script and use it in a script? why am i having trouble figuring this out? -- 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sharing subroutines
hmm. i got scared by the perlmod doc. they show a big template to use. and it doesn't have to run through any other program to massage it? and it will be found if the file is in the same directory as the file that calls it? ok. i'll try it. is this an obvious feature that i was unable to grasp from anything i saw online? On Friday, February 22, 2002, at 08:28 PM, Tanton Gibbs wrote: I don't think creating a module is a big deal...how about file Utility.pm: package Utility; sub trim { my $val = shift; $val =~ s/^\s+//; $val =~ s/\s+$//; return $val; } In file user.pl use Utility; while( ) { print Utility::trim( $_ ); } There is a module containing a utility function that is then used by a user script...seems pretty straight forward to me. Naturally, there can be more to it than that, but there doesn't have to be or even need to be in a case like the above. Tanton - Original Message - From: bob ackerman [EMAIL PROTECTED] To: Aaron Shurts [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, February 22, 2002 11:22 PM Subject: Re: sharing subroutines fine, except that creating a module seems like a big deal. you are minimizing the effort when you show me one subroutine as a module. there is a heap of bookkeeping to attend to. the docs indicate that modules are meant to be created and put in public use - i.e., generally of use. i just want a create an application where a few different scripts can all call on some common subroutines. am i making to big a fuss? is creating a module a trivial task? On Friday, February 22, 2002, at 05:12 PM, Aaron Shurts wrote: I am not exactly sure what you are asking, but if I give out the answer yes, in a module. Does that make sense? Kind of like this... # # contents of HelloName.pm # sub hello_name { ($name) = @_; printf(Hello %s\n, $name); } Then in your script you would have something like this... use lib '/src/common'; use HelloName.pm; use strict; my $name = 'Joe'; hello_name($name); -Original Message- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 5:03 PM To: [EMAIL PROTECTED] Subject: sharing subroutines is there a way to share uncompiled perl scripts? that is, to include the subroutines of one script file into another script file. failing that, can i easily compile a perl script and use it in a script? why am i having trouble figuring this out? -- 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sharing subroutines
Almost. i had to add a '1;' at end of module file or i get error: Util.pm did not return a true value at ./pwrk line 5. BEGIN failed--compilation aborted at ./pwrk line 5. other than that - amazingly simple. can't imagine why it was so hard to figure out or even just find an example of. don't other people do these things normally? On Friday, February 22, 2002, at 08:28 PM, Tanton Gibbs wrote: I don't think creating a module is a big deal...how about file Utility.pm: package Utility; sub trim { my $val = shift; $val =~ s/^\s+//; $val =~ s/\s+$//; return $val; } In file user.pl use Utility; while( ) { print Utility::trim( $_ ); } There is a module containing a utility function that is then used by a user script...seems pretty straight forward to me. Naturally, there can be more to it than that, but there doesn't have to be or even need to be in a case like the above. Tanton - Original Message - From: bob ackerman [EMAIL PROTECTED] To: Aaron Shurts [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, February 22, 2002 11:22 PM Subject: Re: sharing subroutines fine, except that creating a module seems like a big deal. you are minimizing the effort when you show me one subroutine as a module. there is a heap of bookkeeping to attend to. the docs indicate that modules are meant to be created and put in public use - i.e., generally of use. i just want a create an application where a few different scripts can all call on some common subroutines. am i making to big a fuss? is creating a module a trivial task? On Friday, February 22, 2002, at 05:12 PM, Aaron Shurts wrote: I am not exactly sure what you are asking, but if I give out the answer yes, in a module. Does that make sense? Kind of like this... # # contents of HelloName.pm # sub hello_name { ($name) = @_; printf(Hello %s\n, $name); } Then in your script you would have something like this... use lib '/src/common'; use HelloName.pm; use strict; my $name = 'Joe'; hello_name($name); -Original Message- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 5:03 PM To: [EMAIL PROTECTED] Subject: sharing subroutines is there a way to share uncompiled perl scripts? that is, to include the subroutines of one script file into another script file. failing that, can i easily compile a perl script and use it in a script? why am i having trouble figuring this out? -- 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Module call/stdin
I am definitely new to Perl - so here is my basic question. I have a module called from a script. I want the script to call the module and pass it a filename. The module will use that filename in the same manner as if it came from the command like (ex. while () { } ). Chip -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Module call/stdin
If I understand your question correctly, then all you want to do is iterate through a list, performing some action on each item. You can just use a foreach loop for this: foreach $file(@files){ Module::Function($file){ do something... } } unless you actually want to do something to the file, in which case it would look more like this: foreach $file(@files){ open(INFILE,$file); while(INFILE){ Module::Function($_); } } or are you saying that the module normally gets its parameters from STDIN, and you want to redirect the output of one part of the script so that the module thinks it's actually coming from user input? -Original Message- From: Chip Dunning To: [EMAIL PROTECTED] Sent: 2/22/02 9:58 PM Subject: Module call/stdin I am definitely new to Perl - so here is my basic question. I have a module called from a script. I want the script to call the module and pass it a filename. The module will use that filename in the same manner as if it came from the command like (ex. while () { } ). Chip -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sharing subroutines
Yes, I always forget the 1...that has to be the most annoying feature with modules. To me there is a big difference between an OOP module and a namespace module (to borrow a term from C++). What you were after was a namespace module, just a place to collect your functions so that they can be reused and don't interfere with other locally defined functions. For that, packages are amazingly simple and effective...there is no real need to use Exporter, because you want the namespace...also inheritance is not needed because you are not using OOP. Most documents describing packages do so from the standpoint of OOP so they miss the critical section of people that don't want complicated OOP stuff, but just want a new namespace. Naturally, we are getting into the more eclectic side of perl, so many people will disagree with my interpretation, but I think you should keep the solution as simple as possible, but no simpler. Glad I could help! Tanton - Original Message - From: bob ackerman [EMAIL PROTECTED] To: Tanton Gibbs [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, February 22, 2002 11:54 PM Subject: Re: sharing subroutines Almost. i had to add a '1;' at end of module file or i get error: Util.pm did not return a true value at ./pwrk line 5. BEGIN failed--compilation aborted at ./pwrk line 5. other than that - amazingly simple. can't imagine why it was so hard to figure out or even just find an example of. don't other people do these things normally? On Friday, February 22, 2002, at 08:28 PM, Tanton Gibbs wrote: I don't think creating a module is a big deal...how about file Utility.pm: package Utility; sub trim { my $val = shift; $val =~ s/^\s+//; $val =~ s/\s+$//; return $val; } In file user.pl use Utility; while( ) { print Utility::trim( $_ ); } There is a module containing a utility function that is then used by a user script...seems pretty straight forward to me. Naturally, there can be more to it than that, but there doesn't have to be or even need to be in a case like the above. Tanton - Original Message - From: bob ackerman [EMAIL PROTECTED] To: Aaron Shurts [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, February 22, 2002 11:22 PM Subject: Re: sharing subroutines fine, except that creating a module seems like a big deal. you are minimizing the effort when you show me one subroutine as a module. there is a heap of bookkeeping to attend to. the docs indicate that modules are meant to be created and put in public use - i.e., generally of use. i just want a create an application where a few different scripts can all call on some common subroutines. am i making to big a fuss? is creating a module a trivial task? On Friday, February 22, 2002, at 05:12 PM, Aaron Shurts wrote: I am not exactly sure what you are asking, but if I give out the answer yes, in a module. Does that make sense? Kind of like this... # # contents of HelloName.pm # sub hello_name { ($name) = @_; printf(Hello %s\n, $name); } Then in your script you would have something like this... use lib '/src/common'; use HelloName.pm; use strict; my $name = 'Joe'; hello_name($name); -Original Message- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 5:03 PM To: [EMAIL PROTECTED] Subject: sharing subroutines is there a way to share uncompiled perl scripts? that is, to include the subroutines of one script file into another script file. failing that, can i easily compile a perl script and use it in a script? why am i having trouble figuring this out? -- 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]