RE: Protected WEB pages in Perl
Hey Alex, I would be great if you could helps us out a little more. What kind of server are you using? IIS? Check the help section of the IIS Management Console: Start Run mmc on how to restrict access to directories. If you want to do the restriction based on cookies then you can use JavaScript, ASP (on IIS), or Perl (perldoc CGI). You can do a search in http://groups.google.com for Perl: CGI Cookies. I actually learned quite a bit through searching google and the book CGI Programming with Perl from O'reilly. HTH, Steven -Original Message- From: Alex Agerholm [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 13, 2002 11:49 PM To: drieux; cgi cgi-list Subject: RE: Protected WEB pages in Perl I mean WEB pages that are protected using some sort of session variables or cookies. The pages are going to run on a platform that does not support .htaccess. Regards Alex -Original Message- From: drieux [mailto:[EMAIL PROTECTED]] Sent: 13. august 2002 15:44 To: cgi cgi-list Subject: Re: Protected WEB pages in Perl On Tuesday, August 13, 2002, at 12:32 , Alex Agerholm wrote: Hi everyone I am new to writing CGI code in Perl and I am going to make some protected WEB pages using Perl. Can anyone direct me to some sample code for making a simple login system and some protected WEB pages ? do you mean webpages that are controlled with say a .htaccess file that does the authentication prior to that URL being accessed? or do you mean webPages that validate that you will be able to access other webPages by means other than through .htaccess??? ciao drieux --- -- 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: Network Programming
what sort of network programming, what do you want to achieve? On Sun, Aug 11, 2002 at 08:45:25PM +, [EMAIL PROTECTED] wrote: Hello there. Do you know where can I find a good Perl Network Programming Tutorial?? Thank you. --- Runbox Mail Manager (free trial version - this tag is removed upon subscription) Try your own premium email account for free at http://111.runbox.com 100MB storage, no ads, fast webmail, access on any device, retrieve and filter email. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Mat Harris OpenGPG Public Key ID: CC14DD34 [EMAIL PROTECTED]matthewh.genestate.i989.net msg06203/bin0.bin Description: PGP Key 0xCC14DD34. msg06203/pgp0.pgp Description: PGP signature
Submitting Form Passes Old Values
I've got what amounts to a control panel or preferences settings system that uses HTML and perl scripts. I'm running this on Mandrake Linux 8.2 with Apache 1.3. I have two pages that interact with each other. The 2nd page, the one I'm having problems with, has a number of checkboxes, drop down menus, and radio buttons. The first time I press Submit, all the values are passed properly to the called perl script. The problem comes in after that. When I use this page again, (both second and later times) and press Submit, the page passes all the form elements (or rather their values) again, but twice. It keeps building, but I'm not sure if it adds another copy of all the values each time I submit the page or not. In other words, I press submit once, I get one set of values, and am returned to a front page. I go from the front page back to the page with the form and press submit again, and I get two sets of the same values. I just keep getting more and more values. How are these values staying in memory? How can I purge them? Thanks. Hal -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: new lines and stupidity
Jimmy -- ...and then Jimmy George said... % % Hello World Hi! % % David pointed out that the \n is not applicable in the context I was in % and that the html br was. Of course! Only silly tired people like me % do dumb things like that after having been using them in text % definitions for the previous hour or more. Don't be so hard on yourself; it happens to us all :-) HAND :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg06205/pgp0.pgp Description: PGP signature
RE: Submitting Form Passes Old Values
Running Perl as a CGI will *not* cache any variables (or anything else). Each time the script is called the Perl executable will be started, and when finished it will free all memory that it was using. If you are using mod_perl it is a little different. mod_perl will cache a script (and any modules used) in memory so that it starts up faster the next time it is called, and it *can* cache variables if your code isn't written with mod_perl in mind. I hope that helps. Rob -Original Message- From: Hal Vaughan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 13, 2002 11:27 PM To: [EMAIL PROTECTED] Subject: Submitting Form Passes Old Values I've got what amounts to a control panel or preferences settings system that uses HTML and perl scripts. I'm running this on Mandrake Linux 8.2 with Apache 1.3. I have two pages that interact with each other. The 2nd page, the one I'm having problems with, has a number of checkboxes, drop down menus, and radio buttons. The first time I press Submit, all the values are passed properly to the called perl script. The problem comes in after that. When I use this page again, (both second and later times) and press Submit, the page passes all the form elements (or rather their values) again, but twice. It keeps building, but I'm not sure if it adds another copy of all the values each time I submit the page or not. In other words, I press submit once, I get one set of values, and am returned to a front page. I go from the front page back to the page with the form and press submit again, and I get two sets of the same values. I just keep getting more and more values. How are these values staying in memory? How can I purge them? Thanks. Hal -- 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: Cache problem in IE
-Original Message- From: Niko Gunadi [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 13, 2002 9:23 PM To: Beginners cgi Subject: Cache problem in IE Hi, I developed an online polling system where ppl can vote online. This voting is done in a computer room where people come down and vote. The problem is the caching problem that happen in IE. For example, I vote in a certain computer then i log off. The next person who uses the computer can still see the my vote by pressing back in IE. How to disable this caching function ? I read that content-pragma:no cache still won't work in IE. any suggestion ? Sending both an Expires and Cache-Control header works well for me: print $q-header(-expires = 'now', '-Cache-Control' = 'no-cache'); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checking Form data
Jim, et al -- ...and then Jim Lundeen said... % % on a side note: does anyone know the % of people that actually disable % javascript in their browser? can javascript actually be used to harm (lets 100% of the people on my computer do :-) % pretend those annoying pop-up windows don't count!)? i'm not really a % hard-core javascript person, so any stats that you have would be interesting % and helpful... thanks! I don't have anything handy, I'm afraid, but I know that my brother wrote a 5-minute hack that will kill any browser running JS a few years ago -- and he's not even a cracker type. It is my understanding that JS cannot actually create/modify/destroy files, but it can read them and transfer data, so at the very least it's a privacy hole. I'm interested in this topic, and particularly interested in just what JS can and cannot do, so please at least keep me in the CC list if this thread goes off-list (which it probably should). HTH HAND :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg06209/pgp0.pgp Description: PGP signature
Re: REMOVE ME from your mailing list!
You guys are being very childish.. I myself have sent an e-mail to the unsubscribe e-mail address on another of my names and it has yet to unsubscribe that e-mail ... so maybe you should realize that it may not be working correctly and not just assume that someone is stupid And yes he has send the unsubscribe e-mail and the same thing happened. nothing ... so maybe in a few years when your balls drop you will have grown up enough to realize there are such things as computer errors.. Chris Marlor Police and Firemen's Insurance Association Programmer/Systems Support Specialist
RE: 7xx's et al
Hi David and thanks True 755 is required for both read and execute by the group and world. But all the directories and html code in my home site are all 744. I have the cgi-bin folder on 711 as that I thought (under Apache anyway) was supposedly only accessible by the owner but the world also required execute to be able to execute a script read out by the owner. http://www.cabonnecreations.com.au/cgibin/test1.cgi is a 711 file and is under that same 711 cgi-bin folder and it works! I am not logging directly into this site though. I am setting default as it were from a remote node. I can only ftp as owner! More thought required here. That code I sent also fails if I call it from a form loaded from the site. So I think there is more that just basic Unix permissions involved here. Yes, it is controlled by apache. When the cgi-script is run, it is run at the user set in the apache config file: -- # User/Group: The name (or #number) of the user/group to run httpd as. # . On SCO (ODT 3) use User nouser and Group nogroup. # . On HPUX you may not be able to use shared memory as nobody, and the #suggested workaround is to create a user www and use that user. # NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET) # when the value of (unsigned)Group is above 6; # don't use Group #-1 on these systems! # User apache_user Group apache_grp -- So even if you have a cgi script with perms 700, you can still run the script from a browser because it runs a 'apache_user' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[ADMIN - THREAD CLOSED] Re: REMOVE ME from your mailing list!
Hey folks, We don't need to have these sort of comments and flames to the list. I had emailed this person off list to give him other ways to unsubscribe (and have not heard back). Many times, people seem to try to unsubscribe from email addresses which aren't the ones subscribed to the list. Although these people shouldn't send emails to the list about it (if you RTFF you can plainly see email addresses of individuals to email), people do not need to then comment about these emails and people on the list. Thanks for your (future) cooperation. If you ever have issues with unsubscribing, you should send an email to [EMAIL PROTECTED], me ([EMAIL PROTECTED]), or Ask ([EMAIL PROTECTED]) with a) what you have tried, and b) what email address you want taken off. Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute, and it's longer than any hour. That's relativity. --Albert Einstein -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
problems with CGI module
HI, I'm having difficulties using the CGI module, I've read over the module but it's not sinking in. Any help would be greatly appreciated -- Pam the html form can be seen at: www.unex.berkeley.edu/test2/av_form.html the output of the form is sent to a file and also emailed the problems I'm having are: 1. Error checking For example: if a user checks on 35mm Slide Projector and does NOT give the Dates Needed I want an error message displayed saying: Dates needed for 35mm Slide Projector Here's how I defined the checkboxes $av_equip = $q - param('av_equip' -name='av_equip', -values=[slide,tvvcr,lcd,boombox,overhead,opaque,flipchart,projection] ); Here's the error checking logic: # Error checking if ($coursetitle eq ) { # A form field is missing data; return an error print $q - h3(), You must enter the course title.; } elsif ($instructor eq ) { # A form field is missing data; return an error print $q - h3(), You must enter your name.; } elsif ($edp eq ) { # A form field is missing data; return an error print $q - h3(), You must enter the course edp number.; } elsif ($av_equip eq slide || tvvcr || lcd || boombox || overhead || opaque || flipchart || projection) { if ($date_slide eq ) { print $q - h3(), Please enter dates needed for 35mm slide projector.; } if ($date_tvvcr eq ) { print $q - h3(), Please enter dates needed for TV/VCR combo.; } } 2. An email will be sent from the drop down menu, but it's not working the html code is: tr td width=100 bgcolor=#FFCC66bExtension Representative: /b/td td width=375 align=left SELECT NAME=send_to OPTION VALUE=Click and pulldown menu/OPTION OPTION VALUE=[EMAIL PROTECTED]Pam Smith/OPTION OPTION VALUE=[EMAIL PROTECTED]Sue Jones/OPTION /SELECT snippet of cgi code is: $tempfile = /tmp/avtemp$$.txt; $send_to = $q - param('send_to'); # E-mail answers: $date = localtime(); if (open(MAIL, $tempfile)) { print MAIL EOF; To: $send_to From: $send_to Subject: AV Request Form -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: problems with CGI module
Hi Pam, On Wed, Aug 14, 2002 at 08:37:46AM -0700, Pam Derks ([EMAIL PROTECTED]) said something similar to: [snip] elsif ($av_equip eq slide || tvvcr || lcd || boombox || overhead || opaque || flipchart || projection) { This is basically like saying: elsif ($foo eq bar || 1 || 1 || 1 || 1) { or elsif (1) { You would want to change this so each part is '$av_eqip eq whatever', or '$av_equip =~ /^(foo|bar|baz|etc)$/' Also, you do not show how you are defining the variables you are checking. You are using param(), correct? Do a 'print $q-dump()', and make sure you are getting the parameters correct. snippet of cgi code is: $tempfile = /tmp/avtemp$$.txt; $send_to = $q - param('send_to'); # E-mail answers: $date = localtime(); if (open(MAIL, $tempfile)) { print MAIL EOF; To: $send_to From: $send_to Subject: AV Request Form Please look at one of the Mail::* modules, or MIME::Lite for sending email. Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Nuclear explosions under the Nevada desert? What the f*ck are we testing for? We already know the sh*t blows up. -- Frank Zappa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: problems with CGI module
Hi Kevin, I've changed per your suggestion to: elsif ($av_equip eq slide) { if ($date_slide eq ) { print $q - h3(), Please enter date needed for 35mm Slide Projector.; } } but the error checking isn't working, i.e. if I've got 35mm checked, the error message isn't being displayed any other ideas? thanks, Pam Kevin Meltzer [EMAIL PROTECTED] 08/14/02 09:17AM Hi Pam, On Wed, Aug 14, 2002 at 08:37:46AM -0700, Pam Derks ([EMAIL PROTECTED]) said something similar to: [snip] elsif ($av_equip eq slide || tvvcr || lcd || boombox || overhead || opaque || flipchart || projection) { This is basically like saying: elsif ($foo eq bar || 1 || 1 || 1 || 1) { or elsif (1) { You would want to change this so each part is '$av_eqip eq whatever', or '$av_equip =~ /^(foo|bar|baz|etc)$/' Also, you do not show how you are defining the variables you are checking. You are using param(), correct? Do a 'print $q-dump()', and make sure you are getting the parameters correct. snippet of cgi code is: $tempfile = /tmp/avtemp$$.txt; $send_to = $q - param('send_to'); # E-mail answers: $date = localtime(); if (open(MAIL, $tempfile)) { print MAIL EOF; To: $send_to From: $send_to Subject: AV Request Form Please look at one of the Mail::* modules, or MIME::Lite for sending email. Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Nuclear explosions under the Nevada desert? What the f*ck are we testing for? We already know the sh*t blows up. -- Frank Zappa -- 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: problems with CGI module
Well, what exactly is the value of $av_equip and $date_slide at this time? Add a few print statments in for debugging, use CGI::dump() to see what is really being passed in. You may not be storing the values you expect in these variables. Cheers, Kevin On Wed, Aug 14, 2002 at 09:28:22AM -0700, Pam Derks ([EMAIL PROTECTED]) said something similar to: Hi Kevin, I've changed per your suggestion to: elsif ($av_equip eq slide) { if ($date_slide eq ) { print $q - h3(), Please enter date needed for 35mm Slide Projector.; } } but the error checking isn't working, i.e. if I've got 35mm checked, the error message isn't being displayed any other ideas? thanks, Pam Kevin Meltzer [EMAIL PROTECTED] 08/14/02 09:17AM Hi Pam, On Wed, Aug 14, 2002 at 08:37:46AM -0700, Pam Derks ([EMAIL PROTECTED]) said something similar to: [snip] elsif ($av_equip eq slide || tvvcr || lcd || boombox || overhead || opaque || flipchart || projection) { This is basically like saying: elsif ($foo eq bar || 1 || 1 || 1 || 1) { or elsif (1) { You would want to change this so each part is '$av_eqip eq whatever', or '$av_equip =~ /^(foo|bar|baz|etc)$/' Also, you do not show how you are defining the variables you are checking. You are using param(), correct? Do a 'print $q-dump()', and make sure you are getting the parameters correct. snippet of cgi code is: $tempfile = /tmp/avtemp$$.txt; $send_to = $q - param('send_to'); # E-mail answers: $date = localtime(); if (open(MAIL, $tempfile)) { print MAIL EOF; To: $send_to From: $send_to Subject: AV Request Form Please look at one of the Mail::* modules, or MIME::Lite for sending email. Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Nuclear explosions under the Nevada desert? What the f*ck are we testing for? We already know the sh*t blows up. -- Frank Zappa -- 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] -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Don't mind your make-up, you'd better make your mind up. -- Frank Zappa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help!! Retrieving Image File
Hello All, I created a simple http upload file routine that uploads file into my accounts sub folder uploads, /home/myaccount/uploads. This is already running. Now what I wanted to do is retrieve the uploaded file from the browser, and display the content in the browser if it is an image or a text/html file, if not then download it. I made a simple code and its not working for the image file, I hope someone here in the list can help me. Here are the sample code that I've tried so far and it didn't work. Kindly please tell me what I missed Code 1: It didnt work... #!/usr/bin/perl use CGI; $query = new CGI; my $filepath='/home/myaccount/uploads/laptop.jpg'; print $query-header('image/jpeg'); print $filepath; Code 2: This code is running ok with text/html files, but not with the images, I hope someone here can help me. #!/usr/bin/perl my $filepath=/home/rce/uploads/drugs.jpg; open(IMAGE, $filepath); binmode IMAGE; print Content-type: image/jpeg\n\n; while(IMAGE){ print; } Thanks in advance Archie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help!! Retrieving Image File
Code 1: It didnt work... #!/usr/bin/perl use CGI; $query = new CGI; my $filepath='/home/myaccount/uploads/laptop.jpg'; print $query-header('image/jpeg'); print $filepath; Of cause, you didn't open the file and read the file. You are trying to print /home/myaccount/uploads/laptop.jpg to the screen, but with a image header. That's fatal error. Code 2: This code is running ok with text/html files, but not with the images, I hope someone here can help me. #!/usr/bin/perl my $filepath=/home/rce/uploads/drugs.jpg; open(IMAGE, $filepath); binmode IMAGE; You also have to binmode the STDOUT print Content-type: image/jpeg\n\n; That should be .../jpeg\r\n\r\n; Rgds, Connie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Better regrex method
Hello, I'm working on a project where I need to split various tag numbers, from a standard set of prefixes, entered into a form and check the number against a database. A sample test code that works, but was wondering if there's a better way to utilize the regrex of this code: # @tags similuate the tag numbers entered into a form, multiple numbers my @tags = qw(K001900 L001234 GP001675); # @prefixs are a pre-determined set of prefixes used. my @prefixs = qw(SP 8 L K GP TP MP); my($tagid,$tnum); print header('text/html'); while(my $prefix = @prefixs) { foreach $tagid (@tags) { if ($tagid =~ m!^$prefix!) { $tagid =~ s!^$prefix!!; print qq|Prefix: $prefix - Number: $tagidbr|; # Results: Prefix: K - Number: 001900 # ...etc } } } My questions is, is there a better way to separate the prefix from the number ?? Any suggest would be much appreciated. TIA, -- Mike(mickalo)Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! http://www.thunder-rain.com Bus Phone: 1(985)902-8484 Cellular: 1(985)320-1191 Fax:1(985)345-2419 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Better regrex method
This works for me... # sample data my @tags = qw(K001900 L001234 GP001675); my @prefixs = qw(SP 8 L K GP TP MP); # join them with pipes for use in the regex my $prefix = join('|', @prefixs); # match prefix against each tag, seprate the parts. # the o switch cause the regex to only compile once. # the split tags go back into the @tag array. my @tags = map {/^($prefix)(.*)$/o;{PRE=$1,NUM=$2}} (@tags); # this print out the prefix/number pairs foreach my $tag (@tags) { print PREFIX: , $tag-{PRE}, \n; print NUMBER: , $tag-{NUM}, \n; print \n; } Something like that? Rob -Original Message- From: Mike(mickako)Blezien [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 2:44 PM To: Perl List Subject: Better regrex method Hello, I'm working on a project where I need to split various tag numbers, from a standard set of prefixes, entered into a form and check the number against a database. A sample test code that works, but was wondering if there's a better way to utilize the regrex of this code: # @tags similuate the tag numbers entered into a form, multiple numbers my @tags = qw(K001900 L001234 GP001675); # @prefixs are a pre-determined set of prefixes used. my @prefixs = qw(SP 8 L K GP TP MP); my($tagid,$tnum); print header('text/html'); while(my $prefix = @prefixs) { foreach $tagid (@tags) { if ($tagid =~ m!^$prefix!) { $tagid =~ s!^$prefix!!; print qq|Prefix: $prefix - Number: $tagidbr|; # Results: Prefix: K - Number: 001900 # ...etc } } } My questions is, is there a better way to separate the prefix from the number ?? Any suggest would be much appreciated. TIA, -- Mike(mickalo)Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! http://www.thunder-rain.com Bus Phone: 1(985)902-8484 Cellular: 1(985)320-1191 Fax:1(985)345-2419 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- 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: Better regrex method
Hi Rob, Yea, I think that would work better, much appreciated ;) Hanson, Rob wrote: This works for me... # sample data my @tags = qw(K001900 L001234 GP001675); my @prefixs = qw(SP 8 L K GP TP MP); # join them with pipes for use in the regex my $prefix = join('|', @prefixs); # match prefix against each tag, seprate the parts. # the o switch cause the regex to only compile once. # the split tags go back into the @tag array. my @tags = map {/^($prefix)(.*)$/o;{PRE=$1,NUM=$2}} (@tags); # this print out the prefix/number pairs foreach my $tag (@tags) { print PREFIX: , $tag-{PRE}, \n; print NUMBER: , $tag-{NUM}, \n; print \n; } Something like that? -Original Message- From: Mike(mickako)Blezien [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 2:44 PM To: Perl List Subject: Better regrex method Hello, I'm working on a project where I need to split various tag numbers, from a standard set of prefixes, entered into a form and check the number against a database. A sample test code that works, but was wondering if there's a better way to utilize the regrex of this code: # @tags similuate the tag numbers entered into a form, multiple numbers my @tags = qw(K001900 L001234 GP001675); # @prefixs are a pre-determined set of prefixes used. my @prefixs = qw(SP 8 L K GP TP MP); my($tagid,$tnum); print header('text/html'); while(my $prefix = @prefixs) { foreach $tagid (@tags) { if ($tagid =~ m!^$prefix!) { $tagid =~ s!^$prefix!!; print qq|Prefix: $prefix - Number: $tagidbr|; # Results: Prefix: K - Number: 001900 # ...etc } } } My questions is, is there a better way to separate the prefix from the number ?? Any suggest would be much appreciated. TIA, -- Mike(mickalo)Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! http://www.thunder-rain.com Bus Phone: 1(985)902-8484 Cellular: 1(985)320-1191 Fax:1(985)345-2419 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
problems with sendmail within a cgi
Hello, i have used cgi-lib for awhile, but have just been given the job of securing my companies perl files and have started using cgi.pm plus all the security restrictions and have come across a problem. I have this code that redirects just fine, gives me no errors, yet will NOT send out the e-mail that is written within the script. IT is running on a AIX machine. Anyone have any ideas on how to get the e-mail to run? i have to rewrite ALL 100+ scripts within my companies cgi-bin within 3 weeks and could REALLY use the help:) #!/usr/bin/perl -wT use strict; use CGI; # test.cgi $CGI::DISABLE_UPLOADS = 1; $CGI::POST_MAX = 102_400; #100 KB; BEGIN { $ENV{PATH} = /bin:/usr/bin; delete @ENV{ qw ( IFS CDPATH ENV BASH_ENV) }; } my $q = new CGI; my $ZipPostalCode = $q-param( ZipPostalCode ) =~ /^ ( [\w+.] ) /; my $FirstName = $q-param( FirstName ) =~ /^ ( [\w+.] ) /; my $recipient = $q-param( recipient ) =~ /^ ( [\w+.] ) /; my $subject = $q-param( subject ) =~ /^ ( [\w+.] ) /; my $referrer = $q-param( referrer ) =~ /^ ( [\w+.] ) /; my $AddName = $q-param( AddName ) =~ /^ ( [\w+.] ) /; print $q-redirect( /campaign/inf/00/thankyou.html ); print /campaign/inf/00/thankyou.html; open MAIL, | '/usr/lib/sendmail' -t -i or die Could not open sendmail: $!; print MAIL EOM; To: cynkim\@yahoo.com From: mememememe\@yahoo.com Reply-To: cynkim\@yahoo.com Subject: Perl security test This is a test, it is only a test EOM close MAIL or die Error closing sendmail: $!; __ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: problems with sendmail within a cgi
A cursory look at the code appears ok, you are positive that there are no errors given, have you tried running it command line?? What does sendmail's log file look like??? The program may be sending to sendmail, it may not be complaining back immediately, but it might be complaining later and not necessarily to you, aka to apache (or whatever user your web server runs as), root, postmaster, or even /dev/null. Do you ever use the values retrieved from the $q-param sections?? http://danconia.org no longer exists wrote: Hello, i have used cgi-lib for awhile, but have just been given the job of securing my companies perl files and have started using cgi.pm plus all the security restrictions and have come across a problem. I have this code that redirects just fine, gives me no errors, yet will NOT send out the e-mail that is written within the script. IT is running on a AIX machine. Anyone have any ideas on how to get the e-mail to run? i have to rewrite ALL 100+ scripts within my companies cgi-bin within 3 weeks and could REALLY use the help:) #!/usr/bin/perl -wT use strict; use CGI; # test.cgi $CGI::DISABLE_UPLOADS = 1; $CGI::POST_MAX = 102_400; #100 KB; BEGIN { $ENV{PATH} = /bin:/usr/bin; delete @ENV{ qw ( IFS CDPATH ENV BASH_ENV) }; } my $q = new CGI; my $ZipPostalCode = $q-param( ZipPostalCode ) =~ /^ ( [\w+.] ) /; my $FirstName = $q-param( FirstName ) =~ /^ ( [\w+.] ) /; my $recipient = $q-param( recipient ) =~ /^ ( [\w+.] ) /; my $subject = $q-param( subject ) =~ /^ ( [\w+.] ) /; my $referrer = $q-param( referrer ) =~ /^ ( [\w+.] ) /; my $AddName = $q-param( AddName ) =~ /^ ( [\w+.] ) /; print $q-redirect( /campaign/inf/00/thankyou.html ); print /campaign/inf/00/thankyou.html; open MAIL, | '/usr/lib/sendmail' -t -i or die Could not open sendmail: $!; print MAIL EOM; To: cynkim\@yahoo.com From: mememememe\@yahoo.com Reply-To: cynkim\@yahoo.com Subject: Perl security test This is a test, it is only a test EOM close MAIL or die Error closing sendmail: $!; __ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Submitting Form Passes Old Values
In other words what Rob is asking ;-) is are you using mod_perl or plain cgi, and in the case of plain CGI, what browser are you using? what version of that browser? and have you tried other browsers, on other OSes, on other computers with what results??? http://danconia.org Hanson, Rob wrote: Running Perl as a CGI will *not* cache any variables (or anything else). Each time the script is called the Perl executable will be started, and when finished it will free all memory that it was using. If you are using mod_perl it is a little different. mod_perl will cache a script (and any modules used) in memory so that it starts up faster the next time it is called, and it *can* cache variables if your code isn't written with mod_perl in mind. I hope that helps. Rob -Original Message- From: Hal Vaughan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 13, 2002 11:27 PM To: [EMAIL PROTECTED] Subject: Submitting Form Passes Old Values I've got what amounts to a control panel or preferences settings system that uses HTML and perl scripts. I'm running this on Mandrake Linux 8.2 with Apache 1.3. I have two pages that interact with each other. The 2nd page, the one I'm having problems with, has a number of checkboxes, drop down menus, and radio buttons. The first time I press Submit, all the values are passed properly to the called perl script. The problem comes in after that. When I use this page again, (both second and later times) and press Submit, the page passes all the form elements (or rather their values) again, but twice. It keeps building, but I'm not sure if it adds another copy of all the values each time I submit the page or not. In other words, I press submit once, I get one set of values, and am returned to a front page. I go from the front page back to the page with the form and press submit again, and I get two sets of the same values. I just keep getting more and more values. How are these values staying in memory? How can I purge them? Thanks. Hal -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: system command to perl variable
On Wed, 14 Aug 2002, Jose Malacara wrote: Hello. I was wondering if there is a way to capture a system command into a perl variable. I know this is incorrect, but I basically want to do something like this: $date = system(date); print Today is $date.; You can use backticks instead, like this $date = `date`; After this you will have to chomp off the newline perldoc -f chomp Try and avoid backticks or system if possible, if you do decide to use them make sure to check the exit status in $? (perldoc perlvar) This particular task of yours can be done using localtime perldoc -f localtime -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help with IO::Socket::INET
on Wed, 14 Aug 2002 02:32:30 GMT, [EMAIL PROTECTED] (Tim Musson) wrote: Ok, can you point me to an example? I have never used that module before, and it has been probably 4 years since I have done something like this. From a browser what would happen is 1. hit the router/switch 2. respond to the userid/pw challenge 3. go to a new page You may want to check out libwww-perl, of which the LWP::UserAgent is a part, at http://search.cpan.org/author/GAAS/libwww-perl-5.65/ and look for 'lwpcook' in the documentation section for several examples of what you need to accomplish. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Uptime on Remote computer?
you could try snmp but that (in my experience) always reports the wrong time if over 2 days. On Sun, Aug 11, 2002 at 01:19:13PM -0800, Mark Weisman wrote: Hello List: What is the command structure to grab an uptime request from a remote computer? I have several systems in my organization that I would like to grab the uptime for, then post them to a dynamic web page. The web page I've already got done, I just need the command structure for grabbing the uptime. Help in grabbing uptime from a Win32 box would be helpful as well. I'm trying to grab data from a group of FreeBSD boxes, and a singular Win2K box. Any suggestions? His humble servant, Mark-Nathaniel Weisman President Outland Domain Group Anchorage,AK USA http://www.outlander.us [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Mat Harris OpenGPG Public Key ID: CC14DD34 [EMAIL PROTECTED]matthewh.genestate.i989.net msg28983/bin0.bin Description: PGP Key 0xCC14DD34. msg28983/pgp0.pgp Description: PGP signature
parsing tripwire logfile
Hi, I want to automate my tripwire log reporting through email but having it send me an email every tem minutes even when it hasn't found anything is a bit annoying. What I want ot do is parse through the viplation statistics and of any of them are greater than 0, THEN email it. Here is an attachement of my script as such and a tripwire report thanks . -- Mat Harris OpenGPG Public Key ID: CC14DD34 [EMAIL PROTECTED]matthewh.genestate.i989.net #!/usr/bin/perl system(/usr/sbin/tripwire --check -r /tmp/tripwire-report.txt); @report = `cat /tmp/tripwire-report.txt`; @rules = (Invariant Directories, Temporary directories, Tripwire Data Files, Critical devices, User binaries, Tripwire Binaries, Critical configuration files, Libraries, Operating System Utilities, Critical system boot files, File System and Disk Administraton Programs, Kernel Administration Programs, Networking Programs, System Administration Programs, Hardware and Device Control Programs, System Information Programs, Application Information Programs, Shell Related Programs, Critical Utility Sym-Links, Shell Binaries, System boot changes, OS executables and libraries, Security Control, Login Scripts, Root config files); $sendmail=0; foreach $reports(@report){ foreach $rule(@rules){ if($reports =~ m/$rule/){ ($rule,$severity,$added,$removed,$modified) = split(/\s{2,}/); if($added 0 || $removed 0 || $modified 0){ $sendmail=1; } } } } if($sendmail ne 0){ open (MAIL,|/usr/lib/sendmail -t -i || die Couldn't open sendmail, $!\n); print MAIL To: root\n; print MAIL From: tripwire daemon\n; print MAIL Subject: Tripwire Alert\n\n; print MAIL @report\n; close MAIL; } msg28984/bin0.bin Description: PGP Key 0xCC14DD34. Parsing policy file: /etc/tripwire/tw.pol *** Processing Unix File System *** Performing integrity check... Wrote report file: /var/lib/tripwire/report/maiden.genestate.com-20020811-211008.twr Tripwire(R) 2.3.0 Integrity Check Report Report generated by: root Report created on:Sun 11 Aug 2002 21:10:08 BST Database last updated on: Sun 11 Aug 2002 15:04:24 BST === Report Summary: === Host name:maiden.genestate.com Host IP address: 127.0.0.1 Host ID: None Policy file used: /etc/tripwire/tw.pol Configuration file used: /etc/tripwire/tw.cfg Database file used: /var/lib/tripwire/maiden.genestate.com.twd Command line used:tripwire --check === Rule Summary: === --- Section: Unix File System --- Rule Name Severity LevelAddedRemoved Modified - ------ Invariant Directories 66000 Temporary directories 33000 Tripwire Data Files 100 000 Critical devices100 000 User binaries 66000 Tripwire Binaries 100 000 Critical configuration files100 000 Libraries 66000 Operating System Utilities 100 000 Critical system boot files 100 000 File System and Disk Administraton Programs 100 000 Kernel Administration Programs 100 000 Networking Programs 100 000 System Administration Programs 100 000 Hardware and Device Control Programs 100 000 System Information Programs 100 000 Application Information Programs
open file into hash
Hello. I was wondering if there was a way to open a file into a hash? I know this works for arrays, but was wondering if I this could be done for a hash also. I have a file called people.data, which contains two colums: jose2 karen 8 jason 9 tracey 1 Can someone tell me what I am doing wrong here: = #! /usr/bin/perl -w open (INPUT, people.data); %people = INPUT; close (INPUT); #%people = ( #jose = '2', #karen = '8', #jason = '9', #tracey = '1' #); print The value for jose is $people{jose}\n; = I expect to return the value of 2, but see the following error instead: Use of uninitialized value in concatenation (.) or string at ./new.pl line 14. The value for jose is I am guessing that this is related to opening the filehandle as it works if I declare the hash within the script (commented out above). Any help would be greatly appreciated. Jose -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: open file into hash
On Wed, 14 Aug 2002, Jose Malacara wrote: Hello. I was wondering if there was a way to open a file into a hash? I know this works for arrays, but was wondering if I this could be done for a hash also. I have a file called people.data, which contains two colums: jose 2 karen 8 jason 9 tracey1 Can someone tell me what I am doing wrong here: = #! /usr/bin/perl -w open (INPUT, people.data); %people = INPUT; By doing this you are reading all the lines of your file into memory. This statement finally boils down to %people = (jose2\n,karen 8\n...); When you do this the list is evaluated 2 elements at a time with the first element becoming the hash key and the second the value. Finally your hash will look this %people = ( 'jose 9 ' = 'karen 8 ' ...); As you can see the odd numbered lines of your file become the hash keys and the even numbered lines the hash values. Take a look at Data::Dumper to see the kind of data structure you have created. perldoc Data::Dumper This will do what you want while (INPUT) { my @fields = split; # perldoc -f split $people{$fields[0]} = $fields[1]; } close (INPUT); #%people = ( #jose = '2', #karen = '8', #jason = '9', #tracey = '1' #); print The value for jose is $people{jose}\n; = I expect to return the value of 2, but see the following error instead: Use of uninitialized value in concatenation (.) or string at ./new.pl line 14. The value for jose is This is because the key jose is not present in your hash and you have turned warnings on. This is a good thing and also add this line to the top your script use strict; If you want associate a hash with a file take look at perldoc -f tie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: open file into hash
on Wed, 14 Aug 2002 07:35:29 GMT, [EMAIL PROTECTED] (Jose Malacara) wrote: I have a file called people.data, which contains two colums: jose 2 karen 8 jason 9 tracey 1 Can someone tell me what I am doing wrong here: #! /usr/bin/perl -w open (INPUT, people.data); %people = INPUT; close (INPUT); print The value for jose is $people{jose}\n; I expect to return the value of 2, but see the following error instead: Use of uninitialized value in concatenation (.) or string at ./new.pl line 14. The value for jose is It is useful to analyze what's happening when you execute your program: When you write '%people = INPUT;, INPUT is evaluated in list context, meaning that INPUT will produce a list consisting of all the lines in your input-file. This list looks as follows (I removed some whitespace for brevity): (jose 2\n, karen 8\n, jason 9\n, tracey 1\n) (Also note the presence of the newlines). When you assign this list to the %people hash, you take (key,value)- pairs from this list, so you will have: $people{jose 2\n } = karen 8\n; $people{jason 9\n} = tracey 1\n; Which is not what you want. The following program will do what you want: #!/usr/bin/perl -w use strict; my %people = (); open (INPUT, people.data) or die Cannot open file: $!; while(my $line = INPUT) { chomp($line); # remove trailing \n my ($name, $number) = split , $line; $people{$name} = $number; } close (INPUT); print The value for jose is $people{jose}\n; The main part of the program is in the while loop, where we read each line in succession (until there are no more lines), remove the trailing newline, and then split this line into a name and number part, which we then feed to the hash. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: parsing tripwire logfile
On Sun, 11 Aug 2002, Mat Harris wrote: Hi, I want to automate my tripwire log reporting through email but having it send me an email every tem minutes even when it hasn't found anything is a bit annoying. What I want ot do is parse through the viplation statistics and of any of them are greater than 0, THEN email it. Here is an attachement of my script as such and a tripwire report The violation statistics are the one's under the added, removed and modified columns or just the one at end that says Total violations found: 0 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: open file into hash
Hi: By first changing the % sign to a $ sign and then removing {jose} in the print line I got it to work. I tested it in both Windows and Linux environments with the same results. #! /usr/bin/perl -w open (INPUT, people.data); $people = INPUT; close (INPUT); print The value for jose is $people\n; Hope this helps. Have a great day; Andy - Original Message - From: Jose Malacara [EMAIL PROTECTED] To: Perl beginners [EMAIL PROTECTED] Sent: Wednesday, August 14, 2002 12:35 AM Subject: open file into hash Hello. I was wondering if there was a way to open a file into a hash? I know this works for arrays, but was wondering if I this could be done for a hash also. I have a file called people.data, which contains two colums: jose 2 karen 8 jason 9 tracey 1 Can someone tell me what I am doing wrong here: = #! /usr/bin/perl -w open (INPUT, people.data); %people = INPUT; close (INPUT); #%people = ( #jose = '2', #karen = '8', #jason = '9', #tracey = '1' #); print The value for jose is $people{jose}\n; = I expect to return the value of 2, but see the following error instead: Use of uninitialized value in concatenation (.) or string at ./new.pl line 14. The value for jose is I am guessing that this is related to opening the filehandle as it works if I declare the hash within the script (commented out above). Any help would be greatly appreciated. Jose -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: parsing tripwire logfile
On Wed, 14 Aug 2002, Sudarshan Raghavan wrote: On Sun, 11 Aug 2002, Mat Harris wrote: Hi, I want to automate my tripwire log reporting through email but having it send me an email every tem minutes even when it hasn't found anything is a bit annoying. What I want ot do is parse through the viplation statistics and of any of them are greater than 0, THEN email it. Here is an attachement of my script as such and a tripwire report The violation statistics are the one's under the added, removed and modified columns or just the one at end that says Total violations found: 0 Does this work for you #!/usr/local/bin/perl -w use strict; open (TRIPLOG, /tmp/tw-rep.txt) or die Cannot /tmp/tw-rep.txt for reading : $!\n; while (TRIPLOG) { if ((/^\s+Rule Name/ ... /^\n$/) /\d/) { my ($add, $rem, $mod) = (split)[-3, -2, -1]; if ($add 0 || $rem 0 || $mod 0) { print Violations found\n; # You can do your sendmail part here } } } close (TRIPLOG); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: open file into hash
On Wed, 14 Aug 2002, Andy Anderson wrote: Hi: By first changing the % sign to a $ sign and then removing {jose} in the print line I got it to work. I tested it in both Windows and Linux environments with the same results. The % specifies that the identifier is a hash and the $ means it is a scalar. When you do a %people = INPUT you filehandle operator is evaluated in a list context, i.e. all the lines in your file are read in at once. When your filehandle operator is evaluated in a scalar context only the next line is read in. #! /usr/bin/perl -w open (INPUT, people.data); Forgot to mention in my reply to the OP too, when you open a file you should always check for failure. open (INPUT, people.data) or die Failed to open people.data: $!\n; $people = INPUT; At this point $people contains 'jose 2'. When you say you removed 'jose' from the print line do you mean from the file itself, I am sorry you are not allowed to do that. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: News from Prague
flooded. See you all when the water is down :-) Jenda The water is still going up, but the power is still on in our office. I did not go to work yesterday because they said noone should go to the center, but I could have. It seems we are safe here, It's strange how important a tiny height difference can become. I've never noticed the Narodni trida (street) actually does go up a little and that we are a bit higher here still. The rescue system seems to work perfectly so I do not expect there to be any casualties in Prague, but we are all afraid for the houses and bridges. I don't know if you've heard, but there is a boat just above the Charles bridge, there are three tanks/armored cars trying to hold it. if the steel wire ropes break we've HAD a bridge. I hope all is well for everybody and hope the water stops uprising at last. Later, 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: timing delays
Thanks for all the leads and suggestions. I couldn't quite wrap my mind around making select() work for what I want but Time::HiRes works great. Joe On Tue, 2002-08-13 at 14:55, drieux wrote: On Tuesday, August 13, 2002, at 12:20 , Joe Mecklin wrote: I'm trying to send a file as a remote configuration download via telnet in a Perl script (using net::telnet). I need to introduce sub-second delays between sending each line so the receiving system doesn't get confused. Sleep only goes down to a single second; is there something that can inject sub-second delays (module, command, arg to net::telnet, whatever)? http://search.cpan.org/author/JHI/perl-5.8.0/ext/Time/HiRes/HiRes.pm http://search.cpan.org/author/DEWEG/Time-HiRes-01.20/HiRes.pm might be a part of what you are looking for... ciao drieux --- CPAN can be your friend -- 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: Uptime on Remote computer?
Here is a script I use to check system up time. You can specify a remote server as an argument and it will remotely check the uptime for that server. This goes into the perfmon stats and gets the information from there. Keith --cut here- #!c:/perl/bin # # * SystemUpTime.pl * # * Copyright (C) 1998 by Jutta M. Klebe 010398 JK * # * All rights reserved. LU: 250898 JK * # # * $Author:: Jmk $ * # * $Date:: 25.08.98 23:02 $ * # * $Archive:: /Jmk/scripts/saa/SystemUpTime.pl$ * # * $Revision:: 2 $ * # use Win32::PerfLib; ($machine) = @ARGV; $perf = new Win32::PerfLib($machine); if(!$perf) { die Can't open PerfLib of $machine!\n; } my $objlist = {}; my $system = 2; if($perf-GetObjectList($system, $objlist)) { $perf-Close(); my $Counters = $objlist-{Objects}-{$system}-{Counters}; foreach $o ( keys %{$Counters}) { $id = $Counters-{$o}-{CounterNameTitleIndex}; if($id == 674) { $Numerator = $Counters-{$o}-{Counter}; $Denominator = $objlist-{Objects}-{$system}-{PerfTime}; $TimeBase = $objlist-{Objects}-{$system}-{PerfFreq}; $counter = int(($Denominator - $Numerator) / $TimeBase ); $seconds = $counter; $day = int($seconds/(60*60*24)); $seconds %=60*60*24; $hour = int($seconds/(60*60)); $seconds %=60*60; $minute = int($seconds/60); $seconds %=60; $backday=localtime(time-$counter); print \t$counter total seconds\n; print \t$day day(s) $hour hour(s) $minute minute(s) $seconds second(s)\n; print \tSystem was last started on $backday\n; last; } } } # # $History: SystemUpTime.pl $ # # * Version 3 * # User: Kbm Date: 28.02.2002 Time: 09:02 # Added line to show you what day the system was rebooted. # # * Version 2 * # User: Jmk Date: 25.08.98 Time: 23:02 # Updated in $/Jmk/scripts/saa # fixed bug in Win32::PerfLib module. This showed a bug in this script. # Denominator and Timebase weren't correct. # # * Version 1 * # User: Jmk Date: 26.05.98 Time: 8:20 # Created in $/Jmk/scripts/saa # Retrieve the system up time for any (NT) computer # -cut here- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help with IO::Socket::INET
On Tue, 13 Aug 2002 22:08:47 -0400, [EMAIL PROTECTED] (Tim Musson) wrote: ### The next line is where I think I am having problems... ### If I uncomment, I seem to recall it displaying the html code from ### above (HTTP/1.0 200 OK, etc...). But what happens is it just hangs. # while ( $remote ) { print; } print $remote; close $remote; It works for me if I comment out the print $remote and uncomment the while ( $remote ) { print; } while ( $remote ) { print; } #print $remote; close $remote; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help with IO::Socket::INET
Hey zentara, My MUA believes you used to write the following on Wednesday, August 14, 2002 at 8:20:39 AM. z It works for me if I comment out the print $remote and z uncomment the while ( $remote ) { print; } Grrr, I just tried a different http server, and it works just fine... Thanks! -- [EMAIL PROTECTED] Using The Bat! eMail v1.61 Windows 2000 5.0.2195 (Service Pack 2) What does this red button do? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How does ZOMBIE/defunct affect the system?
-Original Message- From: Sudarshan Raghavan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 7:49 AM To: Perl beginners Subject: Re: How does ZOMBIE/defunct affect the system? On Tue, 13 Aug 2002, Ahmed Moustafa wrote: Ahmed Moustafa wrote: Drieux wrote: use POSIX :sys_wait_h; #... do { $kid = waitpid(-1,WNOHANG); } until $kid == -1; Does the execution of the program wait to all the forked processes to terminate? Perl Cookbook says We use the WNOHANG flag to make waitpid immediately return 0 if there are no dead children. Yes WNOHANG makes waitpid return immediately the -1 means wait for any child process. This code will do a non-blocking wait for all child processes. So, the above code doesn't pause the program, does it? It will be in the do-until loop until all of it's children are dead. perldoc -f waitpid This example is straight out of perldoc -f waitpid, but if it's used as-is, I don't see the point. Why do a non-blocking wait, when the do loop effectively blocks the program anyway. You only want non-blocking when you have something else to do. I would write the above as: 1 while wait != -1; # wait for all children Or am I missing something? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Reading Data From simicolon delimited file
Hi all Please i need a help. My problem is that i need to read a csv file format that contain an arabic data and generate and html page that contains the data, using cgi script writen in perl, the text file is under solaris system running apache server. the text file was uploaded into the server using binary transfer type, the data when directly opened looks ok. but when the page is generated the data looks chunck. comparisons are not also working. Shiine _ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl from command line documentation
found this with a google search, looks ok, hth http://www.codebits.com/p5be/ch17.cfm -Original Message- From: Mario [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 13, 2002 5:09 PM To: [EMAIL PROTECTED] Subject: Perl from command line documentation Hi all! I'm triying to replace my awk habits with perl, but I wonder if there is any place where I can find samples and/or documentation about how to run perl from the command line. Normally I work in Unix. For example with awk I used to get a column from the ps or ls -l command. Any comment is welcome. Best Regards Mario -- 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: News from Prague
On Wednesday, August 14, 2002, at 03:33 , Jenda Krynicky wrote: psycho_rant This of course would not happen if you had used java rather than trying to do this in perl. Since while there is a Time::Warp module - there is no Water::Go::Away module in the CPAN /psycho_rant [..] I hope all is well for everybody and hope the water stops uprising at last. [..] you will forgive the small grammar flame here rant well these sort of things did not happen under the old regime when there was a simple method for dealing with 'uprisings'... but did anyone listen to the Komsomol about what would happen if the party fell!!! NO Everyone wanted this sort of chicago-gangsterism /rant ciao drieux --- being an old school tie sorta conservative has it's compensations from time to time -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: timing delays
On Wednesday, August 14, 2002, at 04:21 , Joe Mecklin wrote: Thanks for all the leads and suggestions. I couldn't quite wrap my mind around making select() work for what I want but Time::HiRes works great. Joe [..] http://search.cpan.org/author/JHI/perl-5.8.0/ext/Time/HiRes/HiRes.pm http://search.cpan.org/author/DEWEG/Time-HiRes-01.20/HiRes.pm On Aug 13, john offered us: The select function can be used for this. perldoc -f select [snip] You can effect a sleep of 250 milliseconds this way: select(undef, undef, undef, 0.25); p0: technically I like john's basic thesis - since it is what you are sorta wanting - and would not require the Time::HiRes module p1: when you are concerned about any option proposed there are two basic strategies 1.1: code up the idea - see if it flies 1.2: code up the alternative and compare it p2: never be afraid to install Mind::Bender as it will help with managing the warpage that perl can cause just remember that when you are installing it in your neural pathways to have a friend around in case any of the make test sequences fail - since rebooting a brain can be a really ugly thing ciao drieux http://www.wetware.com/drieux/pbl/ -- the voices in my head make me write these things -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: News from Prague
[off topic] I think drieux has finally lost it. What *it* is, I do not know. Don't know if I have *it* either. -Original Message- From: drieux [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 10:36 AM To: begin begin Subject: Re: News from Prague On Wednesday, August 14, 2002, at 03:33 , Jenda Krynicky wrote: psycho_rant 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: News from Prague
I thought Coke was it... -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 4:43 PM To: 'drieux'; begin begin Subject: RE: News from Prague [off topic] I think drieux has finally lost it. What *it* is, I do not know. Don't know if I have *it* either. -Original Message- From: drieux [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 10:36 AM To: begin begin Subject: Re: News from Prague On Wednesday, August 14, 2002, at 03:33 , Jenda Krynicky wrote: psycho_rant 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: open file into hash
Thanks to all who replied with the useful advice. I really appreciate the help. Thanks! Jose - Original Message - From: Tor Hildrum [EMAIL PROTECTED] To: [EMAIL PROTECTED]; Perl [EMAIL PROTECTED] Sent: Wednesday, August 14, 2002 3:53 AM Subject: Re: open file into hash [EMAIL PROTECTED] wrote: I have a file called people.data, which contains two colums: jose2 karen8 jason9 tracey1 Can someone tell me what I am doing wrong here: = #! /usr/bin/perl -w open (INPUT, people.data); %people = INPUT; Not what you want. foreach (INPUT) { ($key, $var) = split(/\s+/, $_); $hash{$key} = $var; } Or similar. Tor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Can CPAN upgrade perl?
This might be a dumb question, but it's probably a beginner's one. How can I use CPAN to upgrade perl itself? I think this is possible, because it's happened to me inadvertently when I was trying to upgrade a module. I've tried 'install perl' and 'install perl5.8.0' but neither works. Is this a dumb question because cpan only upgrades modules? If so, to upgrade perl, do I just download the source, compile and install it? Thanks for your help. -Kevin Zembower -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: News from Prague
On Wednesday, August 14, 2002, at 07:43 , Nikola Janceski wrote: [off topic] I think drieux has finally lost it. What *it* is, I do not know. Don't know if I have *it* either. [..] well it's not like you have to be Franz Kafka to figure it out you go to bed with a copy of the 3rd Edition of programming perl, and you wake up in the morning hoping to still be the same person or had all the information done a bit of metamorphosis Or maybe you are reading all about the apocalypse and where perl6 is going and you notice that much of the dialog looks like out takes from 'the trial' ciao drieux --- http://www.levity.com/corduroy/kafka.htm will help those who are not as clear on why - or who kafka was - and may not be able to see the clear and intuitively obvious connection between kafka-eqsue and Perl all that Lord of the Rings stuff is all a part of the SINISTER KONSPIRKII to cover up the true literary roots of perl Now Even Mother Nature is trying to get in on the Plot to Cover it all Up -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: perl2exe
Hi, I have been using it for quite some time and never had a problem. I am using it on Win NT platform Let me know if you need further assistance A wild guess would be install perl again probably thanks junaid -Original Message- From: Scott Barnett [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 13, 2002 9:57 AM To: [EMAIL PROTECTED] Subject: perl2exe Hi, I am try to create a .exe with perl2exe on a Win32 platform and keep getting the BSOD or freeze ups. I been to indigostar's site to try to dig up a troubleshooting page, but no luck. Has anyone else had problems with perl2exe. Thanks, Scott Barnett Home Care Medical - Technical Support Specialist 1-800-369-6939 1-262-786-9870 ext.214 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]
[OT] RE: News from Prague
on Wed, 14 Aug 2002 14:53:47 GMT, [EMAIL PROTECTED] (Timothy Johnson) wrote: I thought Coke was it... -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 4:43 PM To: 'drieux'; begin begin Subject: RE: News from Prague [off topic] I think drieux has finally lost it. What *it* is, I do not know. Don't know if I have *it* either. -Original Message- From: drieux [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 10:36 AM To: begin begin Subject: Re: News from Prague Guys, I am truly shocked by your behaviour in this thread. One of our nice colleagues and regulars at perl.beginners takes the effort to report about the precarious condition in his (home?) town, (which you undoubtly have witnessed from your comfortable tv-couch), and all you think about is making jokes. Shame on you. Jenda, I hope the water stops rising soon (although the latest news doesn't seem that optimistic), and that everything stays well for you and your loved ones. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
New to Perl...
Hello, all I need to learn Perl fast, have some C and 4GL background. What is the best way for me to start? I have 2 books that I have started looking at. Programming Perl by Wall, Christiansen Schwartz and Perl Cookbook by Christiansen Torkington. I can download softwares into my PC, but I have to ftp over to my Solaris box from my PC. What do I need to get started playing around with Perl? Any suggestions would be most appreciated! Thanks. Tang Kim 256.722.4283 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl from command line documentation
On Tuesday, August 13, 2002, at 05:09 , Mario wrote: [..] I'm triying to replace my awk habits with perl, p0: perldoc a2p will give you all sorts of information about the 'a2p' application that is reasonable at how to deal with converting 'awk' scripts into perl code. a way of looking at that can be sorta seen with say: http://www.wetware.com/drieux/pbl/misc/sh_to_perl.txt since what you will want to become aware of is how to do things with 'split' cf: perldoc -f split but be forewarned I have little patience for doing what, well, ok, what I did early on: http://www.wetware.com/drieux/pbl/Weird/bloopers/slovenA2P.txt since, well it was just stoopidly simpler to slovenly use a2p to make perl like scripts from awk stuff - and then just cut and paste it into the script where I needed it... [..] For example with awk I used to get a column from the ps or ls -l command. p1: here you will need to get into more of the gory details of how to do 'perl as perl' - cf perldoc perl as the 'root' of the online information p2: my general list of URL's for doing fun with perl is http://www.wetware.com/drieux/pbl/perldoc/ you will find some of the on-line tutorials there p3: in the main perl does not require that you be Franz Kafka to figure it out but there are places where IT IS DANGEROUS!!! IT IS A BEAST!!! 'Run Away!' - m.python ciao drieux http://www.wetware.com/drieux/pbl/ -- This space left intentionally blank. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: New to Perl...
On Wednesday, August 14, 2002, at 08:27 , Kim, Tang (N-Raytheon) wrote: [..] I have 2 books that I have started looking at. Programming Perl by Wall, Christiansen Schwartz and Perl Cookbook by Christiansen Torkington. reasonably good choices to start with. You might want to fetch a) learning perl - 3rd edition b) the pocket guide to programming perl 3rd edition you can also read most of perl's internal documentation with perldoc perl and run through the basic information that is already there. I can download softwares into my PC, but I have to ftp over to my Solaris box from my PC. if you are running Solaris 8 or higher, it comes with perl 5.005_03 installed - and you will want to get on the road from there - learn a bit and then opt to get into the upgrade path to perl 5.8... ciao drieux http://www.wetware.com/drieux/pbl/perldoc where I hide the rest of the links to what I know about perl documentation that can be found on line. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: New to Perl...
on Wed, 14 Aug 2002 15:27:43 GMT, [EMAIL PROTECTED] (Tang Kim) wrote: I need to learn Perl fast, have some C and 4GL background. What is the best way for me to start? I have 2 books that I have started looking at. Programming Perl by Wall, Christiansen Schwartz and Perl Cookbook by Christiansen Torkington. I can download softwares into my PC, but I have to ftp over to my Solaris box from my PC. What do I need to get started playing around with Perl? Any suggestions would be most appreciated! Thanks. You probably also want to take a look at O'Reilly's Learning Perl (By Schwartz Phoenix). If you have previous programming experience you could probably go through it in a couple of days to get a feeling for the language. After that, the Camel will give you all the details, whereas the Cookbook is invaluable for solid example code. If you have the choice between Unix/Win32 platforms, pick the one that you will be developing for after you mastered the language. Perl is available for both, and although a lot of it is platform independent, there are some differences. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] RE: News from Prague
On Wednesday, August 14, 2002, at 08:24 , Felix Geerinckx wrote: [..] Shame on you. [..] p0: I can appreciate the emotional reaction - since I think that all of us went through that phase of dealing with the thought that jenda might no longer be in play - IF things go 'really bad'. Such would be a blow to US as a community. { although I think it might be really harder on jenda } p1: try to remember that this is neither the first natural or man-made disaster to strike the international community. And the perl community - as an 'internet' group is an international community. p2: some here may be able to recall when the tanks rolled into Praha to 'liberate' it from the threat of the dupchek (sp) regime cf: http://lists.village.virginia.edu/lists_archive/sixties-l.old/0409.html so this is not our first time around the barrel for 'crisis in praha'... { I rather doubt that we have that many here who remember the days when it became an independent republic... but, you never know } p3: relax, calm down remember that one of the important duties in life is to know when to send in the clowns Comedy is a Dangerous Art Form - which is why we do not attempt to write programs that attempt it... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl from command line documentation
Mario wrote: Hi all! I'm triying to replace my awk habits with perl, but I wonder if there is any place where I can find samples and/or documentation about how to run perl from the command line. Normally I work in Unix. For example with awk I used to get a column from the ps or ls -l command. Any comment is welcome. Best Regards Mario We have a course called Minimal Perl for the Impatient that is designed exactly for people like you! It teaches a specially crafted dialect of Perl that gives maximal power with minimal learning, and allows you to program in the Pattern/Action model popularized by AWK, the second greatest programming language. Apart from the one-day commercial course (next scheduled for 8/30 in Seattle; see http://teachmeperl.com/minperl.html), we also have a half-day conference version that you can download for free. It's at http://teachmeperl.com/mp_pr.html; the version currently available there is the one from the Amsterdam 2001 YAPC conference, but later this week the updated version from the St. Louis 2002 YAPC will appear there. Enjoy! 8-} ** | Tim Maher, CEO, CONSULTIX (206) 781-UNIX; (866) DOC-PERL; (866) DOC-LINUX | | JAPH, JAWCAR (Just Another White Camel Award Recipient) | | [EMAIL PROTECTED] teachmeunix.com teachmeperl.com teachmelinux.net | | 8/26: Perl+Modules 9/18: Int Perl 9/23: Shell Utilities OCT: mjd ? | ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How does ZOMBIE/defunct affect the system?
-Original Message- From: Ahmed Moustafa [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 11:45 AM To: Bob Showalter; 'Sudarshan Raghavan'; Perl beginners Subject: Re: How does ZOMBIE/defunct affect the system? ... All I need to do is to reap the dead processes without blocking the program. (Also I don't want to ignore the children with using $SIG{CHLD} = 'IGNORE';). Then you should call wait() inside a SIGCHLD handler. That's what SIGCHLD is for. See the examples in perldoc perlipc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
scripting .pl files in Windows
I'm very very new at Perl. I have a question regarding Perl scripting on Windows. I'm using library books to learn and most of the examples are for UNIX My question is: After writing a .pl file in a text editor, is it neccessary to make it executable using the command: chmod +x example.pl ? I don't think the book is suggesting to make a .pl file into an .exe file. Is this step something that is neccessary for UNIX but not for Windows? As it stands now, all my .pl files are associated with ActiveState perl. When i double click on them, the perl window opens and displays the output for only a fraction of a second before it closes. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: scripting .pl files in Windows
-Original Message- From: Beans [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 1:30 PM To: [EMAIL PROTECTED] Subject: scripting .pl files in Windows I'm very very new at Perl. I have a question regarding Perl scripting on Windows. I'm using library books to learn and most of the examples are for UNIX My question is: After writing a .pl file in a text editor, is it neccessary to make it executable using the command: chmod +x example.pl ? Not on Windows. That's a UNIX thing to allow the kernel to run an interpreter script. It also requires the #!/usr/bin/perl line at the top of the script for this to work properly on UNIX. On Windows, this is handled through associations. I don't think the book is suggesting to make a .pl file into an .exe file. Is this step something that is neccessary for UNIX but not for Windows? Correct. UNIX only. As it stands now, all my .pl files are associated with ActiveState perl. When i double click on them, the perl window opens and displays the output for only a fraction of a second before it closes. I think ActiveState has a FAQ on this, but you basically need to insert some kind of pause at the end of your script, or run your script from a command prompt window. The pause could be something as simple as: print Press ENTER to continue: ; STDIN; At the end of your program. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: scripting .pl files in Windows
On Wednesday, August 14, 2002, at 10:29 , Beans wrote: [..] Is this step something that is neccessary for UNIX but not for Windows? [..] If you are planning to have your *.pl file run 'on its own' rather than with perl foo.pl then you will need to set the execute bits on the unix side. there is a way that you can 'translate' your *.pl into *.exe with tools from the Active State. you may also want to look into using the Perl TK modules if you are planning to write windows specific Gui tools - rather than 'command line/dos command/cygwin' style executables. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Printing in windows
Anyone figure out how to trigger a nice, MFC-like printing dialogue in Windows? And use an associated API to produce printer output? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help!! Retrieving Image File
Hello All, I created a simple http upload file routine that uploads file into my accounts sub folder uploads, /home/myaccount/uploads. This is already running. Now what I wanted to do is retrieve the uploaded file from the browser, and display the content in the browser if it is an image or a text/html file, if not then download it. I made a simple code and its not working for the image file, I hope someone here in the list can help me. Here are the sample code that I've tried so far and it didn't work. Kindly please tell me what I missed Code 1: It didnt work... #!/usr/bin/perl use CGI; $query = new CGI; my $filepath='/home/myaccount/uploads/laptop.jpg'; print $query-header('image/jpeg'); print $filepath; Code 2: This code is running ok with text/html files, but not with the images, I hope someone here can help me. #!/usr/bin/perl my $filepath=/home/rce/uploads/drugs.jpg; open(IMAGE, $filepath); binmode IMAGE; print Content-type: image/jpeg\n\n; while(IMAGE){ print; } Thanks in advance Archie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help!! Retrieving Image File
Code 1: It didnt work... #!/usr/bin/perl use CGI; $query = new CGI; my $filepath='/home/myaccount/uploads/laptop.jpg'; print $query-header('image/jpeg'); print $filepath; Of cause, you didn't open the file and read the file. You are trying to print /home/myaccount/uploads/laptop.jpg to the screen, but with a image header. That's fatal error. Code 2: This code is running ok with text/html files, but not with the images, I hope someone here can help me. #!/usr/bin/perl my $filepath=/home/rce/uploads/drugs.jpg; open(IMAGE, $filepath); binmode IMAGE; You also have to binmode the STDOUT print Content-type: image/jpeg\n\n; That should be .../jpeg\r\n\r\n; Rgds, Connie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: scripting .pl files in Windows
Hey Beans, My MUA believes you used to write the following on Wednesday, August 14, 2002 at 1:29:57 PM. B I'm very very new at Perl. I have a question regarding Perl B scripting on Windows. I'm using library books to learn and most of B the examples are for UNIX B My question is: B After writing a .pl file in a text editor, is it neccessary to make it B executable using the command: B chmod +x example.pl ? Not on Win32, that is a unix only thing. B I don't think the book is suggesting to make a .pl file into an .exe file. Correct B Is this step something that is neccessary for UNIX but not for Windows? Correct again B As it stands now, all my .pl files are associated with ActiveState perl. B When i double click on them, the perl window opens and displays the output B for only a fraction of a second before it closes. Well, that is good as far as it goes. Try dropping to a cmd window and running it there. So if you have mycode.pl you should be able to just run 'mycode'. btw, you need to be in the same dir to do that... dir mycode.pl should list your file... The reason it closes is perl is running in a command window. So it opens the window, runs your code, then when your code is completed, it closes the command window. Another thing you could do is put a 'sleep 30' statement at the end of your code. -- [EMAIL PROTECTED] Using The Bat! eMail v1.61 Windows 2000 5.0.2195 (Service Pack 2) use Perl; \ program \ fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash, query-param help
...only the categories for which they have a value This is probably the easiest way. # this will set the value to '' if the key doesn't exist my $email_county = $counties{$query-param('County')}-{County} || ''; And how do I wrap this so the user will select a county I'm not sure I understand this one. Can you explain what you mean? Rob -Original Message- From: Gregg O'Donnell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 2:43 PM To: [EMAIL PROTECTED] Subject: Hash, query-param help I'm writing a script to send emails to different locations. Some will receive one email, others 3 or 4. Should each county have all the categories, even if some have an empty value, or only the categories for which they have a value. And how do I wrap this so the user will select a county my %counties = ( Accomack = { Region = '[EMAIL PROTECTED]', County = '', Abbrev = 'ACC', }, Albemarle = { Region = '[EMAIL PROTECTED]', County = '[EMAIL PROTECTED]', Engr = '[EMAIL PROTECTED]', Abbrev = 'ALB', }, Alleghany = { Region = '[EMAIL PROTECTED]', County = '[EMAIL PROTECTED]', Abbrev = 'ALL', ); # Selected County: return EMAIL ADDRESS my $email_county = $counties{$query-param('County')}-{County}; # Selected County: return REGION EMAIL ADDRESS my $email_region = $counties{$query-param('County')}-{Region}; # Selected County: return ABBREVIATION my $county_abbrev = $counties{$query-param('County')}-{Abbrev}; # Selected County: return ENGINEER EMAIL ADDRESS my $email_engr = $counties{$query-param('County')}-{Engr}; #How do I wrap this so they select a county my $counties{$query-param('County')}-{County} if($query-param('County'){} Thanks, GPO - Do You Yahoo!? HotJobs, a Yahoo! service - Search Thousands of New Jobs -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
possible RFC?
WTF doesn't perl -c check for valid subroutines/function calls? I can write a perlscript calling a function that doesn't exist but perl -c will say syntax ok. ie: % perl -ce nothing_here('some junk') -e syntax OK % perl -e nothing_here('some junk') Undefined subroutine main::nothing_here called at -e line 1. That doesn't make sense! It should check function calls at compile time, correct? So why not for -c? Excuse me if I have overstepped my bounds. I still love Perl regardless, but it can be better. Nikola Janceski The significant problems we face today cannot be solved at the same level of thinking we were at when we created them. -- Albert Einstein (1879-1955) PS. I still drool over the apocalypse papers on Perl 6. I can't wait! 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: Hash, query-param help
If the user doesn't select a county in the first place, $query-param('County') will be undefined, which means that $counties{$query-param('County')}-{County} will be an error. So I think I need some code to handle this using something like if($query-param('County'){} I'm just stuck. Hanson, Rob wrote: ...only the categories for which they have a value This is probably the easiest way. # this will set the value to '' if the key doesn't exist my $email_county = $counties{$query-param('County')}-{County} || ''; And how do I wrap this so the user will select a county I'm not sure I understand this one. Can you explain what you mean? Rob -Original Message- From: Gregg O'Donnell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 2:43 PM To: [EMAIL PROTECTED] Subject: Hash, query-param help I'm writing a script to send emails to different locations. Some will receive one email, others 3 or 4. Should each county have all the categories, even if some have an empty value, or only the categories for which they have a value. And how do I wrap this so the user will select a county my %counties = ( Accomack = { Region = '[EMAIL PROTECTED]', County = '', Abbrev = 'ACC', }, Albemarle = { Region = '[EMAIL PROTECTED]', County = '[EMAIL PROTECTED]', Engr = '[EMAIL PROTECTED]', Abbrev = 'ALB', }, Alleghany = { Region = '[EMAIL PROTECTED]', County = '[EMAIL PROTECTED]', Abbrev = 'ALL', ); # Selected County: return EMAIL ADDRESS my $email_county = $counties{$query-param('County')}-{County}; # Selected County: return REGION EMAIL ADDRESS my $email_region = $counties{$query-param('County')}-{Region}; # Selected County: return ABBREVIATION my $county_abbrev = $counties{$query-param('County')}-{Abbrev}; # Selected County: return ENGINEER EMAIL ADDRESS my $email_engr = $counties{$query-param('County')}-{Engr}; #How do I wrap this so they select a county my $counties{$query-param('County')}-{County} if($query-param('County'){} Thanks, GPO - Do You Yahoo!? HotJobs, a Yahoo! service - Search Thousands of New Jobs - Do You Yahoo!? HotJobs, a Yahoo! service - Search Thousands of New Jobs
Re: possible RFC?
One reason is that you can make runtime use/require calls, as well as run-time function definitions with eval. For example use strict; my $subname = 'contrived'; eval qq(sub $subname { print This could be useful\n }); contrived(); This may seem highly contrived (it is), but there are useful examples of this as well, for instance in making factory classes. George Nikola Janceski wrote: WTF doesn't perl -c check for valid subroutines/function calls? I can write a perlscript calling a function that doesn't exist but perl -c will say syntax ok. ie: % perl -ce nothing_here('some junk') -e syntax OK % perl -e nothing_here('some junk') Undefined subroutine main::nothing_here called at -e line 1. That doesn't make sense! It should check function calls at compile time, correct? So why not for -c? Excuse me if I have overstepped my bounds. I still love Perl regardless, but it can be better. Nikola Janceski The significant problems we face today cannot be solved at the same level of thinking we were at when we created them. -- Albert Einstein (1879-1955) PS. I still drool over the apocalypse papers on Perl 6. I can't wait! 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: possible RFC?
On Wed, Aug 14, 2002 at 02:53:49PM -0400, Nikola Janceski wrote: WTF doesn't perl -c check for valid subroutines/function calls? Because it's quite possible to define subs dynamically. That is, the sub isn't defined directly in your code, but is created (and installed) after your code has started execution. This is a frequently used technique in some kinds of development. Look into AUTOLOAD for more details. Z. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: possible RFC?
-Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 2:54 PM To: Beginners (E-mail) Subject: possible RFC? WTF doesn't perl -c check for valid subroutines/function calls? I can write a perlscript calling a function that doesn't exist but perl -c will say syntax ok. ie: % perl -ce nothing_here('some junk') -e syntax OK % perl -e nothing_here('some junk') Undefined subroutine main::nothing_here called at -e line 1. That doesn't make sense! It should check function calls at compile time, correct? No, otherwise CGI.pm and tons of other stuff would never work. So why not for -c? Consider the following program: $_ = 'sub foo { print Hello World\n }'; eval $_; foo(); foo() is not defined a compile-time, but it's still a perfectly valid program. Because of this, perl -c cannot check the call to foo() at compile-time. Thinking of perl -c as a compiler is a bit of a misnomer. Just for kicks, wrap the code above in a BEGIN { } block and run perl -c on it. See what I mean? Excuse me if I have overstepped my bounds. I still love Perl regardless, but it can be better. No way! :~) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash, query-param help
Are you looking for something like this? # UNTESTED! my $county = $query-param('County'); if ( ! $county ) { # no county was passed. # display error page to the user, or ignore the request. } elsif ( ! exists($counties{$county}) ) { # they sent a county, but we have no data for it. # show error page, or just ignore. } else { # we only get here if things went well my $email_county = $counties{$county}-{County}; my $email_region = $counties{$county}-{Region}; my $county_abbrev = $counties{$county}-{Abbrev}; my $email_engr = $counties{$county}-{Engr}; # ...or we can save some space with this, # depending on your needs. It grabs all values # with an @ and adds them to a list of email # addresses. ...This assumes that you only need # the email addresses and don't care what the # hash key is. my @emails = grep {/\@/} (values %{$counties{$county}}); my $county_abbrev = $counties{$county}-{Abbrev}; # send mails (or whatever) here } Is that what you were looking for? ...Or am I seriously missing the point? Rob -Original Message- From: Gregg O'Donnell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 3:20 PM To: [EMAIL PROTECTED] Subject: RE: Hash, query-param help If the user doesn't select a county in the first place, $query-param('County') will be undefined, which means that $counties{$query-param('County')}-{County} will be an error. So I think I need some code to handle this using something like if($query-param('County'){} I'm just stuck. Hanson, Rob wrote: ...only the categories for which they have a value This is probably the easiest way. # this will set the value to '' if the key doesn't exist my $email_county = $counties{$query-param('County')}-{County} || ''; And how do I wrap this so the user will select a county I'm not sure I understand this one. Can you explain what you mean? Rob -Original Message- From: Gregg O'Donnell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 2:43 PM To: [EMAIL PROTECTED] Subject: Hash, query-param help I'm writing a script to send emails to different locations. Some will receive one email, others 3 or 4. Should each county have all the categories, even if some have an empty value, or only the categories for which they have a value. And how do I wrap this so the user will select a county my %counties = ( Accomack = { Region = '[EMAIL PROTECTED]', County = '', Abbrev = 'ACC', }, Albemarle = { Region = '[EMAIL PROTECTED]', County = '[EMAIL PROTECTED]', Engr = '[EMAIL PROTECTED]', Abbrev = 'ALB', }, Alleghany = { Region = '[EMAIL PROTECTED]', County = '[EMAIL PROTECTED]', Abbrev = 'ALL', ); # Selected County: return EMAIL ADDRESS my $email_county = $counties{$query-param('County')}-{County}; # Selected County: return REGION EMAIL ADDRESS my $email_region = $counties{$query-param('County')}-{Region}; # Selected County: return ABBREVIATION my $county_abbrev = $counties{$query-param('County')}-{Abbrev}; # Selected County: return ENGINEER EMAIL ADDRESS my $email_engr = $counties{$query-param('County')}-{Engr}; #How do I wrap this so they select a county my $counties{$query-param('County')}-{County} if($query-param('County'){} Thanks, GPO - Do You Yahoo!? HotJobs, a Yahoo! service - Search Thousands of New Jobs - Do You Yahoo!? HotJobs, a Yahoo! service - Search Thousands of New Jobs -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: scripting .pl files in Windows
As it stands now, all my .pl files are associated with ActiveState perl. When i double click on them, the perl window opens and displays the output for only a fraction of a second before it closes. I suggest you better associate your perl script with a text editor rather then the perl.exe. Becasue your coding time would probrably more than your testing time. On the other hand, try to run your script in the 'dosprmpt'. However, if you want your assoication as is, you cantry either one of the below at the last of your script, to freeze the screen after the script runs to end : 1. exec pause; 2. system pause; 3. `pause`; 4. STDIN; Rgds, Connie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: possible RFC?
Okay I understand the dynamic subroutine declarations. but perhaps a warning should be made for -w or 'use warnings'? It's just to find misspelled functions. I use 'use strict' for finding misspelled vars. Is there nothing for finding misspelled functions, aside from running it and hoping for the best? Nikola Janceski What counts is not necessarily the size of the dog in the fight - it's the size of the fight in the dog. -- Dwight D. Eisenhower 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: open file into hash
Jose Malacara wrote: Hello. I was wondering if there was a way to open a file into a hash? I know this works for arrays, but was wondering if I this could be done for a hash also. I have a file called people.data, which contains two colums: jose2 karen 8 jason 9 tracey 1 Can someone tell me what I am doing wrong here: = #! /usr/bin/perl -w use strict; open (INPUT, people.data); open INPUT, 'people.data' or die Cannot open 'people.data': $!; %people = INPUT; my %people = map split, INPUT; close (INPUT); #%people = ( #jose = '2', #karen = '8', #jason = '9', #tracey = '1' #); print The value for jose is $people{jose}\n; = John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Executing script invisibly
Hello, I am using Javascript (body onload) to execute a script automatically as a page loads, but this ends up redirecting the page to the URL of the script. Is there a way to have a script execute but prevent the user from being directed away from the home page? Much thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Executing script invisibly
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 3:56 PM To: [EMAIL PROTECTED] Subject: Executing script invisibly Hello, I am using Javascript (body onload) to execute a script automatically as a page loads, but this ends up redirecting the page to the URL of the script. Is there a way to have a script execute but prevent the user from being directed away from the home page? Make your script run from one of those one-pixel web bug things. But many people find those things offensive and try to block them. What is your script doing? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Executing script invisibly
Is there a way to have a script execute but prevent the user from being directed away from the home page? You could load it in an image tag... img src=/cgi-bin/myscript.cgi height=1 width=1 It might show as a broken image in some browsers. To fix that you could have the script send a 1 pixel image to the browser. print Content-type: image/gif\n\n; open IN, 'image.gif'; binmode IN; print while IN; close IN; I use something like that for tracking views. Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 3:56 PM To: [EMAIL PROTECTED] Subject: Executing script invisibly Hello, I am using Javascript (body onload) to execute a script automatically as a page loads, but this ends up redirecting the page to the URL of the script. Is there a way to have a script execute but prevent the user from being directed away from the home page? Much 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: New to Perl...
I tried to view the perldoc and received the following error message: :/usr/local/binperldoc perl Can't locate warnings.pm in @INC (@INC contains: /usr/local/lib/perl5/5.00503/aix /usr/local/lib/perl 5/5.00503 /usr/local/lib/perl5/site_perl/5.005/aix /usr/local/lib/perl5/site_perl/5.005 .) at /usr/local/bin/perldoc line 5. BEGIN failed--compilation aborted at /usr/local/bin/perldoc line 5. I looked in perldoc line 5 and found the following: use warnings; The file warnings.pm is not located in the /usr/local/bin directory. Is this the problem? I tried to talk with the Unix Admin, but he is unavailable since he quit Friday. Thanks for reading. PK Ennis -Original Message- From: drieux [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 10:36 AM To: begin begin Subject: Re: New to Perl... On Wednesday, August 14, 2002, at 08:27 , Kim, Tang (N-Raytheon) wrote: [..] I have 2 books that I have started looking at. Programming Perl by Wall, Christiansen Schwartz and Perl Cookbook by Christiansen Torkington. reasonably good choices to start with. You might want to fetch a) learning perl - 3rd edition b) the pocket guide to programming perl 3rd edition you can also read most of perl's internal documentation with perldoc perl and run through the basic information that is already there. I can download softwares into my PC, but I have to ftp over to my Solaris box from my PC. if you are running Solaris 8 or higher, it comes with perl 5.005_03 installed - and you will want to get on the road from there - learn a bit and then opt to get into the upgrade path to perl 5.8... ciao drieux http://www.wetware.com/drieux/pbl/perldoc where I hide the rest of the links to what I know about perl documentation that can be found on line. -- 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: How does ZOMBIE/defunct affect the system?
- Original Message - From: Bob Showalter [EMAIL PROTECTED] To: 'Ahmed Moustafa' [EMAIL PROTECTED]; Perl beginners [EMAIL PROTECTED] Sent: Wednesday, August 14, 2002 10:08 AM Subject: RE: How does ZOMBIE/defunct affect the system? -Original Message- From: Ahmed Moustafa [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 14, 2002 11:45 AM To: Bob Showalter; 'Sudarshan Raghavan'; Perl beginners Subject: Re: How does ZOMBIE/defunct affect the system? ... All I need to do is to reap the dead processes without blocking the program. (Also I don't want to ignore the children with using $SIG{CHLD} = 'IGNORE';). Then you should call wait() inside a SIGCHLD handler. That's what SIGCHLD is for. See the examples in perldoc perlipc. When I put something in the SIGCHLD handler, the calls to system() return 'No child processes'! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Executing script invisibly
- Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 15, 2002 3:56 AM Subject: Executing script invisibly Hello, I am using Javascript (body onload) to execute a script automatically as a page loads, but this ends up redirecting the page to the URL of the script. Is there a way to have a script execute but prevent the user from being directed away from the home page? That depends on what is your script doing. Only suggestion : 1. print the whold page with your script. 2. activate your script at another frame. 3. use SSI , shtml like method. 4. Don't even use javascript. Activate your script by a zero height:width IMG tag. Rgds, Connie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: possible RFC?
Adam == Adam Turoff [EMAIL PROTECTED] writes: Adam On Wed, Aug 14, 2002 at 02:53:49PM -0400, Nikola Janceski wrote: WTF doesn't perl -c check for valid subroutines/function calls? Adam Because it's quite possible to define subs dynamically. That is, Adam the sub isn't defined directly in your code, but is created (and Adam installed) after your code has started execution. This is a Adam frequently used technique in some kinds of development. Look into Adam AUTOLOAD for more details. Or even require. And that's pretty durn frequent. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: system() retuens -1
On Wed, Aug 14, 2002 at 08:38:06AM -0700, Ahmed Moustafa wrote: $! says 'No child processes'. Does that have something to do with having $SIG{CHLD} = 'IGNORE'; in the code? Yes, that is probably the reason. However, I cannot duplicate your problem with perl v5.6.1. Are you using an older version, or perhaps doing something else, such as calling wait() yourself? The only way I was able to encounter a similar problem was with this code: #!/usr/bin/perl -wl $SIG{CHLD} = 'IGNORE'; print system(cat /dev/null); print wait(); print $?; print $!; The code prints the following: 0 -1 -1 No child processes The system() call does not return -1, but the wait() does, and it set $? to -1. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
unable to parse html
Hail, I'm stuck with this parsing script, (attached) I found on perlmonks.org. I've got Lemay's SAMS 21 day and O'reily's 2rd edition. My Perl experience is just modifying a config file from the plethora of free scripts to now finally trying to modify a script to accomplish the following task. I'd like to import the contents of over 3k html files, between the tags body to /body after I've grepped out the header and footer !-includes- into a table cell in the new templates I'm creating for the site. I'm stuck on the error: 'unable to parse' line: $content = $header_html . $1 . $footer_html; I defined $header_html and $footer_html. Pointing to actual html header and footer files. obliged, Stretch __ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com parsehtml.pl Description: parsehtml.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
unable to parse html
--- batch m [EMAIL PROTECTED] wrote: Date: Wed, 14 Aug 2002 15:23:50 -0700 (PDT) From: batch m [EMAIL PROTECTED] Subject: unable to parse html To: [EMAIL PROTECTED] Hail, I'm stuck with this parsing script, (attached) I found on perlmonks.org. I've got Lemay's SAMS 21 day and O'reily's 2rd edition. My Perl experience is just modifying a config file from the plethora of free scripts to now finally trying to modify a script to accomplish the following task. I'd like to import the contents of over 3k html files, between the tags body to /body after I've grepped out the header and footer !-includes- into a table cell in the new templates I'm creating for the site. I'm stuck on the error: 'unable to parse' line: $content = $header_html . $1 . $footer_html; total script === # opens up original HTML and inserts # into template html. and mirrors the other # files that it doesn't parse #!/usr/bin/perl -w use strict ; use warnings ; $|++ ; #Define variables ## #Directory to parse (with trailing slash) my $open_dir = 'C:/My Documents/carlist/carlist_test/'; #Directory to save parsed documents to (with trailing slash) my $save_dir = 'C:/My Documents/carlist/carlist_test/parsed/'; #Location of template HTML file my $html_file = 'C:/My Documents/carlist/carlist_test/template/newtemplate.html'; #Extensions allowed to parse my @exts = ('html','htm','shtml','shtm'); my $exts; my $ext; my $header_html= 'C:/My Documents/carlist/carlist_test/template/ccheader.html'; my $footer_html= 'C:/My Documents/carlist/carlist_test/template/ccfooter.html'; my $title; #Used to find html files to replace use File::Find; #Used to copy files to new location use File::Copy; #Assists in copying path directory structure use File::Path; #Starts the actual code main(); exit; #Just in case of any accidents sub eachFile { my $filename = $_; my $fullpath = $File::Find::name; #remember that File::Find changes your CWD, #so you can call open with just $_ my $found = 0; foreach $ext (@exts) { if($filename=~/\.$ext$/) { print \tOpening file $filename - ; my $content = open_file($filename); print Completed\n; if($content=~m|TITLE(.*)/TITLE|si) { $title = $1; } else{ $title = www.carlist.com - List your used car for sale for FREE with the longest running used car database in the world.; } print \t\tParsing Document - ; if($content=~m|BODY.*?(.*?)/BODY|si) { $content = $header_html . $1 . $footer_html; $content =~ s|%title%|$title|; save_file($fullpath,$content); print Completed\n; } else{ print Couldn't parse\n; } $found = 1; last; #So it doesn't reopen it with similar extension } } if($found==0) { my $dir = $fullpath; $dir=~s/\Q$open_dir\E/$save_dir/i; #Removes current root dir, and replaces it with new one copy($fullpath,$dir); } } #Returns the contents of a filename specified... sub open_file{ my($file) = @_; my($file_contents) = ; open(DATA,$file) || die Not Completed\n; while(DATA) { $file_contents .= $_; } close(DATA); return($file_contents); } #Saves the new file to its new location sub save_file{ my($file,$file_contents) = @_; $file=~s/$open_dir/$save_dir/i; #Removes current root dir, and replaces it with new one my($dir) = $file; if($dir =~ /(.*)\/.*/) {$dir = $1;} if(!(-e $dir/)) { mkdir($dir/,0755); } open(DATA,$file) || die Cannot saved parse document\n; print DATA $file_contents; close(DATA); } sub main{ #Retrieves HTML for template print Opening Template - ; open(FILE,$html_file) || die Cannot open HTML because $!; my $data = join('',FILE); close(FILE); #Please let them be global variables ($header_html,$footer_html) = split(/\%content\%/,$data); print Successful\n; #Copys directory structure of old to new one... print Copying Directory Path - ; mkpath([$open_dir, $save_dir], 1, 0711); print Successful\n; #Starts the actual File Search Replace print Starting Search and Replace - \n; find (\eachFile, $open_dir); print Successful\n; } === I defined $header_html and $footer_html. Pointing to actual html header and footer files. obliged, Stretch __ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] RE: News from Prague
remember that one of the important duties in life is to know when to send in the clowns Well said, I must say I wondered momentarily how my post about his dealer would go over, but I felt that those of us half way around the globe might be able to provide a smile in an otherwise bad time (especially since that is about all we can provide, other than perl help). And while we ignorant americans sit here (and I am speaking for most of us, not all of us (we do this well too)) only knowing one spoken language, we must make jokes about his only slightly broken english to cover our own inadequacies in foreign relations Lord knows he speaks better english than most of the people here in my state (Indiana), and much better than the athletes that are so oft interviewed on the tube during half time or such of some sporting event, and I won't even start in on my Jack Edwards rant.. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: New to Perl...
On Wednesday, August 14, 2002, at 02:00 , Paul Ennis wrote: I tried to view the perldoc and received the following error message: :/usr/local/binperldoc perl Can't locate warnings.pm in @INC (@INC contains: /usr/local/lib/perl5/5.00503/aix /usr/local/lib/perl 5/5.00503 /usr/local/lib/perl5/site_perl/5.005/aix /usr/local/lib/perl5/site_perl/5.005 .) at /usr/local/bin/perldoc line 5. BEGIN failed--compilation aborted at /usr/local/bin/perldoc line 5. I looked in perldoc line 5 and found the following: use warnings; this is really strange - since it apears that you have a mostly dis combobulated install there since If I recall correctly use warnings does not come out until perl5.6... cf: [jeeves:/System/Library/Perl] drieux% perldoc -q warnings Found in /System/Library/Perl/pods/perlfaq7.pod How do I temporarily block warnings? If you are running Perl 5.6.0 or better, the `use warn- ings' pragma allows fine control of what warning are pro- duced. See the perllexwarn manpage for more details. but your @INC line up there suggests that you are running the 5.00503 version - on an aix platform. so you may want to do a 'which perl' as there may be more than one of them installed ls -li /usr/bin/perl /usr/local/bin/perl The file warnings.pm is not located in the /usr/local/bin directory. correct - that is not your problem - that @INC listing is where that version of perl thinks that the 'things to include' are suppose to be: /usr/local/lib/perl5/5.00503/aix /usr/local/lib/perl5/5.00503 /usr/local/lib/perl5/site_perl/5.005/aix /usr/local/lib/perl5/site_perl/5.005 normally you would find that the 'warnings.pm' file would be in an upper layer like /usr/local/lib/perl5/5.00503 which is WAY squirrelly since it does not come into existence till the next release - eg: 5.6.0 - but you will want to bring in 5.6.1, as there is no more access to the original 5.6.0 version itself. I tried to talk with the Unix Admin, but he is unavailable since he quit Friday. oye are you the only cat who is 'hot footing' perl at your site??? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Processing Special Characters in email
Hi, I wrote a perl script to automatically process incoming email by setting it up in .forward file. One of its function is to get the data from the email and save it to a file, which can be validated and processed to generate a report. One issue came up with is that when an email that contains person's name like Waalvåg Scott or Mike Øyvind, the perl script doesn't print them correctly, meaning, the names is not saved in the file correctly. I disabled .forward setup and just send an email that contains the special character names to my mailbox on the system (unix), I checked /var/mail/user and it doesn't have correct names saved there either. It must be something to do with configuration in the mail system, but not sure. I really appreciate it if you can shed some light here on how to save the names correctly in a file. Thanks much in advance!!! Regards, Scott __ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How does ZOMBIE/defunct affect the system?
Ahmed Moustafa [EMAIL PROTECTED] wrote: From: Bob Showalter [EMAIL PROTECTED] [ waitpid() in tight loop ] This example is straight out of perldoc -f waitpid, but if it's used as-is, I don't see the point. Why do a non-blocking wait, when the do loop effectively blocks the program anyway. You only want non-blocking when you have something else to do. I would write the above as: 1 while wait != -1; # wait for all children Or am I missing something? All I need to do is to reap the dead processes without blocking the program. (Also I don't want to ignore the children with using $SIG{CHLD} = 'IGNORE';). Why not? I mean, I admire dedicated parents, but (most) *nix systems will reap them *for you* if you ignore SIGCHLD. #!/usr/bin/perl $SIG{CHLD} = 'IGNORE'; fork || exit for 1..100; sleep 2; print waited $x\n until ($x = wait) == -1; print Done!\n; If your flavor doesn't support this then you'll usually wait() in the signal handler: #!/usr/bin/perl $SIG{CHLD} = sub { wait }; ... But in general, unless you're going to do something useful with the exit status, $SIG{CHLD} = 'IGNORE' is exactly what you want. -- Steve perldoc -qa.j | perl -lpe '($_)=m((.*))' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RPC modules ???
Hi falks, Does anyone know of a way I can send RPC to my server ?? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: New to Perl...
Paul Ennis [EMAIL PROTECTED] wrote: I tried to view the perldoc and received the following error message: :/usr/local/binperldoc perl Can't locate warnings.pm in @INC (@INC contains: /usr/local/lib/perl5/5.00503/aix /usr/local/lib/perl 5/5.00503 /usr/local/lib/perl5/site_perl/5.005/aix /usr/local/lib/perl5/site_perl/5.005 .) at /usr/local/bin/perldoc line 5. BEGIN failed--compilation aborted at /usr/local/bin/perldoc line 5. I looked in perldoc line 5 and found the following: use warnings; The file warnings.pm is not located in the /usr/local/bin directory. Is this the problem? No... it would go in the @INC directories listed above. But what a mess. The perldoc in your PATH doesn't match the perl in its shebang line. (There were no 'warnings' in 5.005_03.) Anyway, assuming you want to use 5.6.1, I would: 1) copy that perldoc to ~/bin or someplace 2) put that directory first in your PATH 3) find the 5.6.1 perl 4) and fix your copy of perldoc so the shebang points at it I tried to talk with the Unix Admin, but he is unavailable since he quit Friday. Funny. -- Steve perldoc -qa.j | perl -lpe '($_)=m((.*))' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Compare dates
Hello List, How do I compare two dates in the format: Thu Aug 15 2002 15:12:02 to return if one date is higher than the other. Does anyone have any ideas on suitable modules, most the date modules I have looked at dont deal with this date format. Any help or pointers would be great. Thanks Shane -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Sending emails as html pages.
Hi there, I have a script that it's output is a html page. How can i send the html page exactly how it is?, the contents like the one that is on the web server. It is something like the emails we receive from red hat brim , oracle and others companies. Thanks. Joe __ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]