Re: regex help
Well only you can be the judge if you are doing it right. But what that expression tells me is: $string matches, starting with either ( a word, a dot, a hyphen, a at sign, a colon, a plus sign, a question mark, a bang) one or more times, and ending in one of the afore mentioned. So if that is what you want to check for then my guess is that you are correct, however I would also check for ';' and '' and '' but then you have all you're control characters to look out for, and you also have to watch out for the back tick. My suggestion would be to use #!/usr/bin/perl -w -T Then scan to see if it contains the characters you do want, not the ones you don't. I would guess that the characters you will allow is much simplier than the ones you won't. my( $string ) =~ $q-param( string ) =~ /^([\w.])$/; unless ($string) { print BERROR, invalid characters used.! Character = $string/BBR; exit; } Just my two cents. Jeff On 2001.08.23 00:48 Sergio Gonzalez wrote: Can anyone tell me if i'm doing this right? #check for dangerous characters unless ($string =~ /^[\w .-\@:+?!]+$/) { print BERROR, invalid characters used.! Character = $string/BBR; exit; } thank you, Sergio Gonzalez -- 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: File upload problems still!
Roger C Haslock wrote: Just an aside, but what is the point of format = 'Application/msword' ? Anyone can rename their file to look like '*.doc', and you can only determine the file content when you have uploaded it ( at which point you SHOULD check). not to mention you may offend those non-micro$oft users whose resumes are plain text. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: File upload problems still!
Roger C Haslock wrote: Just an aside, but what is the point of format = 'Application/msword' ? Anyone can rename their file to look like '*.doc', and you can only determine the file content when you have uploaded it ( at which point you SHOULD check). not to mention you may offend those non-micro$oft users whose resumes are plain text. In the end, they are going to put on a resume CD, with a VB front end, and Word is used to do keyword searches, and about 100% of the population involved have their resumes in word anyway. --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: File upload problems still!
Roger C Haslock wrote: Just an aside, but what is the point of format = 'Application/msword' ? Anyone can rename their file to look like '*.doc', and you can only determine the file content when you have uploaded it ( at which point you SHOULD check). not to mention you may offend those non-micro$oft users whose resumes are plain text. In the end, they are going to put on a resume CD, with a VB front end, and Word is used to do keyword searches, and about 100% of the population involved have their resumes in word anyway. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: File upload problems still!
--- Ryan Davis [EMAIL PROTECTED] wrote: Curtis+List, I checked out the CGI::Safe.pm module, and so far, I'm having the same problem. The script goes to Just about to get your resume!; then quits. I don't have access to server logs, so I don't know what is going on. I think my server is running Apache, and I've been snooping to try and find the config files (I got a find / -name httpd.conf going right now) Is there anything perlish wrong here? It works on Activestate/Apache/Win98, so I think it must be a server thing, but I dunno. What do you mean by then quits? Does it silently fail? Does it hang? Does it return an error message? Wild guess: Recently (like, two days ago), I had a problem with a script that worked fine on a Windows box but then mysteriously 'hung' on a Linux box. It was caused by the same problem that I had for my recent question about my script dying when I turned off warnings: Windows and Unix have different line endings. Since you mentioned that you had successfully run this on a Win98 box, I'm wondering if this is the problem. Windows recognizes \12\15 as the end of line characters (\r\n). Unix is looking for a \15 (\n). If you have shell access to your server, enter the following: cat -vet script.cgi | more This will display the end of line characters as a dollar sign. If you see a ^M before the dollar sign, then you know you have DOS line endings. Here's an example: #!/usr/bin/perl -wT^M$ If you see that ^M, (ctrl-M, a.k.a. ASCII 12, a.k.a. \r), you can eliminate it with the following in-place edit: perl -pi -e 's/\r//g' script.cgi Just make sure to back up your script, first. To prevent this in the future, make sure you FTP your scripts to the server in ASCII mode, not binary. ASCII mode will fix the line endings for you. If this doesn't resolve the problem, let us know. Cheers, Curtis Poe = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) Ovid on http://www.perlmonks.org/ __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
CGI::POST_MAX use and control
Hi all, I would appreciate some guidance in the use of CGI::POST_MAX. I've listed a snippet of relevant code below from my program to illustrate. When reading in data fields from an HTML form, I want to limit the size of the data accepted from a TEXTAREA box. I don't want to depend upon my ISPs timeouts and what-nots to stop a user from trying a DDOS on 'em. The current incarnation of my script blows itself out of the water if the $user_body variable (the TEXTAREA source) is greater than 4K, for example. This is good. I would like to be able to capture and control the process so that I don't get rudely blown out of the water with a crude 500 Server message (this would be gooder! g). I would like to: a)generate a useful message and, b) set some flags, do some more processing, and send a message back to the user to give them an opportunity to correct their input and atone for their sins. (This would be more gooder! g) I've read through the CGI.pm writeup, but I don't believe I'm applying it correctly. I am having a problem understanding just how and where to make use of CGI::POST_MAX, CGI::Carp, and probably cgi_error() in my code. Where do I put 'em and can someone demonstrate with a similar snippet of code just how and where these are used? For example, when this bombs with data 4096 bytes, I don't even see an error message in my error log file, ...cgi-log.txt -- that would be a nice diagnostic help, too. If there is another prefered method to limit size of input, I would appreciate learning about that, too! Right now my code produces an 'accurate' result (a nuke will 'accurately' kill a fly), but I would prefer to have it produce a 'precise' result (perhaps a HOW-TO on using tightly focused gamma rays to zap that fly, instead). It works, but its not elegant. I'm looking for the state of most goodliness. g (My apologies to non-native English readers of this list for my having fun with the language, but its been a tough day...) Thanks, all. John-- [EMAIL PROTECTED] === #!/usr/bin/perl use strict; #use diagnostics; use CGI qw/:standard/; use CGI::Carp qw/fatalsToBrowser/; BEGIN { use CGI::Carp qw(carpout); open(LOG, $ENV{DOCUMENT_ROOT}/data/cgi-log.txt) or die(Unable to open $ENV{DOCUMENT_ROOT}/data/cgi-log.txt: $!\n); carpout(LOG); } $CGI::POST_MAX = 1024 * 4; ## Max 4K post size $CGI::DISABLE_UPLOADS = 1; ## Disable file uploads $formin = new CGI; $user_name = ' '; $user_addr = ' '; $user_to = ' '; $user_subj = ' '; $user_body = ' '; $user_name = $formin-param('name'); $user_addr = $formin-param('from'); $user_to = $formin-param('to'); $user_subj = $formin-param('subject'); $user_body = $formin-param('body'); ## If good form data ## process the form's input...and do good things... ## else ## create return HTML page and tell user where they've transgressed... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: File upload problems still!
cat -vet script.cgi | more ^M's galore. The 'auto' setting on WS_ftp must not do much. in-place edit: perl -pi -e 's/\r//g' script.cgi Just make sure to back up your script, first. worked like a charm, eliminating all the ^M's When I tried it out, the program still crashed. It executes most of the code, up to the (paraphrased) $file = $cgi-get_upload(blah) then stops executing. I think maybe I can do something with .htaccess files to adjust the limit on PUT, but that is a bit too OT for here, I think. Thanks, Ryan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: File upload problems still!
At 17:31 23/08/01, Ryan wrote: ^M's galore. The 'auto' setting on WS_ftp must not do much. By default WS_ftp will only be expecting files with certain extensions (eg. .txt, .htm) to be ASCII. So 'auto' will upload your .cgi or .pl files as binary. You can change these defaults on the Options button, Extensions tab. (I thought it was worth posting this response to the list, because I've had a few people puzzled by this in the past.) best, Mo Mo Holkar Undying King Games [EMAIL PROTECTED] http://www.ukg.co.uk -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Weekly list FAQ posting
NAME beginners-faq - FAQ for the beginners-cgi mailing list 1 - Administriva 1.1 - I'm not subscribed - how do I subscribe? Send mail to [EMAIL PROTECTED] You can also specify your subscription email address by sending email to (assuming [EMAIL PROTECTED] is your email address): [EMAIL PROTECTED]. 1.2 - How do I unsubscribe? Now, why would you want to do that? Send mail to [EMAIL PROTECTED], and wait for a response. Once you reply to the response, you'll be unsubscribed. If that doesn't work, find the email address which you are subscribed from and send an email like the following (let's assume your email is [EMAIL PROTECTED]): [EMAIL PROTECTED] 1.3 - There is too much traffic on this list. Is there a digest? Yes. To subscribe to the digest version of this list send an email to: [EMAIL PROTECTED] To unsubscribe from the digest, send an email to: [EMAIL PROTECTED] 1.4 - Is there an archive on the web? Yes, there is. It is located at: http://archive.develooper.com/beginners-cgi%40perl.org/ 1.5 - How can I get this FAQ? This document will be emailed to the list once a month, and will be available online in the archives, and at http://beginners.perl.org/ 1.6 - I don't see something in the FAQ, how can I make a suggestion? Send an email to [EMAIL PROTECTED] with your suggestion. 1.7 - Is there a supporting website for this list? Yes, there is. It is located at: http://beginners.perl.org/ 1.8 - Who owns this list? Who do I complain to? Casey West owns the beginners-cgi list. You can contact him at [EMAIL PROTECTED] 1.9 - Who currently maintains the FAQ? Kevin Meltzer, who can be reached at the email address (for FAQ suggestions only) in question 1.6 1.10 - Who will maintain peace and flow on the list? Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large, yet padded, clue-sticks to maintain peace and order on the list. If you are privately emailed by one of these folks for flaming, being off-topic, etc... please listen to what they say. If you see a message sent to the list by one of these people saying that a thread is closed, do not continue to post to the list on that thread! If you do, you will not only meet face to face with a XQJ-37 nuclear powered pansexual roto-plooker, but you may also be taken off of the list. These people simply want to make sure the list stays topical, and above-all, useful to Perl/CGI beginners. 1.11 - When was this FAQ last updated? May 31, 2001 2 - Questions about the 'beginners-cgi' list. 2.1 - What is the list for? A list for beginning Perl programmers to ask questions in a friendly atmosphere. The topic of the list is, of course, CGI with Perl. 2.2 - What is this list _not_ for? * SPAM * Homework * Solicitation * Things that aren't Perl related * Non Perl/CGI questions or issues * Lemurs 2.3 - Are there any rules? Yes. As with most communities, there are rules. Not many, and ones that shouldn't need to be mentioned, but they are. * Be nice * No flaming * Have fun 2.4 - What topics are allowed on this list? Basically, if it has to do with Perl/CGI , then it is allowed. If your question has nothing at all to do with Perl/CGI, it will likely be ignored. 2.5 - I want to help, what should I do? Subscribe to the list! If you see a question which you can give an idiomatic and Good answer to, answer away! If you do not know the answer, wait for someone to answer, and learn a little. 2.6 - Is there anything I should keep in mind while answering? We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the beginner to the place in the FM they should R :) 2.7 - I don't want to post a question if it is in an FAQ. Where should I look first? Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it. It can save everyone time if you look in the Perl FAQs first, instead of having a list of people refer you to the Perl FAQs :) You can learn about 'perldoc' by typing: `perldoc perldoc' At your command prompt. You can also view documentation online at: http://www.perldoc.com and http://www.perl.com 3 - Other Resources 3.1 - What other websites may be useful to a beginner ? * Perl Home Page - http://www.perl.com * PerlMonks - http://www.perlmonks.org * Perldoc - http://www.perldoc.com * Perl Archives - http://www.perlarchives.com 3.2 - What resources may be harmful to a beginner? Anything having to do with the names Matt Wright, or Selena Sol. Why? You may ask yourself. Well, their scripts are old and have been known to be buggy, as well as have security issues. They were written in the days of Perl 4. This means there is no scoping, stricture, warnings, idioms, or file
How does Apache invoke Perl interpreter
Hi, I want to do some research on Perl's transplantability, so I would like to know how an Apache server invokes Perl interpreter - in the case of mod_cgi instead of mod_perl. If anyone knows, or can redirect me to some documentation on the mechanism of Apache, please give me a hint. Thank you. Leon Qichao Dong(Leon) Graduate Research Assistant Innovative Computing Lab Computer Science Dept.University of Tennessee, Knoxville (865)974-9985 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How does Apache invoke Perl interpreter: OT please don't reply
test -Original Message- From: Qichao Dong (Leon) [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 23, 2001 2:21 PM To: [EMAIL PROTECTED] Subject: How does Apache invoke Perl interpreter Hi, I want to do some research on Perl's transplantability, so I would like to know how an Apache server invokes Perl interpreter - in the case of mod_cgi instead of mod_perl. If anyone knows, or can redirect me to some documentation on the mechanism of Apache, please give me a hint. Thank you. Leon Qichao Dong(Leon) Graduate Research Assistant Innovative Computing Lab Computer Science Dept.University of Tennessee, Knoxville (865)974-9985 [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]
Browser Problem
Hello I have written some web pages incorporating Forms and Perl processing on the server. Everything works fine on my IE 5.5 Browser but when I use the Netscape 4.7 and Opera 5.12 browsers, the HTML sent back from the Perl programme appears as (source) text. Do you have any ideas why. Thanks
Re: How does Apache invoke Perl interpreter
On Thu, 23 Aug 2001, Qichao Dong (Leon) wrote: I want to do some research on Perl's transplantability, so I would like to know how an Apache server invokes Perl interpreter - in the case of mod_cgi instead of mod_perl. Have you tried http://perl.apache.org? -- Brett http://www.chapelperilous.net/ In every non-trivial program there is at least one bug. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CGI::POST_MAX use and control
Lisa, Thanks! I synthesized from your answer and realized that my use of 'use CGI::Carp qw/fatalsToBrowser/;' was having me die long before I could have the code handle the problem. I commented out the '...Carp...' block and, indeed, my builtin code handled the error the way I'd intended. I was even able to see my 'friendly' ;-) user's error message: Because your message was too long, we ran out of electrons. Please shorten your e-mail message.. When I shortened the message to less than the 4K I spec'd, the form and code did the right thing and produced the intended e-mail. Follow-up question: Does POST_MAX measure the length of the incoming stream as the code asks for it -- $recd_data = $form-param('sent_data'); -- and then pulls the plug if 'sent_data' goes outside the bounds of acceptable social behavior? I ask because, while this change worked in my current program, I want to more fully understand the working principles for my next system. Thanks. John-- [EMAIL PROTECTED] -Original Message- From: Lisa Nyman [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 23, 2001 1:20 PM To: John Cc: Beginners-CGI Subject: Re: CGI::POST_MAX use and control Hi, On Thu, 23 Aug 2001, John wrote: The current incarnation of my script blows itself out of the water if the $user_body variable (the TEXTAREA source) is greater than 4K, for example. This is good. I would like to be able to capture and control the process so that I don't get rudely blown out of the water with a crude 500 Server message (this would be gooder! g). I would like to: a)generate a useful message and, b) set some flags, do some more processing, and send a message back to the user to give them an opportunity to correct their input and atone for their sins. (This would be more gooder! g) In general, you always want to die gracefully from within a web script so the error is logged and the user doesn't get an icky 500 error page. For example, in database apps I write, for any error, I tell the user the database is unavailable and I log the error. The following has worked for me when dealing with POST_MAX: use CGI qw/:standard/; $CGI::POST_MAX=1024 * 10; $CGI::DISABLE_UPLOADS = 1; $| = 1; my $page = new CGI; print $page-header; $run = $page-param('RUN'); if (!$run cgi_error()) { # do whatever you do for an error dieWell (413: Max Posting surpassed.); } sub dieWell { my $message = shift; # remember to print proper headers if not done by now print $thanks_for_playing_message\n; # do logging of $message if you want, send yourself email, whatever footer; # end my html - exit; } Lisa Wolfisch Nyman [EMAIL PROTECTED] IT Warrior Princess Life is too short to wear ugly underwear. Get the facts at http://quickfacts.census.gov/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CGI::POST_MAX use and control
For myself I would prefer not to abort a script on this type of error... A simple JavaScript to check for the max size of a textarea and an alert is a much better way to handle this type of error, in my option... see OnSubmit in some JavaScript reference and you should be able to find an example like .. O'Reilly's JavaScript The Definitive Guide, Chapter 16: Forms and Form Elements, 16.5 Form Verification Example Hope this give you some ideas... jwm -Original Message- From: Lisa Nyman [mailto:[EMAIL PROTECTED]] Sent: August 23, 2001 13:20 To: John Cc: Beginners-CGI Subject: Re: CGI::POST_MAX use and control Hi, On Thu, 23 Aug 2001, John wrote: The current incarnation of my script blows itself out of the water if the $user_body variable (the TEXTAREA source) is greater than 4K, for example. This is good. I would like to be able to capture and control the process so that I don't get rudely blown out of the water with a crude 500 Server message (this would be gooder! g). I would like to: a)generate a useful message and, b) set some flags, do some more processing, and send a message back to the user to give them an opportunity to correct their input and atone for their sins. (This would be more gooder! g) In general, you always want to die gracefully from within a web script so the error is logged and the user doesn't get an icky 500 error page. For example, in database apps I write, for any error, I tell the user the database is unavailable and I log the error. The following has worked for me when dealing with POST_MAX: use CGI qw/:standard/; $CGI::POST_MAX=1024 * 10; $CGI::DISABLE_UPLOADS = 1; $| = 1; my $page = new CGI; print $page-header; $run = $page-param('RUN'); if (!$run cgi_error()) { # do whatever you do for an error dieWell (413: Max Posting surpassed.); } sub dieWell { my $message = shift; # remember to print proper headers if not done by now print $thanks_for_playing_message\n; # do logging of $message if you want, send yourself email, whatever footer; # end my html - exit; } Lisa Wolfisch Nyman [EMAIL PROTECTED] IT Warrior Princess Life is too short to wear ugly underwear. Get the facts at http://quickfacts.census.gov/ -- 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: CGI::POST_MAX use and control
John, Thanks for the idea. I'd thought of using JavaScript, but I'm sunk if the user has Jscript turned off on their PC and I felt I wanted a little more surety on this being checked. I am going to re-visit the idea, however. My current Perl code does catch the error and return a form to the user so that they can reflect on their evil ways and correct their misdeeds. The script won't abort on 'em. (I'm considering a file-based counter, so that maybe the third time the same user flubs up I can really slap their paw, however; but that's an enhancement g) Thanks. John-- [EMAIL PROTECTED] -Original Message- From: Moon, John [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 23, 2001 2:22 PM To: John Cc: Beginners-CGI Subject: RE: CGI::POST_MAX use and control For myself I would prefer not to abort a script on this type of error... A simple JavaScript to check for the max size of a textarea and an alert is a much better way to handle this type of error, in my option... see OnSubmit in some JavaScript reference and you should be able to find an example like .. O'Reilly's JavaScript The Definitive Guide, Chapter 16: Forms and Form Elements, 16.5 Form Verification Example Hope this give you some ideas... jwm -Original Message- From: Lisa Nyman [mailto:[EMAIL PROTECTED]] Sent: August 23, 2001 13:20 To: John Cc: Beginners-CGI Subject: Re: CGI::POST_MAX use and control Hi, On Thu, 23 Aug 2001, John wrote: The current incarnation of my script blows itself out of the water if the $user_body variable (the TEXTAREA source) is greater than 4K, for example. This is good. I would like to be able to capture and control the process so that I don't get rudely blown out of the water with a crude 500 Server message (this would be gooder! g). I would like to: a)generate a useful message and, b) set some flags, do some more processing, and send a message back to the user to give them an opportunity to correct their input and atone for their sins. (This would be more gooder! g) In general, you always want to die gracefully from within a web script so the error is logged and the user doesn't get an icky 500 error page. For example, in database apps I write, for any error, I tell the user the database is unavailable and I log the error. The following has worked for me when dealing with POST_MAX: use CGI qw/:standard/; $CGI::POST_MAX=1024 * 10; $CGI::DISABLE_UPLOADS = 1; $| = 1; my $page = new CGI; print $page-header; $run = $page-param('RUN'); if (!$run cgi_error()) { # do whatever you do for an error dieWell (413: Max Posting surpassed.); } sub dieWell { my $message = shift; # remember to print proper headers if not done by now print $thanks_for_playing_message\n; # do logging of $message if you want, send yourself email, whatever footer; # end my html - exit; } Lisa Wolfisch Nyman [EMAIL PROTECTED] IT Warrior Princess Life is too short to wear ugly underwear. Get the facts at http://quickfacts.census.gov/ -- 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: Browser Problem
--- Advance Design - Vance [EMAIL PROTECTED] wrote: Hello I have written some web pages incorporating Forms and Perl processing on the server. Everything works fine on my IE 5.5 Browser but when I use the Netscape 4.7 and Opera 5.12 browsers, the HTML sent back from the Perl programme appears as (source) text. Do you have any ideas why. Thanks Newer versions of Internet Explorer have a feature that examines that beginning of the data that it receives and attempts to render the data accordingly. It completely violates W3C standards by ignoring the content-type header. Many, many developers have been bitten by this bug. I've accidently sent GIFs with a content type of image/pjpeg and IE still rendered it correctly but Netscape didn't. That was less than fun to debug. In your script, find out what is responsible for printing the content-type header and post that code snippet here. It will be something like the following: # If you're doing it by hand, it will resemble this: print Content-type: text/html\n\n; # If you're using CGI.pm, it will resemble on of the two following lines: print header(); # or (varies depending on the name of the CGI object) print $query-header; There are many different ways of printing the content-type header, but they will likely resemble the snippets above. Send that and we may have an answer for you. Of course, you can also telnet to port 80 (assuming that's the telnet port) and view the headers that way). Most likely, you're sending a content type of 'text/plain'. Here's what you'd enter in telnet: GET /cgi-bin/somescript.cgi?foo=bar HTTP/1.1 Host: www.somehost.com Substitute your own host and path and make sure you have two newlines after the host header. Cheers, Curtis Poe = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) Ovid on http://www.perlmonks.org/ __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CGI::POST_MAX use and control
I'd thought of using JavaScript, but I'm sunk if the user has Jscript turned off on their PC and I felt I wanted a little more surety on this being checked. I am going to re-visit the idea, however.never hurts to do both, never hurts to do both, your server will thank you for the less POSTs you're giving it! justin. s k a z a t - http://skazat.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Configuration Files
Hello. I would like to set up a configuration file for a CGI that I am writing so that it will be portable without editing the actual cgi. Stuff like administator email's, network segments, and the like. Is there a way to source the file for the cgi to read, or do I have to add a require statment and make the file a user routine? -James -- James Kelty Sr. Unix Systems Administrator The Ashland Agency [EMAIL PROTECTED] 541.488.0801 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Configuration Files
James Kelty [EMAIL PROTECTED] said something to this effect on 08/23/2001: I would like to set up a configuration file for a CGI that I am writing so that it will be portable without editing the actual cgi. Stuff like administator email's, network segments, and the like. Is there a way to source the file for the cgi to read, or do I have to add a require statment and make the file a user routine? There are a few ways to do it. Easiest is to have the config file be valid perl, and call it like: require /path/to/config.pl; There are plenty of modules on CPAN to read config files; my favorite is Config::General, which allows for (among other things) Apache-style config files. Config::Ini is also supposed to be good, and there is also the AppConfig package. (darren) -- Students achieving Oneness will move on to Twoness. -- Woody Allen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Configuration Files
Darren, try App::Config Jeffl On 2001.08.23 15:27 darren chamberlain wrote: James Kelty [EMAIL PROTECTED] said something to this effect on 08/23/2001: I would like to set up a configuration file for a CGI that I am writing so that it will be portable without editing the actual cgi. Stuff like administator email's, network segments, and the like. Is there a way to source the file for the cgi to read, or do I have to add a require statment and make the file a user routine? There are a few ways to do it. Easiest is to have the config file be valid perl, and call it like: require /path/to/config.pl; There are plenty of modules on CPAN to read config files; my favorite is Config::General, which allows for (among other things) Apache-style config files. Config::Ini is also supposed to be good, and there is also the AppConfig package. (darren) -- Students achieving Oneness will move on to Twoness. -- Woody Allen -- 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: Fw: Browser Problem
--- Advance Design - Vance [EMAIL PROTECTED] wrote: Hi Joel, Thanks for the fast reply. This is the html document heads. I have tried messing about with these, but with no change in result. !doctype html public -//W3C//DTD HTML 4.0 Transitional//EN html head titlebase-02.html/title meta name=Generator content=Edit Plus meta name=Author content=Vance meta name=Keywords content=keyword,keyword meta name=Description content=keyword,keyword /head Actually, that's the head of the HTML document. What's needed are the headers that are sent *prior* to that. Those headers tell the user agent (the browser, in this case) what to do with the document. Cheers, Curtis Poe = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) Ovid on http://www.perlmonks.org/ __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Browser Problem
Hello Curtis, I am just returning a complete html document from the perl file using the following: (perl in blue, html in red) Start Perl stuff... End Perl stuff... printcontainer; !doctype html public -//W3C//DTD HTML 4.0 Transitional//EN html head titlebase-02.html/title /head body Content /body /html container Your email suggests I should have a content-type header included in here somewhere... ? Thanks for your help. Vance [EMAIL PROTECTED] www.advance-design.co.uk --- Advance Design - Vance [EMAIL PROTECTED] wrote: Hello I have written some web pages incorporating Forms and Perl processing on the server. Everything works fine on my IE 5.5 Browser but when I use the Netscape 4.7 and Opera 5.12 browsers, the HTML sent back from the Perl programme appears as (source) text. Do you have any ideas why. Thanks Newer versions of Internet Explorer have a feature that examines that beginning of the data that it receives and attempts to render the data accordingly. It completely violates W3C standards by ignoring the content-type header. Many, many developers have been bitten by this bug. I've accidently sent GIFs with a content type of image/pjpeg and IE still rendered it correctly but Netscape didn't. That was less than fun to debug. In your script, find out what is responsible for printing the content-type header and post that code snippet here. It will be something like the following: # If you're doing it by hand, it will resemble this: print Content-type: text/html\n\n; # If you're using CGI.pm, it will resemble on of the two following lines: print header(); # or (varies depending on the name of the CGI object) print $query-header; There are many different ways of printing the content-type header, but they will likely resemble the snippets above. Send that and we may have an answer for you. Of course, you can also telnet to port 80 (assuming that's the telnet port) and view the headers that way). Most likely, you're sending a content type of 'text/plain'. Here's what you'd enter in telnet: GET /cgi-bin/somescript.cgi?foo=bar HTTP/1.1 Host: www.somehost.com Substitute your own host and path and make sure you have two newlines after the host header. Cheers, Curtis Poe = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) Ovid on http://www.perlmonks.org/ __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/
Re: Browser Problem
--- Advance Design - Vance [EMAIL PROTECTED] wrote: Hello Curtis, I am just returning a complete html document from the perl file ... Vance, It sounds like that could be the problem. Generally, when printing a Web page from a CGI script, you need to supply a content-type header to let the user agent (browser, in this case) know what type of content it's dealing with. If you're not doing that, your Web server might be doing that for you and sending a default of 'text/plain', or perhaps it's not sending it at all the the browsers are using defaults? Tough to say what's going on here. If you are not printing anything before the Web page, try printing the following: print Content-type: text/html\n\n; That will add the content-type header. Even better, try this (tougher to make a typo with this method): use CGI qw/:standard/; print header(); It sounds like you may be a little unsure as to what is meant by headers, so I'll try to explain, just in case. Your browser, when you request a resource from a Web server, will issue a request. There are many different request methods, but for CGI programmers, you will primarily be dealing with GET and POST requests. A typical request sent from your browser to the server may resemble the following: POST /cgi-bin/somescript.cgi HTTP/1.1 Accept */* Accept-Language: en-us Accept-encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT) Host: www.someserver.com Connection: Keep-Alive color=redname=Ovid Note that this request is split into two sections. The first section is comprised of the headers and the second section is the entity body, or just body. Since this is a POST request (see first line), form data is put in the entity body. If this were a GET request, there would be no body and the first line would be something like (note the query string moved from the body) GET /cgi-bin/somescript.cgi?color=redname=Ovid HTTP/1.1 For a get request like the one above, you'll see something like the following in the address bar of your browser: http://www.someserver.com/cgi-bin/somescript.cgi?color=redname=Ovid The Web server receives the request and passes your query information to the CGI script. When the CGI script responds, it is expected to send at least a Content-type header (unless your using non-parsed header scripts, which I won't go into now) or a status header (which I also won't go into now). Your Web server supplies the rest of the headers. Here's a typical response: a Web page sent by a script: HTTP/1.1 200 OK Date: Thu, 23 Sep 2001 06:23:19 GMT Server: Apache/1.3.6 (Unix) Last-Modified: Mon, 20 Sep 2001 08:19:56 GMT ETag: 2f5cd-9640381-e1bd6 Accept-Ranges: bytes Content-length: 4295 Connection: close Content-type: text/html !doctype html public -//W3C//DTD HTML 4.0 Transitional//EN html head titlebase-02.html/title etc. Note that we again have headers and a body, just as an HTML document has a head and body, but we're talking apples and oranges here. Your script is expected to at least specify the content-type (note the last line of the headers) and the Web server usually provides the rest of the headers. The two newlines between the headers allows your browser to know where the headers stop and the entity-body begins. Typically, when you view source in a Web browser, you're seeing *only the entity-body* of the document that's been returned. Hope this clears up the confusion. For more information, you can read http://www.easystreet.com/~ovid/cgi_course/. Cheers, Curtis Poe = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) Ovid on http://www.perlmonks.org/ __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CGI::POST_MAX use and control
Justin, Whoops! Hadn't thought of that. Belt 'n suspenders is good. I'm sold. Besides, I'm am anthropomorphic enough to understand that my server has feelings, too. John-- [EMAIL PROTECTED] -Original Message- From: Justin Simoni [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 23, 2001 2:51 PM To: John Cc: Moon, John; Beginners-CGI Subject: Re: CGI::POST_MAX use and control I'd thought of using JavaScript, but I'm sunk if the user has Jscript turned off on their PC and I felt I wanted a little more surety on this being checked. I am going to re-visit the idea, however.never hurts to do both, never hurts to do both, your server will thank you for the less POSTs you're giving it! justin. s k a z a t - http://skazat.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Browser Problem
Hello Curtis, It works!! Start Perl stuff... End Perl stuff... printcontainer; content-type: text/html blank line blank line !doctype html public -//W3C//DTD HTML 4.0 Transitional//EN html head titlebase-02.html/title /head body Content /body /html container The:- print Content-type: text/html\n\n; produced a error in the browser for some reason. Many thanks for all your help. (I am not entirely certain of what is going on but it works!) Now I have to sort out the html/browser discrepancy problems. Opera and IE5.5 are pretty close but Netscape is doing strange things with my layout. Thanks again, Vance. --- --- Advance Design - Vance [EMAIL PROTECTED] wrote: Hello Curtis, I am just returning a complete html document from the perl file ... Vance, It sounds like that could be the problem. Generally, when printing a Web page from a CGI script, you need to supply a content-type header to let the user agent (browser, in this case) know what type of content it's dealing with. If you're not doing that, your Web server might be doing that for you and sending a default of 'text/plain', or perhaps it's not sending it at all the the browsers are using defaults? Tough to say what's going on here. If you are not printing anything before the Web page, try printing the following: print Content-type: text/html\n\n; That will add the content-type header. Even better, try this (tougher to make a typo with this method): use CGI qw/:standard/; print header(); It sounds like you may be a little unsure as to what is meant by headers, so I'll try to explain, just in case. Your browser, when you request a resource from a Web server, will issue a request. There are many different request methods, but for CGI programmers, you will primarily be dealing with GET and POST requests. A typical request sent from your browser to the server may resemble the following: POST /cgi-bin/somescript.cgi HTTP/1.1 Accept */* Accept-Language: en-us Accept-encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT) Host: www.someserver.com Connection: Keep-Alive color=redname=Ovid Note that this request is split into two sections. The first section is comprised of the headers and the second section is the entity body, or just body. Since this is a POST request (see first line), form data is put in the entity body. If this were a GET request, there would be no body and the first line would be something like (note the query string moved from the body) GET /cgi-bin/somescript.cgi?color=redname=Ovid HTTP/1.1 For a get request like the one above, you'll see something like the following in the address bar of your browser: http://www.someserver.com/cgi-bin/somescript.cgi?color=redname=Ovid The Web server receives the request and passes your query information to the CGI script. When the CGI script responds, it is expected to send at least a Content-type header (unless your using non-parsed header scripts, which I won't go into now) or a status header (which I also won't go into now). Your Web server supplies the rest of the headers. Here's a typical response: a Web page sent by a script: HTTP/1.1 200 OK Date: Thu, 23 Sep 2001 06:23:19 GMT Server: Apache/1.3.6 (Unix) Last-Modified: Mon, 20 Sep 2001 08:19:56 GMT ETag: 2f5cd-9640381-e1bd6 Accept-Ranges: bytes Content-length: 4295 Connection: close Content-type: text/html !doctype html public -//W3C//DTD HTML 4.0 Transitional//EN html head titlebase-02.html/title etc. Note that we again have headers and a body, just as an HTML document has a head and body, but we're talking apples and oranges here. Your script is expected to at least specify the content-type (note the last line of the headers) and the Web server usually provides the rest of the headers. The two newlines between the headers allows your browser to know where the headers stop and the entity-body begins. Typically, when you view source in a Web browser, you're seeing *only the entity-body* of the document that's been returned. Hope this clears up the confusion. For more information, you can read http://www.easystreet.com/~ovid/cgi_course/. Cheers, Curtis Poe = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) Ovid on http://www.perlmonks.org/ __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/
sending @array as hidden variable
Hi Everybody, I am trying to send an array as a hidden value in my script as follows: @array = (eggs, ham, bread, pop); foreach $food (@array){ print INPUT TYPE=\hidden\ NAME=\food\ VALUE=\$food\; } My two questions are: 1. Is this the most efficient way of sending an array as a hidden value? 2. And if so, what is the corresponding $input{''} syntax? Many thanks for your time, everybody! = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] Great spirits have always encountered violent opposition from mediocre minds. -Albert Einstein __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: split a file
Yet another way...: -snip--- #!/usr/bin/perl -w use strict; open (FILE, file_with_headings.txt) || die Couldn't open \file_with_headings.txt\ $!\n; open (DIALIGN, dialign.txt) || die Couldn't create \dialign.txt\ $!\n; open (FASTA, fasta.txt) || die Couldn't create \fasta.txt\ $!\n; open (TREE, sequence_tree.txt) || die Couldn't create \sequence_tree.txt\ $!\n; while (FILE) { print DIALIGN if (/DIALIGN/ .. /FASTA/); print FASTA if (/FASTA/ .. /Sequence tree/); print TREE if (/Sequence tree/ .. eof); } close (DIALIGN); close (FASTA); close (TREE); -snip--- Ron Smith From: Pedro A Reche Gallardo [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED], [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: split a file Date: Tue, 21 Aug 2001 18:24:44 -0400 Hi All, I have a file (see below) that I would like to split in three files: One file for the information under Alignment (DIALIGN format), another for the information under the line Alignment (FASTA format) and a third one for the information under sequence tree. Any help to do this will be appreciated. Cheers Alignment (DIALIGN format): === gi|38145|e1 MALPVTALLL PLALLLHAAR ---PSQFRVS PLDRTWNLGE TVELKCQVLL gi|74386931 MALPVTALLL PLALLLHAAR ---PSQFRVS PLDRTWNLGE TVELKCQVLL ** ***** ** ** ** * *** ** ** Alignment (FASTA format): = gi|38145|emb|CAA4278 MALPVTALLLPLALLLHAAR---PSQFRVSPLDRTWNLGETVELKCQVLL SNPTSGCSWLFQPRGAAASPTFLLYLSQNKPKAAEGLDTQRFSGKRLGDT gi|7438693|pir||S256 MALPVTALLLPLALLLHAAR---PSQFRVSPLDRTWNLGETVELKCQVLL Sequence tree: == ((gi|38145|emb|CAA4278:0.003018, gi|7438693|pir||S256:0.003018):0.002338, gi|1168854|sp|P41688:0.005357); *** PEDRO a. RECHE gallardo, pHDTL: 617 632 3824 Scientist, Mol.Immnunol.Foundation, FX: 617 632 3351 Dana-Farber Cancer Institute, EM: [EMAIL PROTECTED] Harvard Medical School, EM: [EMAIL PROTECTED] 44 Binney Street, D610C,URL: http://www.reche.org Boston, MA 02115 *** _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to reference env variables.
At 11:26 AM 08.22.2001 -0400, Bob Showalter wrote: -Original Message- From: Kingsbury, Michael [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 22, 2001 11:07 AM To: '[EMAIL PROTECTED]' Subject: How to reference env variables. When running a command such as : `ls -la /some/directory` there is an envirornment variable called !EXITCODE that I want to reference. I already have Use Env in place, but how do I keep perl from gagging on the bang in the variable name?? Based on a cursory glance at Env.pm, it appears that it will skip any names in the environment that dont match [A-Za-z_]. Theoretically you shouldn't be using any environment tokens with special characters in them anyway since the shell can and will misinterpret them at the most un useful times. The '!' is a great example of this since bash will go crazy on it as well as many other shells. In fact, you should really find out what is gagging, the Perl script or the shell. You're probably right that it is the Perl interpreter but I'd double check to make sure. It looks like the c shell is innocuous to the '!' based on HP example below. I have to agree with the suggestion made here too, that you need to be specific about what your env var !EXITCODE does. Perhaps there is a Unix mechanism or Perl mechanism already in place that will do what you are attempting (seem to anyway) do. - Jim You could get at it through the regular %ENV hash: $ENV{'!EXITCODE'} This command works on my (HPUX) system: $ env !EXITCODE=hello perl -e 'print $ENV{q[!EXITCODE]}, \n' hello Is this variable some artifact of your shell? Are you wanting to test it following the ls backticks? If so, this isn't going to work. The shell/ls will be executed in a child process, and the child cannot affect the parent's environment. If you just want the exit status from the backtics, you can use Perl's regular $? variable. Or maybe I'm misunderstanding the whole issue. (Wouldn't be the first time). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Jim -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- http://www.perlmonks.org/index.pl?node_id=67861lastnode_id=67861 -BEGIN PERL GEEK CODE BLOCK- --BEGIN GEEK CODE BLOCK-- Version: 0.01 Version: 3.12 P++*@$c?P6?R+++@$M GIT/CM/J d++(--) s++:++ a- $O!MA-E! PU--+++BDC(+) UB$L$S$ $C-@D!(-)$S@$X?WP+MO!+++ P++(+)+ L+++()+$ !E* +PP+++n-CO?PO!o G W++(+++) N+ o !K w--- PS---(-)@ PE *(!)$A--@$Ee---(-)Ev++uL++*@$uB+ Y PGP t+(+++)+++@ 5- X++ R@ *@$uS+*@$uH+uo+w-@$m! tv+ b? DI-(+++) D+++(++) G() --END PERL GEEK CODE BLOCK-- --END GEEK CODE BLOCK-- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl is amazing!!
At 07:17 AM 08.21.2001 -0500, Randy5235 wrote: I just started learning Perl about 2 days ago. I am totally blown away at the power and ease. I am however trying to find as much reference as possible. I have checked most of the popular sites thus far and managed to find some docs there. Any links to documentation and how to's for a beginner would be much appreciated. Thanks Randy5235 I absolutely *love* perlmonks.org http://www.perlmonks.org I recommend that site to anyone. Remember, the key to being monk is the ability to search. :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Jim -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- http://www.perlmonks.org/index.pl?node_id=67861lastnode_id=67861 -BEGIN PERL GEEK CODE BLOCK- --BEGIN GEEK CODE BLOCK-- Version: 0.01 Version: 3.12 P++*@$c?P6?R+++@$M GIT/CM/J d++(--) s++:++ a- $O!MA-E! PU--+++BDC(+) UB$L$S$ $C-@D!(-)$S@$X?WP+MO!+++ P++(+)+ L+++()+$ !E* +PP+++n-CO?PO!o G W++(+++) N+ o !K w--- PS---(-)@ PE *(!)$A--@$Ee---(-)Ev++uL++*@$uB+ Y PGP t+(+++)+++@ 5- X++ R@ *@$uS+*@$uH+uo+w-@$m! tv+ b? DI-(+++) D+++(++) G() --END PERL GEEK CODE BLOCK-- --END GEEK CODE BLOCK-- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: counting
yes but here the result of $count will always be 0, it should see the imput file and count tell me how many processed lines I hve in total, for the momento it is presentig all the precessed lines, so it gives an out put that says proceseed line 1 procesed line 2 and so on, but for th fineal report I would like to know how many in tootal were procesed how can I do that? here is the whole source #!/usr/bin/perl use strict; my $REPORT_FILE=report.htm; my $blast_file=$ARGV[0]||'blast.dat'; unless (-e $blast_file) { die $0: error:missing file: $blast_file; } #slurp all the seqs in to the scalar my ($query_src,$sbjct_src); #open the blast data file and end prg (DIE) if we can't find it open(IN, #$blast_file) or die open (IN, $blast_file) or die $0: ERROR: $blast_file: $!; #go trought the blast file line by line, concat all the query and sbj seqs my $line; while ($line=IN) { chomp $line; print processing line $. \n; my @words=split /\s+/, $line; if ($line=~ /^Query/) { $query_src .=$words[2]; } elsif ($line =~ /^Sbjct/) { $sbjct_src .=$words[2]; } } #next line closes the blast file close IN; #analysis part my @patterns=('gtccca', 'gcaatg', 'cagct', 'tcggga', '-'); #find the patterns and sotore them in to the hashes my (%query_counts, %sbjct_counts); #search and store foreach my $pattern (@patterns) { while ($query_src=~ /$pattern/g) { $query_counts{$pattern}++; } while ($sbjct_src=~ /$pattern/g) { $sbjct_counts{ $pattern }++; } } #create an empty report fele open (OUT, $REPORT_FILE) or die $0: ERROR: cant write $REPORT_FILE; #print the header of the report file #print OUT Seq report \n, lo que sea , scalar localtime, \n, \nnote in the sakasl saklkskfkdkskskjfkddkfj \n, total lenght of the 'Query' seq: \n ,\nlenght $query_src, characters $ #adds agc my $count=0; while ( IN ) { $count++; print prsdf line $count\n; } print process $count lines\n; my $thetime = scalar (localtime); print OUT END_OF_REPORT; !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 3.2//EN HTML HEAD META HTTP-EQUIV=Content-Type CONTENT=text/html; charset=iso-8859-1 META NAME=Generator CONTENT=MS Exchange Server version 5.5.2650.12 TITLEBlast report/TITLE /HEAD BODY PFONT SIZE=2 FACE=ArialSeq report,/FONT Plocal time for this report $thetime pNote: A dash - represents missing data in the chromosomal seq brtotal lenght of the query seq $query_src p Results for query pnueva var $count /BODY /HEAD /HTML END_OF_REPORT #print the query mathces #foreach my $key (sort @patterns) #{ # print OUT \t '$key' seen $query_counts{$key}\n; #} #print OUT \nTOTAL lenght of 'Sbjct' seq: ,\nlenght $sbjct_src, cahracter$ #print the sbjct mathces #foreach my $key (sort @patterns) #{ # print OUT \t'$key' seen $sbjct_counts{$key}\n; #} close OUT; __END__ an imput file looks like this Query: 1tcgggaaagaa--aatggtggc-ttcaagtttccagtcagctgctctctgtcccag 60 Sbjct: 1ctacaca-gaaagaatggtgg---tcaagtttcttcttgctctctctctgtcccag 60 so for example at the momento it is not giving me the number of characters on the quey line again how can I do that? On Wed, 22 Aug 2001, Troy Denkinger wrote: Date: Wed, 22 Aug 2001 11:31:09 -0400 From: Troy Denkinger [EMAIL PROTECTED] To: webmaster [EMAIL PROTECTED], perl [EMAIL PROTECTED] Subject: Re: counting On Wednesday 22 August 2001 11:58, webmaster wrote: #!/usr/bin/perl $REPORT_file=report.htm; $ imput_file=$ARGV[0]||'imput.dat'; unless (-e $imput_file) { die $0: error:missing file: $imput_file; } open (IN, $imput_file) or die $0 : error: $imput_file: $!; All of this ( except the #! line ) can be replaced by this: open( IN, shift ) or die( Open failed: $! ); #print $imput_file; my $line; while ($line=IN) { chomp $line; print processing line $. \n; } If I understand the question, you want to be told by the while look what line is processing and then, at the end, be told how many lines were processed. I'd use a counter to keep track of it all: my $count = 0; while( IN ){ $count++; print Processing line $count\n; } print Processed $count lines\n; Also, use strict and use warnings, you'll be happy to did - maybe not now, but someday. Regards, Troy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl is amazing!!
Hello Randy, I wrote some beginners tutorials you might find usefull on http://japh.nu Also, I'd recommend the camel book (programming perl, by larry wall, published by o'reilly) and the llama book (learning perl, by randal schwartz, also published by o'reilly). hth, Jos Boumans Randy5235 [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I just started learning Perl about 2 days ago. I am totally blown away at the power and ease. I am however trying to find as much reference as possible. I have checked most of the popular sites thus far and managed to find some docs there. Any links to documentation and how to's for a beginner would be much appreciated. Thanks Randy5235 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Administrators Mailing Groups ???
Dear All, I am new to PERL .Perl is very Interesting and Useful it seems. Please tell me is there any Mailing List for Admin activities Using Perl(Windows NT UNIX environments). I am interested in writing some scripts using PERL on Administrative purpose.. Please Help me in this regards, Please share any Well known links in this Direction . Thanx and Regards Raju -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
perl version
how could i know which perl version i am using : any command on unix/linux
RE: perl version
| how could i know which perl version i am using : any command | on unix/linux perl -v or (more verbose) perl -V -- Marcus | -Original Message- | From: Rahul Garg [mailto:[EMAIL PROTECTED]] | Sent: Thursday, August 23, 2001 1:14 PM | To: [EMAIL PROTECTED] | Subject: perl version | | | how could i know which perl version i am using : any command | on unix/linux | -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl version
Hi, Useperl -v dinesh -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Perl/TK GUI IDE? Does one exist?
Hi, As some of you know... developing TK can be time consuming. Does anyone know, even in its simplest form, of a perl TK IDE tool? Idealy on the windows platform. Perl Builder doesn't really have a VC++ style IDE where you can create yoru window look and feel. Regards, Pierre Smolarek Internet Production Manager BBM Carlson, Carlson Marketing Group -- This message contains privileged and confidential information intended only for the use of the addressee named above. If you are not the intended recipient of this message, you are hereby notified that you must not disseminate, copy or take any action in reliance on it. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the company.
RE: Debug help
-Original Message- From: Scott Taylor [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 22, 2001 6:46 PM To: [EMAIL PROTECTED] Subject: Debug help Hi all, I snatched this guest book off some script site Be careful. A lot of that stuff on script sites is pure crapola. and it's either gone now, or I misplaced the bookmark, but anyhow, perhaps someone can help me with the syntax. Something I changed at 3AM one morning now it doesn't work right Use RCS, CVS, or something. Make backups. , I know the MySQL parameters are fine, it's something I accidently deleted in here. $success returns this value: DBI::st=HASH(0x81a8280) at the line if($success != 1) ... Well, $success is the return from prepare(), which is a statement handle. Why would you compare a statement handle to a 1? can anyone point out my obvious mistake? Calling the handle $success implies that you mean for this variable to be the result of the execute() method. Read the DBI docs to see what prepare() and execute() return. Note that the return of prepare() is not checked. You might want to do that, otherwise the execute() call will barf ungracefully. sub insert_entry { my ($dbh, $success, $name, $email, $website, $comments,$time); $dbh = DBI-connect(DBI:mysql:database=$serverDb; host=$serverName;port=$serverPort,$serverUser,$serverPass); $name = param(name); $email = param(email); $website = param(website); $comments = param(comments); $time = time; $SQL = INSERT INTO $serverTabl(name,email,website,comments,time) VALUES(?, ?, ?, ?, ?), undef, $name, $email,$website,$comments,$time; $success = $dbh-prepare($SQL); $success-execute; $dbh-disconnect; if($success != 1) { return $success Sorry, the database was unable to add your entry. Please try again later. } else { return; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to tie a hash of arrays
-Original Message- From: G Harper [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 23, 2001 2:58 AM To: [EMAIL PROTECTED] Subject: How to tie a hash of arrays Is there an easier way than MLDBM? It's all I've found. I need to store/retreive a DBM hash with 7 keys, each key storing an array with up to 40 entries. It very much depends on the specific application. It really doesn't get much easier than MLDBM. I don't understand what the problem is. Or can I tie multiple hashes to one DBM file? Then I could reference each entry as a key in it's respective hash. No, a DBM ties to one hash. But that hash (using MLDBM) can contain other hashes nested to any level. Post some details about why MLDBM doesn't seem to be the right tool for you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl is amazing!!
This link takes you to a great beginner's page. I find it very useful and still reference it occasionally. http://www.cs.unm.edu/~bwylie/perl/start.html -Original Message- From: Randy5235 [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 21, 2001 7:18 AM To: [EMAIL PROTECTED] Subject: Perl is amazing!! I just started learning Perl about 2 days ago. I am totally blown away at the power and ease. I am however trying to find as much reference as possible. I have checked most of the popular sites thus far and managed to find some docs there. Any links to documentation and how to's for a beginner would be much appreciated. Thanks Randy5235 -- 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]
inquiry/variables
I have #search and store foreach my $pattern (@patterns) { while ($query_src=~ /$pattern/g) { $query_counts{$pattern}++; } while ($sbjct_src=~ /$pattern/g) { $sbjct_counts{ $pattern }++; } } and foreach my $key (sort @patterns) { print OUT \t '$key' seen $query_counts{$key}\n; } #print OUT \nTOTAL lenght of 'Sbjct' seq: ,\nlenght $sbjct_src, cahracters\n, resou$ #print the sbjct mathces foreach my $key (sort @patterns) { print OUT \t'$key' seen $sbjct_counts{$key}\n; } I want to have in a separate variable each match, it reads a file and searches for mathces, if fines one counst is and prints it out, that is doing now, now I do not want id to print it out but to store the value for a future use in any variable new, so I can decide later wich are worthful to have on a report, how canI do that? cheers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using the B module?
Hi there, I would like to perform a special check on scripts before they are evaluated. We have this situation: * we provide a set of functions * our users should use just these functions, nothing else Therefore, a typical script would look like this: use Ourlib; ourSub(arg1, 2, arg); ourSub1(); ourSub2(3); ourSubX(CONST1, CONST2); The execution of this functions might take a lot of time. Therefore we would like to ensure that all method calls are correct - before we start to execute the first call. E. g. we know that ourSubX will accept only 2 strings from a set of 5 possible values or so. Therefore if someone mistakely writes ourSubX(CONSTL, CONST2) we would like to stop right in the beginning. Of course we cant check for any kind of mistake - but we would like to avoid the situation where a script fails after 20 hours because someone wrote CONSTL instead of CONST1 in the last line of a script ... I think the easiest solution for this requirement is to use the perl compiler package and to check any call to a method in the script - before the script itself is executed. Well, knowing what to do is not quite the same as knowing how to do it ... maybe someone can tell me where I can find some SIMPLY examples/tutorials of how to use the B package - for example it would be really nice to see code that reads a perl script and then walks over the corresponding AST and prints out all the nodes of the AST. thx, edwin günthner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
usage of require
Hi, I wrote a perl programm where i have a lot of strings defined and a lot of configuration data. To have a handy file where all configuration is stored and can be easily changed I want to use the require function. So I put after use CGI; a require config; I created a file called config and put it to the same directory where the script resides. The content is like this: @year = (2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011); etc. But running the programm fails. What' wrong? Bye, Oliver ** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. Sony cannot accept liability for statements made which are clearly the sender's own and not made on behalf of Sony. (01) ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
More problems printing dereferencing an array within an struct
Wags helped me with the last problem (though we are still unsure of the reason for the behavior). This round I have encountered another similar problem. The code sample works for printing out the scalars, but when I attempt to print out the arrays instead the size of the arrays are printed, causing no end to confusion. If I print $MIB_TREE{$object}-children i get an array reference, so i try to dereference it but then I can only get the size. Any ideas ? (Perl guru's please see the earlier note with the similar subject line to see if you can help with that problem as well). Truly confused, #!/usr/bin/perl -w use strict; use Parse::RecDescent; use Class::Struct; select ( STDOUT ); $| = 1; # my $wRX = \[\\w\\-\]; # my $commentRX = qr/^--/; struct Object = { name= '$', id = '$', children = '@', }; my %MIB_TREE; my $node = Object-new(); $node-name(Murray); $node-id(ID3148); @{$node-children} = (Craig, Scott, Cara); $MIB_TREE{$node-name} = $node; $node = Object-new(); $node-name(CRAIG); $node-id(ID0281); @{$node-children} = (NA); $MIB_TREE{$node-name} = $node; foreach my $object ( keys %MIB_TREE ) { print $MIB_TREE{$object}-name.\n; print $MIB_TREE{$object}-id.\n; print @{$MIB_TREE{$object}-children}.\n; } - Craig Moynes IBM Global Services, Canada [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using the B module?
On Thu, Aug 23, 2001 at 03:22:54PM +0200, Edwin Günthner wrote: maybe someone can tell me where I can find some SIMPLY examples/tutorials of how to use the B package - Hardly for beginners, but you probably want to take a look at B::Utils. As far as tutorials are concerned, I think you might be out of luck. for example it would be really nice to see code that reads a perl script and then walks over the corresponding AST and prints out all the nodes of the AST. I'd suggest looking at something like B::Deparse or B::Concise. You might be better off simply parsing with Perl. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: More problems printing dereferencing an array within an struct
On Thu, Aug 23, 2001 at 09:31:52AM -0400, Craig Moynes/Markham/IBM wrote: This round I have encountered another similar problem. The code sample works for printing out the scalars, but when I attempt to print out the arrays instead the size of the arrays are printed, causing no end to confusion. If I print $MIB_TREE{$object}-children i get an array reference, so i try to dereference it but then I can only get the size. Here's your problem: print @{$MIB_TREE{$object}-children}.\n; You are printing the array in scalar context, which gives its size. Try either of these: print @{$MIB_TREE{$object}-children}, \n; print @{$MIB_TREE{$object}-children}\n; Depending on whether you want the spaces between elements. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: usage of require
perhaps you want to 'use' or even 'do' your module but it depends on the error you are getting perhaps you can provide a bit more context? Jos - Original Message - From: Oliver Velten [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 23, 2001 3:32 PM Subject: usage of require Hi, I wrote a perl programm where i have a lot of strings defined and a lot of configuration data. To have a handy file where all configuration is stored and can be easily changed I want to use the require function. So I put after use CGI; a require config; I created a file called config and put it to the same directory where the script resides. The content is like this: @year = (2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011); etc. But running the programm fails. What' wrong? Bye, Oliver ** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. Sony cannot accept liability for statements made which are clearly the sender's own and not made on behalf of Sony. (01) ** -- 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: Using the B module?
Paul brings up a good point. You can do something like this: package OurPackage; BEGIN { my $filename = (caller(2))[1]; # now, open $filename and make sure it only uses what you want # and how you want it used. } in their file use strict; use OurPackage; -- BEGIN is executed here Good Luck! Tanton -Original Message- From: Paul Johnson To: Edwin Günthner Cc: [EMAIL PROTECTED] Sent: 8/23/2001 8:33 AM Subject: Re: Using the B module? On Thu, Aug 23, 2001 at 03:22:54PM +0200, Edwin Günthner wrote: maybe someone can tell me where I can find some SIMPLY examples/tutorials of how to use the B package - Hardly for beginners, but you probably want to take a look at B::Utils. As far as tutorials are concerned, I think you might be out of luck. for example it would be really nice to see code that reads a perl script and then walks over the corresponding AST and prints out all the nodes of the AST. I'd suggest looking at something like B::Deparse or B::Concise. You might be better off simply parsing with Perl. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- 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]
RTF Generator vs. RTF Writer?
I am looking for a module that allows generation of RTF documents from perl. The idea is to take output from database searches and generate documents with specific fonts, so that users can print out (or do whatever else they want to do with) these documents. CPAN informs that there are two such modules: RTF-Generator-1.00 and RTF-Writer-1.06. Does anyone on this list use these modules and can share experiences? Thanks regards, Birgit Kellner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex help
Jeff 'japhy/Marillion' Pinyan a écrit : Someone else has already shown the general approach for ensuring a unique-character string: sub unique_characters { $_[0] =~ /(.).*?\1/s ? 0 : 1 } We can extrapolate upon this idea and test afterward that the string doesn't contain any unwanted characters: sub unique_char_set { my ($str, $chars) = @_; return 0 if $str =~ /[^\Q$chars\E]/; return !($str =~ /(.).*?\1/s); } Thanks for your response guys. This is very useful. In fact, since I needed a one liner (I forgot to say that) for a regex-based dispatch table, I tried to convert that to : ($str !~ /(c|C|d|e|E|f|G|h|i|I|k|K|l|L|m|M|r|R|s|t|T|v|V|x|X).*?\1/s); But this doesn't fail if unwanted characters are in. So I am afraid that we'll arrive at (??{ ... }) What I am trying to do is some kind of shell. Command dispatching is done via a hash containing regex = coderef style data. That's why I am looking for a one--liner. Thanks ! Michel. -- Michel Blanc Centre Multimédia Erasme/Parc d'activités innovantes 69930 Saint Clément-les-places Tel : +33-(0)4-74-70-68-40 / Fax : +33-(0)4-74-70-68-40 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Append array in hash of arrays under strict
Here's some sample code --- use strict; my (%hash, @array, @results); $hash{'name'}{'sub'} = qw(one two three four); @array = qw(five six seven eight); $hash{'name'}{'sub'} = ($hash{'name'}{'sub'}, @array); print @{$hash{'name'}{'sub'}}; --- This produces an error Can't use string (4) as an ARRAY ref while strict refs in use at test.pl line 11. The Perl Cookbook says this causes a runtime exception under use strict because you're dereferencing an undefined reference where autovivification won't occur and suggests using... --- use strict; my (%hash, @array, @results); $hash{'name'}{'sub'} = qw(one two three four); @array = qw(five six seven eight); $hash{'name'}{'sub'} = ($hash{'name'}{'sub'}, @array); @results = exists( $hash{'name'}{'sub'} ) ? @{ $hash{'name'}{'sub'} } : (); print @results; --- Which I've tried, but it produces the same error. Does anyone have some advice or a workround (other that removing the use strict pragma if possible). I've tried combining the arrays like this push ($hash{'name'}{'sub'}, @array); and push (@{$hash{'name'}{'sub'}}, @array); with similar errors. Thanks John Edwards IT Support Runecraft Leeds Phone: 0113 2206317 Fax: 0113 2206301 Mobile: 07961 356186 --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex help
Bob Showalter a écrit : If you want to match any of those characters (and no other) in any order, but at most once, here is a non-regex approach (not terribly efficient if you need to do it millions of times, but it works): use strict; my $key = 'cCdeEfGhiI'; # legal chars check('cCdE'); # match check('cCcE'); # no match check('xccE'); # no match sub check { my $val = shift; print Testing $val: ; my %h = map { ($_ = 0) } split //, $key; for (split //, $val) { print(No match\n), return unless exists $h{$_} !$h{$_}++; } print Match\n; } Thanks for this Bob, but I forgot to say that : - I need a regexp, - I need a one-liner - The order of characters doesn't matter Sorry for this oversight, and thanks for your help. Michel. -- Michel Blanc Centre Multimédia Erasme/Parc d'activités innovantes 69930 Saint Clément-les-places Tel : +33-(0)4-74-70-68-40 / Fax : +33-(0)4-74-70-68-40 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: usage of require
-Original Message- From: Oliver Velten [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 23, 2001 9:32 AM To: '[EMAIL PROTECTED]' Subject: usage of require Hi, I wrote a perl programm where i have a lot of strings defined and a lot of configuration data. To have a handy file where all configuration is stored and can be easily changed I want to use the require function. So I put after use CGI; a require config; I created a file called config and put it to the same directory where the script resides. The content is like this: @year = (2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011); etc. But running the programm fails. What' wrong? Fails in what way? Why make us guess? Did you carefully read the documentation on require? I can think of two reasons why it might be failing: 1. If config is a bareword, require will look for a file called config.pm, and it must exist in a location in @INC 2. If the last expression in the file does not evaulate to true, the require will fail. See: perldoc -f require perldoc -q require -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Perform a tar command on a directory
Does anyone have a good suggestion how to go about creating a tar ball of a directory from within a Perl script? I considered doing a change directory just above the directory which I want to tar and then using the UNIX tar command from within the script. Is this the best approach? Thanks! Hans
Strip charactes from every element in array
Is there any easy way to strip a single character from every element in an array? @array = qw(one1 two1 three1); And I need the elements to be (one two three). My only idea is copy to another array, run a foreach, s/// the char out and push into another array, then after the foreach has finished empty the first array and replace with the fixed one. There must be a better way, right John Edwards IT Support Runecraft Leeds Phone: 0113 2206317 Fax: 0113 2206301 Mobile: 07961 356186 --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Strip charactes from every element in array
| Is there any easy way to strip a single character from every | element in an | array? @array = qw(one1 two1 three1); chop @array; print @array; Hope this helps. -- Marcus | -Original Message- | From: John Edwards [mailto:[EMAIL PROTECTED]] | Sent: Thursday, August 23, 2001 4:45 PM | To: Perl Beginners (E-mail) | Subject: Strip charactes from every element in array | | | Is there any easy way to strip a single character from every | element in an | array? | | @array = qw(one1 two1 three1); | | And I need the elements to be (one two three). | | | My only idea is copy to another array, run a foreach, s/// | the char out and | push into another array, then after the foreach has finished | empty the first | array and replace with the fixed one. There must be a better | way, right | | John Edwards | IT Support | Runecraft Leeds | | Phone: 0113 2206317 | Fax: 0113 2206301 | Mobile: 07961 356186 | | | | --Confidentiality--. | This E-mail is confidential. It should not be read, copied, | disclosed or | used by any person other than the intended recipient. | Unauthorised use, | disclosure or copying by whatever medium is strictly | prohibited and may be | unlawful. If you have received this E-mail in error please | contact the | sender immediately and delete the E-mail from your system. | | | | -- | To unsubscribe, e-mail: [EMAIL PROTECTED] | For additional commands, e-mail: [EMAIL PROTECTED] | -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Strip charactes from every element in array
| and if the character isn't there | | @array(one1 two three1); | | I end up with | | one tw three @array = qw(one1 two1 three1); s/\d+$// for @array; print @array; -- Marcus | -Original Message- | From: John Edwards [mailto:[EMAIL PROTECTED]] | Sent: Thursday, August 23, 2001 4:49 PM | To: 'HOLLAND-MORITZ,MARCUS (A-hsgGermany,ex1)' | Subject: RE: Strip charactes from every element in array | | | and if the character isn't there | | @array(one1 two three1); | | I end up with | | one tw three | | -Original Message- | From: HOLLAND-MORITZ,MARCUS (A-hsgGermany,ex1) | [mailto:[EMAIL PROTECTED]] | Sent: 23 August 2001 15:49 | To: 'John Edwards' | Subject: RE: Strip charactes from every element in array | | | | Is there any easy way to strip a single character from every | | element in an | | array? | | @array = qw(one1 two1 three1); | chop @array; | print @array; | | Hope this helps. | | -- Marcus | | | | -Original Message- | | From: John Edwards [mailto:[EMAIL PROTECTED]] | | Sent: Thursday, August 23, 2001 4:45 PM | | To: Perl Beginners (E-mail) | | Subject: Strip charactes from every element in array | | | | | | Is there any easy way to strip a single character from every | | element in an | | array? | | | | @array = qw(one1 two1 three1); | | | | And I need the elements to be (one two three). | | | | | | My only idea is copy to another array, run a foreach, s/// | | the char out and | | push into another array, then after the foreach has finished | | empty the first | | array and replace with the fixed one. There must be a better | | way, right | | | | John Edwards | | IT Support | | Runecraft Leeds | | | | Phone: 0113 2206317 | | Fax: 0113 2206301 | | Mobile: 07961 356186 | | | | | | | | --Confidentiality--. | | This E-mail is confidential. It should not be read, copied, | | disclosed or | | used by any person other than the intended recipient. | | Unauthorised use, | | disclosure or copying by whatever medium is strictly | | prohibited and may be | | unlawful. If you have received this E-mail in error please | | contact the | | sender immediately and delete the E-mail from your system. | | | | | | | | -- | | To unsubscribe, e-mail: [EMAIL PROTECTED] | | For additional commands, e-mail: [EMAIL PROTECTED] | | | | | --Confidentiality--. | This E-mail is confidential. It should not be read, copied, | disclosed or | used by any person other than the intended recipient. | Unauthorised use, | disclosure or copying by whatever medium is strictly | prohibited and may be | unlawful. If you have received this E-mail in error please | contact the | sender immediately and delete the E-mail from your system. | | -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Strip charactes from every element in array
When you do a for loop : for (@array) { s/1//g; } the implicit $_ in the loop becomes an alias for the real element - so by modifying the element in the loop you're actually modifying the real one in the array. Luke PS you could use map here as well, but it's in a void context - big no-no :-) I personally liked the s/// for @array expression. On Thu, 23 Aug 2001, John Edwards wrote: Is there any easy way to strip a single character from every element in an array? @array = qw(one1 two1 three1); And I need the elements to be (one two three). My only idea is copy to another array, run a foreach, s/// the char out and push into another array, then after the foreach has finished empty the first array and replace with the fixed one. There must be a better way, right John Edwards IT Support Runecraft Leeds Phone: 0113 2206317 Fax: 0113 2206301 Mobile: 07961 356186 --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: perl version
On Aug 23, HOLLAND-MORITZ,MARCUS (A-hsgGermany,ex1) said: | how could i know which perl version i am using : any command | on unix/linux perl -v Or, if you're sick like me, perl -version number, please -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex help
On Aug 23, Michel Blanc said: sub unique_char_set { my ($str, $chars) = @_; return 0 if $str =~ /[^\Q$chars\E]/; return !($str =~ /(.).*?\1/s); } Thanks for your response guys. This is very useful. In fact, since I needed a one liner (I forgot to say that) for a regex-based dispatch table, I tried to convert that to : Ok. Then use this: if ($str =~ /[^cCdeEfghiIkKlLmMrRstTvVxX]|(.).*?\1/) { # it was a bad string } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Removing Modules
Any ideas on how to remove unwanted modules? And what happens if they have been intertwined with a DLL? TIA, Danial __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Comparison
Hi, If some one can help me out please I am brand new to Perl I wrote a prog which is working fine except for few glitches It should read two text files compare the snap.txt with base.txt and spit out the name of task which is not running in last hour or so The snap log file has list of tasks which are either completed, running or exited with error The snap log file carries log for more then a day or so What I am interested in is about the tasks not running or rendering error in last hour or so My prog list it but since there is a repetition of the same tasks over a period of time so it is not giving the right output I want to get the very latest instance of the task when it is erroring out The Base.txt contains the tasks which I am interested in to check which are like about 10 or so The log files are tab delimited Enclosed is the script along with the two text files Another option is to only read one file and look for specific tasks which are not running and the names of the tasks can be incorporated in the script. In the snap.txt file field 8 gives the task state If someone can help me out with the code in detail I appreciate it. Thanks snap.txt base.txt # Monitoring script use Win32; my($snapshot, $baseline); # Defining txt files # First file $snapshot = ./snap.txt; # List of Svcs currently running, file in c:\perl # Second file $baseline = ./base.txt; # List of All Svcs which should be running my(@arr1, @arr2, @result); # Defining arrays my($fld1, $fld2, $fld3, $fld4, $fld5, $fld6, $fld7, $fld8); # Defining variables for fields my($match, $cnt, $val1, $val2, $finalresult); # Defining scalar variables $match = N; #Open snapshot file and insert every line into @arr1 open(SNAPSHOT, $snapshot) or die Unable to open $snapshot.; # Open the txt file and place it in filehandle $cnt = 0; while ( SNAPSHOT ) # Looping thru the filehandle snapshot { $arr1[$cnt] = $_; $cnt = $cnt + 1; } close (SNAPSHOT); # close the filehandle snapshot #Open baseline file and insert every line into @arr2 open(BASELINE, $baseline) or die Unable to open $baseline.; # Open the txt file and place it in filehandle $cnt = 0; while ( BASELINE ) # Looping thru the filehandle baseline { $arr2[$cnt] = $_; $cnt = $cnt + 1; } close (BASELINE); # close filehandle baseline # Outer loop is for baseline file # Inner loop is for snapshot file # Taking one element from @arr2 (baseline) and comparing it with all the elements in @arr1(snapshot) and # If their is no match then insert that name into @result. $cnt = 0; foreach $val2 (@arr2) # referring to baseline { foreach $val1 (@arr1) # referring to snapshot { if ($val1 eq $val2) { $match = Y; } } if ($match eq N) { $result[$cnt] = $val2; $cnt = $cnt + 1; } $match = N; } $finalresult = 0; # initializing to zero foreach $val1 (@result) { $finalresult = $finalresult + 1; } if ($finalresult 0 ) { print \nList of SICK Siebel-Tasks \n\n; # If some svc is not functioning foreach $val1 (@result) { ($fld1,$fld2,$fld3,$fld4,$fld5,$fld6,$fld7,$fld8) = split(/\|/,$val1);# separating req fields for output print Siebel-Task $fld4; related to Siebel-Component $fld3 \n; } } else { print \nCheers! All Siebel-Tasks are Doing Well!\n; # When all svcs are running fine } SBLSRVR_NAME SVC_NAME COMP_NAME SVC_COMP TASK_NUM TASK_PID SVC_MODE TASK_STATE START_TIME END_TIME TASK_STATUS - - - -- --- --- -- S2_NXLKPRDServerMgr ServerMgr ServerMgr 47148 881 Session NotRunning 08/23/2001 11:14:25 Processing List Tasks command S2_NXLKPRDSynchMgr SynchMgr SynchMgr 47147 Session Completed 08/23/2001 11:14:09 08/23/2001 11:14:09 COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, sent 0 msgs, rcvd 0 msgs S2_NXLKPRDSynchMgr SynchMgr SynchMgr 47146 Session Completed 08/23/2001 11:13:09 08/23/2001 11:13:09 COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, sent 0 msgs, rcvd 0 msgs S2_NXLKPRDSynchMgr SynchMgr SynchMgr 47145 Session Completed 08/23/2001 11:12:09 08/23/2001 11:12:09 COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, sent 0 msgs, rcvd 0 msgs S2_NXLKPRD
hash of ref to array of arrays, lost all but the last element in hash
Dear all, I would like to construct a hash, whose value holds a reference to an array of arrays, however all the keys in my hash have the exact same value, which turns out to be the value of the last element I put it!! I felt that something is wrong in the data structure, that I should not keep re-using @match or @splice, they get overwritten, so I only came with the last one. But I am not sure how to fix it, or is there a way? Any insight is much appreciated!!! -Jennifer #! /usr/bin/perl -w my %hash; my $MatchLine; my $SVLine; while (STDIN) { chomp $_; if (/^Query=(\w+)$/) { if ($key) { @match = split (' ', $MatchLine); @splice = split (' ', $SVLine); $ref = [\@match, \@splice]; $hash{$key}= $ref; $key = $1; } else { $key =$1 } } elsif (/^MA:(.+)$/) { $MatchLine = $1; } elsif (/^SV:(.+)$/) { $SVLine = $1; } else { } } foreach $key (keys %hash) { print $key\n; print $_ for (@$mref); print \n; print $_ for (@$svref); print \n; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Databases and Perl
At 11:39 AM 8/23/01 -0500, [EMAIL PROTECTED] wrote: I am in the process of developing perl code to create and populate a oracle database. Have anyone out there in PerlLand ever developed a process that will create a oracle database, tablespaces and create tables and indexes? If yes, would you mind sharing your code? DB2 would work just as well. Get Programming the Perl DBI by Tim Bunce and Alligator Descartes, from O'Reilly, and with your knowledge of SQL you'll be able to do anything you want with Oracle or DB2 from Perl. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: fatal subroutine
At 03:06 PM 8/21/01 +0100, Andre P. wrote: Hi, I am transfering a script which is calling the fatal subroutine. On the new machine I am getting the following error: Undefined subroutine main::fatal called at This happens when writing: fatal(blah); Wher is the fatal function located. In the code you transferred, or some module or other file it requires in order to work. There is no function 'fatal' in core Perl. It's something made up by the writer of the script you're copying, or by the writer of some file that that script imports. Look in the original script for a definition of fatal, or look in it for use, require, or do statements that reference some file not in core Perl, and look in that file for it. Do I need to include some modules??? I can't find any usefull info in the manuals. any help much appreciated. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Weekly list FAQ posting
NAME beginners-faq - FAQ for the beginners mailing list 1 - Administriva 1.1 - I'm not subscribed - how do I subscribe? Send mail to [EMAIL PROTECTED] You can also specify your subscription email address by sending email to (assuming [EMAIL PROTECTED] is your email address): [EMAIL PROTECTED]. 1.2 - How do I unsubscribe? Now, why would you want to do that? Send mail to [EMAIL PROTECTED], and wait for a response. Once you reply to the response, you'll be unsubscribed. If that doesn't work, find the email address which you are subscribed from and send an email like the following (let's assume your email is [EMAIL PROTECTED]): [EMAIL PROTECTED] 1.3 - There is too much traffic on this list. Is there a digest? Yes. To subscribe to the digest version of this list send an email to: [EMAIL PROTECTED] To unsubscribe from the digest, send an email to: [EMAIL PROTECTED] This is a high traffic list (100+ messages per day), so please subscribe in the way which is best for you. 1.4 - Is there an archive on the web? Yes, there is. It is located at: http://archive.develooper.com/beginners%40perl.org/ 1.5 - How can I get this FAQ? This document will be emailed to the list once a week, and will be available online in the archives, and at http://learn.perl.org/ 1.6 - I don't see something in the FAQ, how can I make a suggestion? Send an email to [EMAIL PROTECTED] with your suggestion. 1.7 - Is there a supporting website for this list? Yes, there is. It is located at: http://beginners.perl.org/ 1.8 - Who owns this list? Who do I complain to? Casey West owns the beginners list. You can contact him at [EMAIL PROTECTED] 1.9 - Who currently maintains the FAQ? Kevin Meltzer, who can be reached at the email address (for FAQ suggestions only) in question 1.6 1.10 - Who will maintain peace and flow on the list? Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large, yet padded, clue-sticks to maintain peace and order on the list. If you are privately emailed by one of these folks for flaming, being off-topic, etc... please listen to what they say. If you see a message sent to the list by one of these people saying that a thread is closed, do not continue to post to the list on that thread! If you do, you will not only meet face to face with a XQJ-37 nuclear powered pansexual roto-plooker, but you may also be taken off of the list. These people simply want to make sure the list stays topical, and above-all, useful to Perl beginners. 1.11 - When was this FAQ last updated? July 11, 2001 2 - Questions about the 'beginners' list. 2.1 - What is the list for? A list for beginning Perl programmers to ask questions in a friendly atmosphere. 2.2 - What is this list _not_ for? * SPAM * Homework * Solicitation * Things that aren't Perl related * Monkeys * Monkeys solicitating homework on non-Perl related SPAM. 2.3 - Are there any rules? Yes. As with most communities, there are rules. Not many, and ones that shouldn't need to be mentioned, but they are. * Be nice * No flaming * Have fun 2.4 - What topics are allowed on this list? Basically, if it has to do with Perl, then it is allowed. You can ask CGI, networking, syntax, style, etc... types of questions. If your question has nothing at all to do with Perl, it will likely be ignored. If it has anything to do with Perl, it will likely be answered. 2.5 - I want to help, what should I do? Subscribe to the list! If you see a question which you can give an idiomatic and Good answer to, answer away! If you do not know the answer, wait for someone to answer, and learn a little. 2.6 - Is there anything I should keep in mind while answering? We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the beginner to the place in the FM they should R :) Please do not quote the documentation unless you have something to add to it. It is better to direct someone to the documentation so they hopefully will read documentation above and beyond that which answers their question. It also helps teach them how to use the documentation. 2.7 - I don't want to post a question if it is in an FAQ. Where should I look first? Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it. It can save everyone time if you look in the Perl FAQs first, instead of having a list of people refer you to the Perl FAQs :) You can learn about 'perldoc' by typing: `perldoc perldoc' At your command prompt. You can also view documentation online at: http://www.perldoc.com and http://www.perl.com 2.8 Is this a high traffic list? YES! You have been warned! If you don't want to get ~100 emails per day from this list,
RE: is this sub called correctly? am I missing something?
I do not believe that you need the before the function call. -Original Message- From: Birgit Kellner [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 23, 2001 12:52 PM To: [EMAIL PROTECTED] Subject: is this sub called correctly? am I missing something? I have a sub called and it doesn't return what it's supposed to return - am I blind or is there something I am missing out on? The script runs with use strict, and no errors are reported. my ($db_key, %rec); # %orderhash contains numeric keys and values, like ('43' = '5', '20' = '17'); I want to call the sub get_record for each of these keys. # NOTE: this works perfectly, with the same syntax, in other parts of the same file. # might the problem be that I'm embedding the call to the sub in a foreach loop here? foreach (keys %orderhash) { $db_key = $_; print Database key: $db_key; #this works fine, so $db_key HAS a numeric value %rec = get_record($db_key); # here's the problem: %rec doesn't get returned print Number: $rec{'number'}; # ouch, no value. } # this is the called sub, contained in another file that we're requiring. # other file also runs under use strict - no errors reported. all variables not declared in the sub are declared globally. # I won't give all explanations about what this does just yet - hoping that this is a simple logic error which I'm too blind to see ... sub get_record { # # Given an ID as input, get_record returns a hash of the # requested record or undefined if not found. my ($key, $found, $line, @data, $field, $restricted, $i, %rec); $key = $_[0]; $found = 0; ($restricted = 1) if ($auth_modify_own and !$per_admin); open (DB, $db_file_name) or cgierr(error in get_records. unable to open db file: $db_file_name.\nReason: $!); if ($db_use_flock) { flock(DB, 1); } LINE: while (DB) { (/^#/) and next LINE; (/^\s*$/) and next LINE; $line = $_; chomp ($line); @data = split_decode($line); next LINE if ($restricted and ($db_userid ne $data[$auth_user_field])); if ($data[$db_key_pos] eq $key) { $found = 1; for ($i = 0; $i = $#db_cols; $i++) { # Map the array columns to a hash. $rec{$db_cols[$i]} = $data[$i]; } last LINE; } } close DB; $found ? (return %rec) : (return undef); } I'd be really grateful for any hints as to what might be wrong - thanks in advance. I've also tried calling the sub without , but it doesn't make a difference. Birgit Kellner -- 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]
Sending emails: Question newbie
Hi all -- I'm trying to send an email with an attachment from the below code (Gary MacDonald posted the code on activestate. Thanks Gary:-). The code works fine to send email to my Imail Server (type of nt mail server) but when I try to send a message to either ny yahoo mail account or my exchange mail server I don't get the body of the message OR the attachment. Any suggestion would be greatly appreciated. Thanks Mike use Net::SMTP; use MIME::Base64; my $file = 'test.doc'; my $mediatype = 'msword'; open INPUT, $file or die Can't open INPUT file $file: $!\n; binmode INPUT; my $buffer; # my $from = '[EMAIL PROTECTED]'; my $to = '[EMAIL PROTECTED]'; my $server = 'smtp.server.com'; # my $smtp = Net::SMTP-new($server) or die Can't create SMTP object\n; # $smtp-mail($from); $smtp-to($to); # my @msg = MSG; From: $from To: $to Subject: word document attachment MIME-Version: 1.0 Content-type: multipart/mixed; boundary=Boundary $time --Boundary $time Content-type: text/plain This is a test email. --Boundary $time Content-type: application/$mediatype; name=$file Content-disposition: attachment; filename=$file Content-transfer-encoding: base64 MSG # $smtp-data(); $smtp-datasend(@msg); $smtp-datasend(encode_base64($buffer)) while(read (INPUT, $buffer, 60*57)); $smtp-datasend(\n--Boundary $time--\n); $smtp-dataend(); $smtp-quit(); # close INPUT; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
The symbol in a variable
Hello, I am *very new* to Perl and to this list. I have a question I am hoping someone can answer. I am looking over an existing Perl script and came across this block of code: # Create the cmdfile my $runprog = $NexBase::idxBase/cmdfiles/$indexname $cmdfile; exit $? if system($runprog); Can anyone tell me what the symbol means here: my $runprog = $NexBase::idxBase/cmdfiles/$indexname $cmdfile; I have looked in O'Reilly's Programming Perl book and found lots of information about the symbol, but I could not see how it relates in the above variable. Any help is appreciated. Thanks, Buffy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: is this sub called correctly? am I missing something?
--On Donnerstag, 23. August 2001 13:01 -0500 Daryl J. Hoyt [EMAIL PROTECTED] wrote: I do not believe that you need the before the function call. I thought so, but leaving it out doesn't solve my problem either. - But thanks anyway. Birgit Kellner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: The symbol in a variable
At 11:20 AM 8/23/01 -0700, Buffy Press wrote: Hello, I am *very new* to Perl and to this list. I have a question I am hoping someone can answer. I am looking over an existing Perl script and came across this block of code: # Create the cmdfile my $runprog = $NexBase::idxBase/cmdfiles/$indexname $cmdfile; exit $? if system($runprog); Can anyone tell me what the symbol means here: my $runprog = $NexBase::idxBase/cmdfiles/$indexname $cmdfile; I have looked in O'Reilly's Programming Perl book and found lots of information about the symbol, but I could not see how it relates in the above variable. That symbol is not going to be used by Perl. The variable $runprog is being initialized to contain a command to be passed to your OS' command line interpreter (the Bourne shell on Unix-y systems). You'll see $runprog used later in that program in either a system() or exec() function call, or between backticks (``) (or, less likely, in an open() call). If you're unfamiliar with the Bourne shell, consult a reference such as Unix Shell Programming by Kochan Wood, Hayden Books (happens to be on the shelf in front of me). -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: is this sub called correctly? am I missing something?
On Thu, Aug 23, 2001 at 07:52:04PM +0200, Birgit Kellner wrote: my ($db_key, %rec); # %orderhash contains numeric keys and values, like ('43' = '5', '20' = '17'); I want to call the sub get_record for each of these keys. # NOTE: this works perfectly, with the same syntax, in other parts of the same file. # might the problem be that I'm embedding the call to the sub in a foreach loop here? No. foreach (keys %orderhash) { $db_key = $_; print Database key: $db_key; #this works fine, so $db_key HAS a numeric value %rec = get_record($db_key); # here's the problem: %rec doesn't get returned What does get returned? print Number: $rec{'number'}; # ouch, no value. Is this what you're using to verify %rec has no keys? Have you tried doing a dump of %rec to see what it does have? For example: use Data::Dumper; print Data::Dumper-([\%rec])-Terse(1)-Useqq(1)-Dump; } # this is the called sub, contained in another file that we're requiring. # other file also runs under use strict - no errors reported. all variables not declared in the sub are declared globally. # I won't give all explanations about what this does just yet - hoping that this is a simple logic error which I'm too blind to see ... sub get_record { # # Given an ID as input, get_record returns a hash of the # requested record or undefined if not found. my ($key, $found, $line, @data, $field, $restricted, $i, %rec); $key = $_[0]; $found = 0; ($restricted = 1) if ($auth_modify_own and !$per_admin); open (DB, $db_file_name) or cgierr(error in get_records. unable to open db file: $db_file_name.\nReason: $!); if ($db_use_flock) { flock(DB, 1); } LINE: while (DB) { (/^#/) and next LINE; (/^\s*$/) and next LINE; $line = $_; chomp ($line); @data = split_decode($line); next LINE if ($restricted and ($db_userid ne $data[$auth_user_field])); if ($data[$db_key_pos] eq $key) { $found = 1; for ($i = 0; $i = $#db_cols; $i++) { # Map the array columns to a hash. $rec{$db_cols[$i]} = $data[$i]; } last LINE; } } close DB; $found ? (return %rec) : (return undef); This can be simplified to simply: return %rec If %rec has data, you'll get key-value pairs; if not, you get an empty list, and thus an empty hash. As it is, if a record couldn't be found, and you use get_record() like you do above, e.g. %rec = get_record(), %rec will have one key, undef, with a value of undef, and you'll get a warning. I doubt if this has any bearing on your problem, I'm just suggesting it as a simplification. } I've also tried calling the sub without , but it doesn't make a difference. It won't. In your case, the '' has no practical purpose. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Sending emails: Question newbie
HI -- Has anyone had a similar problem when sending email with attachments?? Thanks Mike -Original Message- From: Mike Rapuano Sent: Thursday, August 23, 2001 2:07 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; Mike Rapuano Subject: Sending emails: Question newbie Hi all -- I'm trying to send an email with an attachment from the below code (Gary MacDonald posted the code on activestate. Thanks Gary:-). The code works fine to send email to my Imail Server (type of nt mail server) but when I try to send a message to either ny yahoo mail account or my exchange mail server I don't get the body of the message OR the attachment. Any suggestion would be greatly appreciated. Thanks Mike use Net::SMTP; use MIME::Base64; my $file = 'test.doc'; my $mediatype = 'msword'; open INPUT, $file or die Can't open INPUT file $file: $!\n; binmode INPUT; my $buffer; # my $from = '[EMAIL PROTECTED]'; my $to = '[EMAIL PROTECTED]'; my $server = 'smtp.server.com'; # my $smtp = Net::SMTP-new($server) or die Can't create SMTP object\n; # $smtp-mail($from); $smtp-to($to); # my @msg = MSG; From: $from To: $to Subject: word document attachment MIME-Version: 1.0 Content-type: multipart/mixed; boundary=Boundary $time --Boundary $time Content-type: text/plain This is a test email. --Boundary $time Content-type: application/$mediatype; name=$file Content-disposition: attachment; filename=$file Content-transfer-encoding: base64 MSG # $smtp-data(); $smtp-datasend(@msg); $smtp-datasend(encode_base64($buffer)) while(read (INPUT, $buffer, 60*57)); $smtp-datasend(\n--Boundary $time--\n); $smtp-dataend(); $smtp-quit(); # close INPUT; -- 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]
redirecting print output to a variable
Hi, I've got this code: #Example of generated code. I have little influence over the actual code in the variable. It's generated from a template. $generatedCode = '$test = some result; print test is: $test;'; open MYFILE, somefile; select(MYFILE); my $testvar = eval $generatedCode; select(STDOUT); close MYFILE; this prints the result of the generated code in a file called somefile. Is there any way in which I can store the output from the eval $generatedCode; in a variable, be it a string or an array, instead of in a file? I have to do this a lot , and having a file in between slows the code quite a bit. Thanks, Bas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sending emails: Question newbie
Hi all. I´m sending attachments with the following code: (it works ok with mailserver running MS Exchange, and other mailservers too) ### #!/usr/bin/perl use MIME::Lite; use strict; my $subject = Here goes the subject; my $attachfile = File_to_Attach; my $msg = new MIME::Lite ( From='[EMAIL PROTECTED]', To ='[EMAIL PROTECTED]', Cc ='[EMAIL PROTECTED]', Subject =$subject, Type='multipart/mixed'); $msg-attach( Type ='TEXT', Data =$subject); $msg-attach( Type ='TEXT', Path =$attachfile, Filename =$attachfile); $msg-send(); ## Let me know if it works for you... :) Bye Ricardo Derbes Altec SE Albarracín 157 - San Carlos de Bariloche +54-2944-426892 [EMAIL PROTECTED] - Original Message - From: Mike Rapuano [EMAIL PROTECTED] To: Mike Rapuano [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, August 23, 2001 4:17 PM Subject: RE: Sending emails: Question newbie HI -- Has anyone had a similar problem when sending email with attachments?? Thanks Mike -Original Message- From: Mike Rapuano Sent: Thursday, August 23, 2001 2:07 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; Mike Rapuano Subject: Sending emails: Question newbie Hi all -- I'm trying to send an email with an attachment from the below code (Gary MacDonald posted the code on activestate. Thanks Gary:-). The code works fine to send email to my Imail Server (type of nt mail server) but when I try to send a message to either ny yahoo mail account or my exchange mail server I don't get the body of the message OR the attachment. Any suggestion would be greatly appreciated. Thanks Mike use Net::SMTP; use MIME::Base64; my $file = 'test.doc'; my $mediatype = 'msword'; open INPUT, $file or die Can't open INPUT file $file: $!\n; binmode INPUT; my $buffer; # my $from = '[EMAIL PROTECTED]'; my $to = '[EMAIL PROTECTED]'; my $server = 'smtp.server.com'; # my $smtp = Net::SMTP-new($server) or die Can't create SMTP object\n; # $smtp-mail($from); $smtp-to($to); # my @msg = MSG; From: $from To: $to Subject: word document attachment MIME-Version: 1.0 Content-type: multipart/mixed; boundary=Boundary $time --Boundary $time Content-type: text/plain This is a test email. --Boundary $time Content-type: application/$mediatype; name=$file Content-disposition: attachment; filename=$file Content-transfer-encoding: base64 MSG # $smtp-data(); $smtp-datasend(@msg); $smtp-datasend(encode_base64($buffer)) while(read (INPUT, $buffer, 60*57)); $smtp-datasend(\n--Boundary $time--\n); $smtp-dataend(); $smtp-quit(); # close INPUT; -- 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]
a1.a2.a3.a4 - integer
Hi, I can transform an ip a1.a2.a3.a4 to an integer using b1=a1 24 b2=a2 16 b3=a3 8 int =b1+b2+b3+a4 now I want to do the opposite. how can I get a1.a2.a3.a4 from this integer? ok I get a1, but I start to have a headeach to get the rest Thanks Pierre _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
a1.a2.a3.a4 - integer
THIS IS NOW THE 5TH REQUEST. TAKE ME OFF THIS ALIAS. P lerenard plerenard@hoTo: [EMAIL PROTECTED] tmail.com cc: Subject: a1.a2.a3.a4 - integer 08/23/01 04:01 PM Hi, I can transform an ip a1.a2.a3.a4 to an integer using b1=a1 24 b2=a2 16 b3=a3 8 int =b1+b2+b3+a4 now I want to do the opposite. how can I get a1.a2.a3.a4 from this integer? ok I get a1, but I start to have a headeach to get the rest Thanks Pierre _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- 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: a1.a2.a3.a4 - integer
On Aug 23, P lerenard said: I can transform an ip a1.a2.a3.a4 to an integer using b1=a1 24 b2=a2 16 b3=a3 8 int =b1+b2+b3+a4 now I want to do the opposite. how can I get a1.a2.a3.a4 from this integer? ok I get a1, but I start to have a headeach to get the rest Do: while ($x) { unshift @parts, $x % 256; $x = 8; } and that will give you the parts you need. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: a1.a2.a3.a4 - integer
At 02:08 PM 08/23/01, [EMAIL PROTECTED] wrote: THIS IS NOW THE 5TH REQUEST. TAKE ME OFF THIS ALIAS. That's not very productive for this list. What pard of this link didn't you understand? List-Unsubscribe: mailto:[EMAIL PROTECTED] Sen a blank email there. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: a1.a2.a3.a4 - integer
I think you can get it by shifting the correct number of bits and masking off the lower 8 bits. my $x = $b1+$b2+$b3+$b4; $a4 = $x 0xFF; $a3 = ($x8) 0xFF; $a2 = ($x16) 0xFF; $a1 = ($x24) 0xFF; Good Luck! Tanton -Original Message- From: P lerenard To: [EMAIL PROTECTED] Sent: 8/23/2001 4:01 PM Subject: a1.a2.a3.a4 - integer Hi, I can transform an ip a1.a2.a3.a4 to an integer using b1=a1 24 b2=a2 16 b3=a3 8 int =b1+b2+b3+a4 now I want to do the opposite. how can I get a1.a2.a3.a4 from this integer? ok I get a1, but I start to have a headeach to get the rest Thanks Pierre _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- 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: a1.a2.a3.a4 - integer
On Aug 23, Gibbs Tanton - tgibbs said: $a4 = $x 0xFF; $a3 = ($x8) 0xFF; $a2 = ($x16) 0xFF; $a1 = ($x24) 0xFF; D'oh, I forgot -- is faster than %. while ($x) { unshift @parts, $x 256; $x = 8; } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Looking for help with the Translate operator
Good day; I don't know if this is possible... But I'm trying to replace the high-hex symbol for one-half (\xBD) with 1/2 This is what I've tried so far: $variable =~ tr/[\xBD]/1/2/; #tr doesn't like this, so I tried... $replacement = 1/2; $variable =~ tr/[\xBD]/$replacement/; #tr replaces \xBD with 'r', then I tried $variable =~ tr/[\xBD]/\$replacement/; # just to see if the \ in front of the $ would work.. It didn't May be a total brainfart, but I'm stumped. I appreciate any advice. Thank you very much for your time, Carl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Looking for help with the Translate operator
On Aug 23, Carl W Rogers said: I don't know if this is possible... But I'm trying to replace the high-hex symbol for one-half (\xBD) with 1/2 No, you have to use a substitution (s///) for that. tr/// is for character-to-character translations. $variable =~ tr/[\xBD]/1/2/; #tr doesn't like this, so I tried... Fails because of the / in 1/2. You'd have to backslash it, but that doesn't make the tr/// do what you expect. Leave out the [...] in the left-hand side of the tr///, because a tr/// is already using character classes. $replacement = 1/2; $variable =~ tr/[\xBD]/$replacement/; #tr replaces \xBD with 'r', then I tried Fails because tr/// does not interpolate variables. $variable =~ tr/[\xBD]/\$replacement/; # just to see if the \ in front of the $ would work.. It didn't Fails as well. You want: s{\xBD}{1/2}g; Plain and simple: find hex character BD, and replace it with '1/2'. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: a1.a2.a3.a4 - integer
Hello P, Friday, August 24, 2001, P lerenard [EMAIL PROTECTED] wrote: Pl I can transform an ip a1.a2.a3.a4 to an integer using Pl b1=a1 24 Pl b2=a2 16 Pl b3=a3 8 Pl int =b1+b2+b3+a4 Pl now I want to do the opposite. Pl how can I get a1.a2.a3.a4 from this integer? Pl ok I get a1, but I start to have a headeach to get the rest if you interested in ip addresses conversions, you can use use Socket; sub ip2ul { return inet_aton($_[0]); } sub ul2ip { return inet_ntoa($_[0]); } or something like this: sub ip2ul { return unpack( 'N', pack( 'C4', split( /\./, shift ) ) ); } sub ul2ip { return join( '.', unpack( 'C4', pack( 'N', shift ) ) ); } (receipts stolen from russian fido7.ru.perl group) Best wishes, Maximmailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
sendmail and newlines
Situation: My perl script (see Code: below) is being handed a flatfile (see File: below) generated from a database to do a mass mailing that will send a message generic to the flatfile but with each recepient receiving a unique username and password. The message part of the file is being input by a list administrator through an oracle tool (I think, I didn't develop that in anyway) and the ability to have newlines is necessary for formatting. The problem is when this message is dumped into the flatfile, the newlines are still in it and cause the script to go nuts. My idea was to have the newlines in the message replaced with \\n before being put into the flatfile (which is what I have done in my test file). I then attempt to replace the \\n with \n in the $message field for sending. It kind of works. (see Output: below) I get the newlines now, but i also get one \ just out there. I have tried many variations, but having \\n and replacing with \n seems to be the only way to get a newline to work, but how to get rid of the extra \? Any suggestions would be very very appreciated. TIA Code: #!/usr/bin/perl $mailprog = '/usr/sbin/sendmail -t'; $admin_email=decoraw\@act.org; $subject=Testing the new mass mailer; $file = /actapps/suitespot/cgi-bin/sender/returntest3.txt; $number_sent = 0; open(DATA, $file) || die Can't open $file; # open the file for reading while($line = DATA) { chomp $line; ($junk,$email,$message,$survey_url,$login,$password) = split(/\|/,$line); $message =~ s|\\n|\n|g; #replace the escaped newlines with newlines for formatting open (MAIL, |$mailprog -t) || die Can't open $mailprog! \n; print MAIL Content-type:text/plain\n; print MAIL From: $admin_email\n; print MAIL To: $email\n; print MAIL Subject: $subject\n; print MAIL $message\n\n; print MAIL URL: $survey_url\n; print MAIL Login: $login\n; print MAIL Password: $password\n; close(MAIL); $number_sent++; } File: |[EMAIL PROTECTED]|This is my message.\\nI hope these returns will work this time.\\nWendy|http://www.mysite.com/index.html|3|3| Output: This is my message.\ I hope these returns will work this time.\ Wendy URL: http://www.mysite.com/index.html Login: 3 Password: 3 = Wendy Webmistress My computer has an Emmy, how 'bout yours? __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: redirecting print output to a variable
Hello Bas, Thursday, August 23, 2001, Bas Bloemsaat [EMAIL PROTECTED] wrote: BB I've got this code: BB #Example of generated code. I have little influence over the actual code in BB the variable. It's generated from a template. BB $generatedCode = '$test = some result; print test is: $test;'; open MYFILE, somefile; BB select(MYFILE); BB my $testvar = eval $generatedCode; BB select(STDOUT); BB close MYFILE; BB this prints the result of the generated code in a file called somefile. Is BB there any way in which I can store the output from the BB eval $generatedCode; BB in a variable, be it a string or an array, instead of in a file? I have to BB do this a lot , and having a file in between slows the code quite a bit. i'm not sure, that have correctly understand you. may be you need this? $generatedCode = '$test = some result; print test is: $test;'; $generatedCode =~ s/print /return /; my $testvar = eval $generatedCode; print testvar=$testvar; Best wishes, Maximmailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
string checks
What is the best way in Perl to do the following? Check $string to see if the following path is found /this is right/ If found anywhere in the string return 1, if not return 0. The whole pattern must be found just like written. Robert ( Kent ) Collins: IBM Certified Solutions Expert Cell Phone: 214.632.3940 DBA Intranet Site: http://ora3dba.i2.com/support Major advancements in technology are indistinguishable from Magic
Re: string checks
On Thu, Aug 23, 2001 at 06:10:48PM -0500, [EMAIL PROTECTED] wrote: What is the best way in Perl to do the following? Define best. Is it fastest? Most readable? Most clever? Check $string to see if the following path is found /this is right/ If found anywhere in the string return 1, if not return 0. The whole pattern must be found just like written. I'd either use: index($string, /this is right/) != -1 if I'm being frugal with CPU cycles, or $string =~ m|/this is right/| if I'm not, or if I prefer readability at that point. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: is this sub called correctly? am I missing something?
Hello Birgit, Thursday, August 23, 2001, Birgit Kellner [EMAIL PROTECTED] wrote: BK my ($db_key, %rec); BK # %orderhash contains numeric keys and values, like ('43' = '5', '20' = BK '17'); I want to call the sub get_record for each of these keys. BK # NOTE: this works perfectly, with the same syntax, in other parts of the BK same file. BK # might the problem be that I'm embedding the call to the sub in a foreach BK loop here? BK foreach (keys %orderhash) { BK $db_key = $_; BK print Database key: $db_key; #this works fine, so $db_key HAS a numeric BK value BK %rec = get_record($db_key); # here's the problem: %rec doesn't get BK returned BK print Number: $rec{'number'}; # ouch, no value. BK } BK # this is the called sub, contained in another file that we're requiring. BK # other file also runs under use strict - no errors reported. all variables BK not declared in the sub are declared globally. BK # I won't give all explanations about what this does just yet - hoping that BK this is a simple logic error which I'm too blind to see ... BK sub get_record { BK # BK # Given an ID as input, get_record returns a hash of the BK # requested record or undefined if not found. BK my ($key, $found, $line, @data, $field, $restricted, $i, %rec); BK $key = $_[0]; BK $found = 0; BK ($restricted = 1) if ($auth_modify_own and !$per_admin); BK open (DB, $db_file_name) or cgierr(error in get_records. unable to BK open db file: $db_file_name.\nReason: $!); BK if ($db_use_flock) { flock(DB, 1); } BK LINE: while (DB) { BK (/^#/) and next LINE; BK (/^\s*$/) and next LINE; BK $line = $_; chomp ($line); BK @data = split_decode($line); BK next LINE if ($restricted and ($db_userid ne $data[$auth_user_field])); BK if ($data[$db_key_pos] eq $key) { BK $found = 1; BK for ($i = 0; $i = $#db_cols; $i++) { # Map the array columns to a hash. Unfortunatelly, my telepathic abilities still seriously broken :) please put print key = $db_cols[$i], value = $data[$i]; here and show us output. BK $rec{$db_cols[$i]} = $data[$i]; BK } BK last LINE; BK } BK } BK close DB; BK $found ? BK (return %rec) : BK (return undef); BK } Birgit, please, provide as more information as possible with your question, not only piece of code. it's very hard to understand, what can be wrong. Best wishes, Maximmailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Strange foreach need..........
I have a file that has paired lines, in other words I need to process them kinda like one line. Let me 'splain. I read a file into the array @rename foreach $lines (@rename) { do a bunch of stuff here now I need to read the next line to get some info that needs to be processed with the first line info I want to be able to do something like??? $line2=@rename; do some stuff on $line2 write out some stuff } Seems simple enough. I am sure that this is where thinking in Perl comes into play. Since I am a relative newcomer to Perl, I can't quite make the leap required...so. Any and all ideas are welcomed. Be gentle. :-) Thanks -- - They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety. -- Benjamin Franklin - RGary Luther RR RR SAF RR RR UTABEGAS 2500 Broadway RR RRHelena, MT 59602 [EMAIL PROTECTED] RR RR ULE !! RR RR Visit our website at RR RR http://www.safmt.org BEGIN:VCARD VERSION:2.1 X-GWTYPE:USER FN:Gary Luther TEL;WORK:0631 ORG:;Computer Center TEL;PREF;FAX:(406) 444-0684 EMAIL;WORK;PREF;NGW:[EMAIL PROTECTED] N:Luther;Gary TITLE:Systems Administrator END:VCARD -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Strange foreach need..........
On Thu, Aug 23, 2001 at 05:28:42PM -0600, Gary Luther wrote: I have a file that has paired lines, in other words I need to process them kinda like one line. Let me 'splain. I read a file into the array @rename foreach $lines (@rename) { do a bunch of stuff here now I need to read the next line to get some info that needs to be processed with the first line info I want to be able to do something like??? $line2=@rename; do some stuff on $line2 write out some stuff } It'd be easier to accomplish this without using an intermediary array. while (defined($line1 = FILE)) { my $line2 = FILE; ... } Otherwise, there are various solutions to your problem. If you don't mind being destructive: while (my($line1, $line2) = splice(@rename, 0, 2)) { ... } Destructive and possibly a little more readable: while (@rename) { my($line1, $line2) = (shift(@rename), shift(@rename)); ... } Destructive, readable, and possibly faster: @rename = reverse(@rename); while (@rename) { my($line1, $line2) = (pop(@rename), pop(@rename)); ... } Non-destructive for loop: for (my $i = 0; $i @rename; $i += 2) { my($line1, $line2) = ($rename[$i], $rename[$i + 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]
How to close ALL open file descriptors
I open lots of file descriptors in a script. At one point, I want to close all the opened file descriptors (except for stdin, stdout, stderr). Is there a way to close all the opened file descriptors without having a list of the handles ? *** This communication is confidential and is intended only for the person to whom it is addressed. If you are not that person, you are not permitted to make use of the information and you are requested to notify administrator [EMAIL PROTECTED] immediately that you have received it and then destroy/erase the copy/e-mail in your possession. *** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Afew questions and request for help.
On 8/23/01 6:29 PM, Duston S. Horacek wrote: Hello, I'm looking to make a script that will load data into text boxes on a web page from a file off the web host, and then allow other text boxes to be modified by the user, then resaved to the same file.. For instance WEB PAGE LOADS GDP : 1,000,000 (This value is loaded from a text file off the host and is uneditable) Tax Rate: (this is set by the person viewing the web page) Income: (This takes the loaded GDP and the user inputed Tax rate and figures the income) SAVE button: (this saves ALL the fields back to the text file) END WEB PAGE Now I'd also like another version of the same that allows the GM of a game to edit ALL the fields, but this should be easy once I know how to do the other. SO Can some one please tell me how I can read several different fields into text boxes on a web page from a text file from the server, then save them back to the server to be readable again. Your help is very much appreciated! Sincerly, Duston S. Horacek I'm not quite sure what you want. Do you want to know how to read text files? If so, it totally depends on the how the data is formatted on said text files. Maybe you could give us examples of the files you're trying to read? Once you have the data in variables you simply plug them into the value attribute of an input tag, or in between textfield tags. Perhaps if you could show us what you have so far, or be more specific. -Michael Kelly Email: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Afew questions and request for help.
ok, say the web page looks something like this (Very simple) http://www.excelgames.com/sample2.htm goto that and look it over it gicves a visual example of what I'm trying to do. As for what type or format of file, it doesn't matter as I haven't made it yet, as long as the same file can be read and saved to from this web page it matters not. Thanks for the help! I'm not quite sure what you want. Do you want to know how to read text files? If so, it totally depends on the how the data is formatted on said text files. Maybe you could give us examples of the files you're trying to read? Once you have the data in variables you simply plug them into the value attribute of an input tag, or in between textfield tags. Perhaps if you could show us what you have so far, or be more specific. -Michael Kelly Email: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Reusing $1?
In the below code, is the backreference $1 useable as I am intending? #!/usr/bin/perl -w =Script Info:= # # Script : CountCodeRed.pl # Purpose: to scan apache web server access log files and # count the number or code red worm attempts # Created: 08/19/2001 # # Note: # This script reads the apache access log in the common log format (CLF space delimited): # %h - Remote host # %l - Remote Log Name # %u - Remote user # %t - Time Date stamp in the form of [19/Aug/2001:06:28:45 -0600] # %\%r\ - First line of request # %s - Status or request # %b - Bytes sent =cut # path to default log file location $LogFilePath = /var/log/apache/access.log.0; $ProcessDate = ; $DailyHitCount = 0; $DailyCodeRedHits = 0; # open log file for reading open (LOGFILE, $LogFilePath) || die Can't open log file : $!\n; while ($line = LOGFILE) { $line =~ /\[(.+)\] /; # get date time value between [] $ThisDateTime = $1; # should look like 19/Aug/2001:06:28:45 -0600 # this works #($ThisDate, $Junk) = split(/:/, $ThisDateTime); # this is more elegant? Turn 19/Aug/2001:06:28:45 -0600 into 19/Aug/2001 $ThisDateTime =~ / (^.*?:) /; # is this pattern bad? $ThisDate = $1; # or does $1 need to be 'reset'? ... Thanks! Rob Waggoner Master Applications Craftsman WAGGS Web based Advanced Graphics and Graphing Solutions http://www.waggs.net Applying Old world craftsmanship to New world technologies -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reusing $1?
On Aug 23, Rob Waggoner said: while ($line = LOGFILE) { $line =~ /\[(.+)\] /; # get date time value between [] $ThisDateTime = $1; # should look like 19/Aug/2001:06:28:45 -0600 # this works #($ThisDate, $Junk) = split(/:/, $ThisDateTime); # this is more elegant? Turn 19/Aug/2001:06:28:45 -0600 into 19/Aug/2001 $ThisDateTime =~ / (^.*?:) /; # is this pattern bad? $ThisDate = $1; # or does $1 need to be 'reset'? Your whitespace is killing the regex. The regex / ^/ can never match -- there can never be ANYTHING BEFORE the beginning of the line. Also, the $DIGIT variables are not set to undef on a failed match -- they retain their previous values. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reusing $1?
Thank-you. I don't recall that Camel mentioning the white-space subtlety, but I also haven't hit chapter 5 yet. /(.*?):/ gives me what I needed. At 09:17 PM 08/23/01, you wrote: On Aug 23, Rob Waggoner said: while ($line = LOGFILE) { $line =~ /\[(.+)\] /; # get date time value between [] $ThisDateTime = $1; # should look like 19/Aug/2001:06:28:45 -0600 # this works #($ThisDate, $Junk) = split(/:/, $ThisDateTime); # this is more elegant? Turn 19/Aug/2001:06:28:45 -0600 into 19/Aug/2001 $ThisDateTime =~ / (^.*?:) /; # is this pattern bad? $ThisDate = $1; # or does $1 need to be 'reset'? Your whitespace is killing the regex. The regex / ^/ can never match -- there can never be ANYTHING BEFORE the beginning of the line. Also, the $DIGIT variables are not set to undef on a failed match -- they retain their previous values. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Rob Waggoner Master Applications Craftsman WAGGS Web based Advanced Graphics and Graphing Solutions http://www.waggs.net Applying Old world craftsmanship to New world technologies -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]