RE: undefined value error
Xiangli Zhang wrote: Here is my updated code with errorHTTP 500 that did not happened for the old code, and the modules I am using. n.b. that Error 500 is just a catch-all error from the web server. If other error messages from your script were output, you will find them in the web server's error log. So go look there. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Sorting a hash
From: Gunnar Hjalmarsson [EMAIL PROTECTED] You don't need another hash. perldoc -f sort perldoc -q sort a hash my @codes = sort { $comp{$a}{$year}{profit} = $comp{$b}{$year}{profit} } keys %comp; I have tried that, but it gave me an error telling that $year is undefined. $year should be a variable but the sort function should loop through all the years for every code of all the companies, and return the biggest profit. That's why I think I need to use a second hash that uses the code of the companies as a hash key and the profit as its values. Teddy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
perl.beginners.cgi 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 do I complain to? Complaints can be sent to [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? Feb 04, 2004 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.org - http://www.perl.org * Perl Home Page - http://www.perl.com * PerlMonks - http://www.perlmonks.org * Perldoc - http://www.perldoc.com * Perl Archives - http://www.perlarchives.com * NMS Archive - http://nms-cgi.sourceforge.net/ * Unofficial Perl Beginners' Site - http://perl-begin.berlios.de 3.2 - What resources may be harmful to a beginner? Beware of Perl4-like code-- You might find some script archives and unauthorized mirrors with old Perl4 versions of Selena Sol and Matt Wright scripts. Don't use those scripts. They are outdated and may even in some cases
Re: Sorting a hash
Octavian Rasnita wrote: Gunnar Hjalmarsson wrote: You don't need another hash. perldoc -f sort perldoc -q sort a hash my @codes = sort { $comp{$a}{$year}{profit} = $comp{$b}{$year}{profit} } keys %comp; I have tried that, but it gave me an error telling that $year is undefined. Well, since you introduced that variable yourself, I assumed you had set it. $year should be a variable but the sort function should loop through all the years for every code of all the companies, and return the biggest profit. That's why I think I need to use a second hash that uses the code of the companies as a hash key and the profit as its values. Then I tend to agree. Actually you want to do several sorts, not just one. Something like: my %maxprofit; for ( keys %comp ) { my $year = ( sort { $comp{$_}{$b}{profit} = $comp{$_}{$a}{profit} } keys %{ $comp{$_} } )[0]; $maxprofit{$_} = $comp{$_}{$year}{profit}; } -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Removing many files and subdirectories under a folrder
can the above be done with one perl function?
Re: Removing many files and subdirectories under a folrder
Not a perl master, but can't you just do a: system(rm -r dirname); Is that what you mean? Denzil --- John [EMAIL PROTECTED] wrote: can the above be done with one perl function? ___ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Removing many files and subdirectories under a folrder
I want a solution that will work on all platforms. I read in Lerning Perl that unlink * could delete all files. But what if i want to delete all files under a certain directory? will unlink ./mydir/* work? - Original Message - From: Denzil Kruse [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, October 04, 2004 10:26 AM Subject: Re: Removing many files and subdirectories under a folrder Not a perl master, but can't you just do a: system(rm -r dirname); Is that what you mean? Denzil --- John [EMAIL PROTECTED] wrote: can the above be done with one perl function? ___ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Removing many files and subdirectories under a folrder
On Mon, 4 Oct 2004 00:26:22 -0700 (PDT), Denzil Kruse [EMAIL PROTECTED] wrote: Not a perl master, but can't you just do a: system(rm -r dirname); What if its windows system? blahhh... :-000ps..!! Moreover if it was some other **ix type system, I don't think the above code will smell right when cooked. Thats what i guess though. :-) Is that what you mean? Denzil --- John [EMAIL PROTECTED] wrote: can the above be done with one perl function? Yes it can be done using Perl. Read some doc... There are in-built functions called rmdir, mkdir and many more.. Good way to start is 'perldoc perlfunc' for it. [snip] -- Cheers, SanoBabu -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Removing many files and subdirectories under a folrder
Well unlink ./mydir/* worked as i expected for all the files but not directories. - Original Message - From: Sano Babu [EMAIL PROTECTED] To: perlmailing List [EMAIL PROTECTED] Sent: Monday, October 04, 2004 11:01 AM Subject: Re: Removing many files and subdirectories under a folrder On Mon, 4 Oct 2004 00:26:22 -0700 (PDT), Denzil Kruse [EMAIL PROTECTED] wrote: Not a perl master, but can't you just do a: system(rm -r dirname); What if its windows system? blahhh... :-000ps..!! Moreover if it was some other **ix type system, I don't think the above code will smell right when cooked. Thats what i guess though. :-) Is that what you mean? Denzil --- John [EMAIL PROTECTED] wrote: can the above be done with one perl function? Yes it can be done using Perl. Read some doc... There are in-built functions called rmdir, mkdir and many more.. Good way to start is 'perldoc perlfunc' for it. [snip] -- Cheers, SanoBabu -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
array of hashes looping prob
Hey all I'm stuck looping through an array of hashes, here is what I have: ## for my $a (@result){ for my $h (keys %$a){ $tst = $h-{$a}; } } ## @result contains a hashes, I can die it out ok... there is something wrong when I try looping and assigning it to $tst . any ideas? Thanks in advance for any tips. G :) _ It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: array of hashes looping prob
Ok everyone I got it: for my $a (@result){ for my $h (keys %$a){ print $h = $a-{$h} BRBRBR; } } Cheers, G :) From: Graeme McLaren [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: array of hashes looping prob Date: Mon, 04 Oct 2004 10:27:37 +0100 MIME-Version: 1.0 X-Originating-IP: [212.250.155.249] X-Originating-Email: [EMAIL PROTECTED] X-Sender: [EMAIL PROTECTED] Received: from lists.develooper.com ([63.251.223.186]) by mc1-f5.hotmail.com with Microsoft SMTPSVC(5.0.2195.6824); Mon, 4 Oct 2004 02:28:11 -0700 Received: (qmail 17987 invoked by uid 514); 4 Oct 2004 09:28:09 - Received: (qmail 17978 invoked from network); 4 Oct 2004 09:28:08 - Received: from x1.develooper.com (63.251.223.170) by lists.develooper.com with SMTP; 4 Oct 2004 09:28:08 - Received: (qmail 7646 invoked by uid 225); 4 Oct 2004 09:28:08 - Received: (qmail 7638 invoked by alias); 4 Oct 2004 09:28:08 - Received: from bay16-f17.bay16.hotmail.com (HELO hotmail.com) (65.54.186.67) by la.mx.develooper.com (qpsmtpd/0.27.1) with ESMTP; Mon, 04 Oct 2004 02:28:06 -0700 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 4 Oct 2004 02:28:02 -0700 Received: from 212.250.155.249 by by16fd.bay16.hotmail.msn.com with HTTP;Mon, 04 Oct 2004 09:27:37 GMT X-Message-Info: JGTYoYF78jFv9gV82oMMe3ImNAX5LeNb Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm Precedence: bulk List-Post: mailto:[EMAIL PROTECTED] List-Help: mailto:[EMAIL PROTECTED] List-Unsubscribe: mailto:[EMAIL PROTECTED] List-Subscribe: mailto:[EMAIL PROTECTED] Delivered-To: mailing list [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] X-Spam-Status: No, hits=-0.0 required=8.0tests=BAYES_44 X-Spam-Check-By: la.mx.develooper.com Message-ID: [EMAIL PROTECTED] X-OriginalArrivalTime: 04 Oct 2004 09:28:02.0655 (UTC) FILETIME=[72372EF0:01C4A9F4] Return-Path: [EMAIL PROTECTED] Hey all I'm stuck looping through an array of hashes, here is what I have: ## for my $a (@result){ for my $h (keys %$a){ $tst = $h-{$a}; } } ## @result contains a hashes, I can die it out ok... there is something wrong when I try looping and assigning it to $tst . any ideas? Thanks in advance for any tips. G :) _ It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response _ Want to block unwanted pop-ups? Download the free MSN Toolbar now! http://toolbar.msn.co.uk/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
perl regex to array
Hi, I have slightly a tricky situation, in my large program. I am trying the best to reproduce it I have a string like this $x='a{1}b{21}c{5}d'; # The numbers in the {} are random and are not of interest I want to access all elements from the string 'a' 'b' 'c' 'd' How do I do it best ? I am now doing this $x .='{0}'; # So that the next regex works while($x=~/(.+?)\{\d+\}/){ print $1; ... } Is there a better way Thanks Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Net::SFTP and different port than 22
Can i define a different port than 22 ?
RE: Removing many files and subdirectories under a folrder
John wrote: can the above be done with one perl function? No; you need to write a script. You might look at http://ppt.perl.org/commands/rm/index.html for an implementation of rm(1) in Perl. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.
William My impression was that OO in Perl has historically been fraught with William CPU overhead - this will change in Perl 6? (argument number 2) FUD FUD FUD. *All* late binding takes a bit of time. Perl caches what it can. well, i'll be a mother's son! I figured that Perl had to have /some/ problems somewhere. interesting. willy http://www.hackswell.com/corenth -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Removing many files and subdirectories under a folrder
John == John [EMAIL PROTECTED] writes: John can the above be done with one perl function? use File::Path qw(rmtree); rmtree('/some/path/to/the/top'); -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: OT: Email syntax validation
Gunnar == Gunnar Hjalmarsson [EMAIL PROTECTED] writes: Gunnar As a result of the thread Check for valid email address, I have Gunnar modified my emailsyntax() function to better conform to RFC 822. After Gunnar all, I wouldn't like e.g. my contact form module to reject Randal when Gunnar he has changed addresses. ;-) Gunnar I skipped the specification's domain-literal alternative, at least Gunnar for the time being. Gunnar This is the modified function: Again, why aren't you just using Email::Valid? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Need Help with 'Out of Memory!' Error message situation
From: Tony Frasketi [EMAIL PROTECTED] Hello group I'm getting the following error message when running my Perl program: Out of Memory! The program reads in an ASCII file into a string variable $lines. Then parses $lines looking for certain types of entities as follows... while ($lines =~ s/(INSERT INTO.+?)\#end_insert(.+)/$2/si) { # processing goes here } No problem reading in the file. The 'Out of Memory' error occurs as soon as the while statement is first executed. Yeah that's because you force Perl to do unnecessary work. Try to change the code to: while ($lines =~ /(INSERT INTO.+?)\#end_insert/sig) { This will loop through the $lines just as well, but will not force Perl to keep modifying the text. HTH, Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: perl regex to array
From: Ramprasad A Padmanabhan [EMAIL PROTECTED] I have slightly a tricky situation, in my large program. I am trying the best to reproduce it I have a string like this $x='a{1}b{21}c{5}d'; # The numbers in the {} are random and are not of interest I want to access all elements from the string 'a' 'b' 'c' 'd' How do I do it best ? I am now doing this $x .='{0}'; # So that the next regex works while($x=~/(.+?)\{\d+\}/){ print $1; ... } If you are only interested in the letters you may do this: while ($x =~ /([a-zA-Z]+)/g { print $1; ... } Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Removing many files and subdirectories under a folrder
Bob Showalter wrote: John wrote: can the above be done with one perl function? No; you need to write a script. Oops, I guess you can do it in one function. Sorry 'bout that :~) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
SFTP failed to get a file from remote host
Here is the debug monster: sftp: Sent SSH2_FXP_OPEN I:1 P:/usr/local/apache/logs/access_log monster: sftp: Sent message SSH2_FXP_READ I:2 O:0 monster: sftp: Received reply T:103 I:2 monster: sftp: In read loop, got 8192 offset 0 monster: sftp: Sent message SSH2_FXP_READ I:3 O:8192 monster: channel 1: window 16291 sent adjust 16477 monster: sftp: Received reply T:103 I:3 monster: sftp: In read loop, got 8192 offset 8192 monster: sftp: Sent message SSH2_FXP_READ I:4 O:16384 monster: sftp: Received reply T:103 I:4 monster: sftp: In read loop, got 8192 offset 16384 monster: sftp: Sent message SSH2_FXP_READ I:5 O:24576 Do you know what is going on here and why the get method fails?
Re: Removing many files and subdirectories under a folrder
On 04 Oct 2004 05:15:04 -0700, Randal L. Schwartz [EMAIL PROTECTED] wrote: John == John [EMAIL PROTECTED] writes: John can the above be done with one perl function? use File::Path qw(rmtree); rmtree('/some/path/to/the/top'); If the directory has read-only permission shouldn't the program report read-only directory. Can't delete ! or something without having to explicitly die?? Are the semantics heading the right way here?? It seems rmtree is doing 'chmod +wx' or something here before deleteing the dir/file, is it right or is it implementation dependent via the programmer? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! [snip] -- Cheers, SanoBabu -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: SFTP failed to get a file from remote host
On Mon, 4 Oct 2004, John wrote: Here is the debug Where is the code ? Do you know what is going on here and why the get method fails? No. Where is the code ? -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Net::SFTP and different port than 22
On Mon, 4 Oct 2004, John wrote: Can i define a different port than 22 ? I don't see anything about specifying a port in the Net::SFTP docs, but the underlying SSH protocol does provide support for this, so it should be possible. Have you tried specifying the port as part of the host name? my $sftp = Net::SFTP-new(my.host.org:); ? I don't actually know if that will work, but it's worth a try. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: OT: Email syntax validation
Randal L. Schwartz wrote: Gunnar == Gunnar Hjalmarsson [EMAIL PROTECTED] writes: Gunnar As a result of the thread Check for valid email address, I have Gunnar modified my emailsyntax() function to better conform to RFC 822. After Gunnar all, I wouldn't like e.g. my contact form module to reject Randal when Gunnar he has changed addresses. ;-) Gunnar I skipped the specification's domain-literal alternative, at least Gunnar for the time being. Gunnar This is the modified function: Again, why aren't you just using Email::Valid? I have already explained that: http://www.mail-archive.com/beginners%40perl.org/msg62450.html -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: OT: Email syntax validation
Again, why aren't you just using Email::Valid? I have already explained that: http://www.mail-archive.com/beginners%40perl.org/msg62450.html Faulty reasoning, the modules are available for public download to and if they don't have them they'll know it from the error you output about it informing them its needed and be able to install it quite easily perl -MCPAN -e 'install Email::Valid;' The advantages of it far outway the they don't have to install a module argument. That's what modules are for! :) Or you can always include the Email::Valid Module in the public script. That way they don't have to install the module and you can use solid consistent code. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Net::SFTP and different port than 22
On Mon, 4 Oct 2004, Chris Devers wrote: On Mon, 4 Oct 2004, John wrote: Can i define a different port than 22 ? I don't see anything about specifying a port in the Net::SFTP docs, but the underlying SSH protocol does provide support for this, so it should be possible. Have you tried specifying the port as part of the host name? my $sftp = Net::SFTP-new(my.host.org:); ? I don't actually know if that will work, but it's worth a try. Actually, more specifically, Net::SFTP seems to build on Net::SSH::Perl, and that seems to have a Port option: Net::SSH::Perl-new($host, %params) To set up a new connection, call the new method, which connects to $host and returns a Net::SSH::Perl object. new accepts the following named parameters in %params: [] * port The port of the sshd daemon to which you wish to connect; if not specified, this is assumed to be the default ssh port. http://search.cpan.org/~drolsky/Net-SSH-Perl-1.25/lib/Net/SSH/Perl.pm#Net::SSH::Perl-%3Enew($host,_%25params) So it might be possible to have something like this my $sftp = Net::SFTP-new(my.host.org, -port = ); ...or something along those lines. This is completely untested, but it looks like it may work. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: OT: Email syntax validation
Gunnar Hjalmarsson wrote: Randal L. Schwartz wrote: Again, why aren't you just using Email::Valid? I have already explained that: http://www.mail-archive.com/beginners%40perl.org/msg62450.html Interesting; if you visit that link, www.mail-archive.com evidently doesn't properly match RFC822 addresses either: No, that incorrectly invalidates fred[EMAIL PROTECTED] which is a valid working address :~) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: OT: Email syntax validation
JupiterHost.Net wrote: Again, why aren't you just using Email::Valid? I have already explained that: http://www.mail-archive.com/beginners%40perl.org/msg62450.html Faulty reasoning, the modules are available for public download to and if they don't have them they'll know it from the error you output about it informing them its needed and be able to install it quite easily perl -MCPAN -e 'install Email::Valid;' The advantages of it far outway the they don't have to install a module argument. That's what modules are for! :) I hear that you have never distributed CGI scripts to people who typically have never heard of CPAN and don't have shell access, and to whom Perl and CGI are synonyms. That's the 'business' I am in. Or you can always include the Email::Valid Module in the public script. I do that with a few modules, but it makes installation harder and makes it more difficult to maintain my programs. Consequently, I avoid that trouble for trivial things. In this case we are talking about a simple input validation check, aiming to catch typos, and it would not justify that Email::Valid, as well as the non-standard modules it's dependent on, be included in the distribution. That way they don't have to install the module and you can use solid consistent code. I believe that my modified function is solid and consistent enough, but I posted it in the hope to get some feedback on *the code*. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Removing many files and subdirectories under a folrder
From: Sano Babu [EMAIL PROTECTED] On 04 Oct 2004 05:15:04 -0700, Randal L. Schwartz [EMAIL PROTECTED] wrote: John == John [EMAIL PROTECTED] writes: John can the above be done with one perl function? use File::Path qw(rmtree); rmtree('/some/path/to/the/top'); If the directory has read-only permission shouldn't the program report read-only directory. Can't delete ! or something without having to explicitly die?? Are the semantics heading the right way here?? die() does NOT mean write a message to STDERR and exit the program. It means throw an exception. If noone catches the exception print the message to STDERR and exit the program.) See eval BLOCK in perldoc -f eval HTH, Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: OT: Email syntax validation
Bob Showalter wrote: Gunnar Hjalmarsson wrote: Randal L. Schwartz wrote: Again, why aren't you just using Email::Valid? I have already explained that: http://www.mail-archive.com/beginners%40perl.org/msg62450.html Interesting; if you visit that link, www.mail-archive.com evidently doesn't properly match RFC822 addresses either: No, that incorrectly invalidates fred[EMAIL PROTECTED] which is a valid working address :~) Yeah, I noticed that, too. Randal should really think twice before including '' in his real addresses. :) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Net::SFTP and different port than 22
I fixed that Here is the solution my $sftp = Net::SFTP-new($myhost, user=user, password=pass, debug=0,ssh_args = [port =145]) or die(); - Original Message - From: Chris Devers [EMAIL PROTECTED] To: John [EMAIL PROTECTED] Cc: Perl Beginners [EMAIL PROTECTED] Sent: Monday, October 04, 2004 6:27 PM Subject: Re: Net::SFTP and different port than 22 On Mon, 4 Oct 2004, Chris Devers wrote: On Mon, 4 Oct 2004, John wrote: Can i define a different port than 22 ? I don't see anything about specifying a port in the Net::SFTP docs, but the underlying SSH protocol does provide support for this, so it should be possible. Have you tried specifying the port as part of the host name? my $sftp = Net::SFTP-new(my.host.org:); ? I don't actually know if that will work, but it's worth a try. Actually, more specifically, Net::SFTP seems to build on Net::SSH::Perl, and that seems to have a Port option: Net::SSH::Perl-new($host, %params) To set up a new connection, call the new method, which connects to $host and returns a Net::SSH::Perl object. new accepts the following named parameters in %params: [] * port The port of the sshd daemon to which you wish to connect; if not specified, this is assumed to be the default ssh port. http://search.cpan.org/~drolsky/Net-SSH-Perl-1.25/lib/Net/SSH/Perl.pm#Net:: SSH::Perl-%3Enew($host,_%25params) So it might be possible to have something like this my $sftp = Net::SFTP-new(my.host.org, -port = ); ...or something along those lines. This is completely untested, but it looks like it may work. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
perl.beginners 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 do I complain to? You can send complaints to [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? Feb 04, 2004 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, consider subscribing to the digest. 2.9 Other tips before posting to the list
Re: OT: Email syntax validation
Gunnar Hjalmarsson wrote: JupiterHost.Net wrote: Again, why aren't you just using Email::Valid? I have already explained that: http://www.mail-archive.com/beginners%40perl.org/msg62450.html Faulty reasoning, the modules are available for public download to and if they don't have them they'll know it from the error you output about it informing them its needed and be able to install it quite easily perl -MCPAN -e 'install Email::Valid;' The advantages of it far outway the they don't have to install a module argument. That's what modules are for! :) I hear that you have never distributed CGI scripts to people who You hear? From who? Who told! :) typically have never heard of CPAN and don't have shell access, and to I have actually but I educate them briefly on the benefits and then we use FTP if need be ;p Plus if I had host that wasn't willing to install Email::Valid for me so I could use it in a script, I'd dump 'em fast :) whom Perl and CGI are synonyms. That's the 'business' I am in. Bummer :) Or you can always include the Email::Valid Module in the public script. I do that with a few modules, but it makes installation harder and makes it more difficult to maintain my programs. Consequently, I avoid that trouble for trivial things. In this case we are talking about a simple input validation check, aiming to catch typos, and it would not justify that Email::Valid, as well as the non-standard modules it's dependent on, be included in the distribution. That way they don't have to install the module and you can use solid consistent code. I believe that my modified function is solid and consistent enough, but I posted it in the hope to get some feedback on *the code*. cool, sometimes the paradigm needs changed though and not the code :) I'm happy if you're happy! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: perl regex to array
On Oct 4, Ramprasad A Padmanabhan said: I have a string like this $x='a{1}b{21}c{5}d'; # The numbers in the {} are random and are not of interest I want to access all elements from the string 'a' 'b' 'c' 'd' How do I do it best ? I'd do: my @parts = split /{\d+}/, $string; -- Jeff japhy Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: sum a column
I tried the suggestion below, and it appears to have worked, thanks. I had to add a print $sum != to inside and outside the while loop. Im not sure why it is working this way?? Also Im getting an error Use of uninitialized value in string ne at ./clean1.pl line 28, LOG line 1. ?? If anyone can explain I would appericate: #!/usr/bin/perl use Socket; use strict; use POSIX 'strftime'; use warnings; my $line = $ARGV[0]; my $time = strftime %y%m%d%H, localtime; my $sum = 0; my $prev_date; # open the file open(LOG,$line) or die Unable to open LOG:$!\n; print Date_Time, SRCIP, DSTIP, TOTALBYTES \n; # read it in one record at a time #while (LOG) { while ($line = LOG) { next if $line =~ /^\D/; my ($logdate,$srcip,$dstip,$totalbytes) = split(/\t/,$line); my ($date,$time)= split(/\s/,$logdate); my @hour = split(/:/,$time); my $current_date = $date; if ($hour[0] = 6 and $hour[0] 22){ if ($prev_date ne $current_date) {##LINE 28## #print Total: $sum\n;# display before clearing, Prints a Total: 0 on first line if ($sum != 0) { print Total: $sum\n; } $sum = 0; } $sum += $totalbytes; $prev_date = $current_date; print $logdate,$srcip,$dstip,$totalbytes; } # End Of While: } if ($sum != 0) { print Total: $sum\n; } # close the file close(LOG); output: Date_Time, SRCIP, DSTIP, TOTALBYTES Use of uninitialized value in string ne at ./clean1.pl line 28, LOG line 1. 01-01-2004 12:56:48,192.168.1.1,192.168.2.2,2768 01-01-2004 12:56:48,192.168.2.2,192.168.1.1,438 Total: 3206 01-02-2004 16:49:45,192.168.3.3,192.168.4.4,364 01-02-2004 16:49:45,192.168.4.4,192.168.3.3,513 Total: 877 Thank You. Rob -Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Thursday, September 30, 2004 5:32 PM To: rmck; [EMAIL PROTECTED] Subject: Re: sum a column Hello, Im trying to sum up a column from my results. Help. current output: Date_Time, SRCIP, DSTIP, TOTALBYTES 01-01-2004 12:56:48, 192.168.1.1, 192.168.2.2, 2768 Sum Of Bytes = 2768 01-01-2004 12:56:48, 192.168.2.2, 192.168.1.1, 438 Sum Of Bytes = 876 01-02-2004 16:49:45, 192.168.3.3, 192.168.4.4, 9058 Sum Of Bytes = 27174 01-02-2004 16:49:45, 192.168.4.4, 192.168.3.3, 918 Sum Of Bytes = 3672 goal: Date_Time, SRCIP, DSTIP, TOTALBYTES 01-01-2004 12:56:48, 192.168.1.1, 192.168.2.2, 2768 01-01-2004 12:56:48, 192.168.2.2, 192.168.1.1, 438 Sum Of Bytes = 3206 01-02-2004 16:49:45, 192.168.3.3, 192.168.4.4, 364 01-02-2004 16:49:45, 192.168.4.4, 192.168.3.3, 513 Sum Of Bytes = 877 Im stuck. Should I use a hash?? Hash shouldn't be necessary unless they are not ordered. Current Script: #!/usr/bin/perl use Socket; use strict; use POSIX 'strftime'; use warnings; my $time = strftime %y%m%d%H, localtime; my $count = 0; No need to quote integers during assignment. # open the file open(LOG,@ARGV) or die Unable to open LOG:$!\n; Why are you opening @ARGV, doesn't seem like this would work, that or Perl is doing something under the hood that I don't expect, but very little surprises me :-). print Date_Time, SRCIP, DSTIP, TOTALBYTES \n; # read it in one record at a time while (LOG) { my ($logdate,$srcip,$dstip,$totalbytes) = split(/\t/,$_); my ($date,$time )= split(/\s/,$logdate); my @hour = split(/:/,$time); You can capture the above to get just the hour if you want to, with, my ($hour) = split(/:/, $time); next if $_ =~ /^\D/; Why do this down here, it seems it would be more efficient to catch it as early as possible. if ($hour[0] = 6 and $hour[0] 22){ print $logdate,$srcip,$dstip,$totalbytes; $count++; my $sum = $count * $totalbytes; This is likely your problem. Are you really trying to sum the # of bytes? If so why are you multiplying it times the $count, which is seemingly the line of the file that you are currently processing. Also, $sum will have to be scoped ouside the loop otherwise it will be reset for each line of input that you process, you really need to keep it for each iteration and then only clear it when the hour/date you are currently on is not the same as the previous hour/date. print Sum of Bytes = $sum\n; } } # close the file close(LOG); Thanks for any input.. Rob So in pseudo code it will look something like: my $sum = 0; my $prev_date; while (my $line = LOG) { . . . my $current_date = ; if ($prev_date ne $current_date) { print Total: $sum\n;# display before clearing $sum = 0; } $sum += $totalbytes; $prev_date = $current_date; } # don't forget the last one, aka the while loop has stopped # so we need one last date change if ($sum != 0) { print Total: $sum\n; } http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: OT: Email syntax validation
JupiterHost.Net wrote: Gunnar Hjalmarsson wrote: I hear that you have never distributed CGI scripts to people who You hear? From who? Who told! :) Well, that was the only explanation I could figure out to your firm opinion in the matter. typically have never heard of CPAN and don't have shell access, and to I have actually but I educate them briefly on the benefits and then we use FTP if need be ;p Sorry if I was presumptive, but I still believe we are talking about different target audiences. Plus if I had host that wasn't willing to install Email::Valid for me so I could use it in a script, I'd dump 'em fast :) The users of my programs may have other priorities. I believe that my modified function is solid and consistent enough, but I posted it in the hope to get some feedback on *the code*. cool, sometimes the paradigm needs changed though and not the code :) I'm happy if you're happy! When people undiscriminatingly advocate the use of modules whenever possible, I get unhappy. I'm using modules when I consider it to be suitable. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: OT: Email syntax validation
When people undiscriminatingly advocate the use of modules whenever possible, I get unhappy. I'm using modules when I consider it to be suitable. Peace my friend, do whatever you want. It wasn't an attack, that's what the smiley's are for :) Chill chill chill ;p -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Need help with script
On Thu, Sep 30, 2004 at 04:44:36PM -0700, John W. Krahn wrote: Paul Johnson wrote: On Wed, 2004-09-29 at 21:25, JupiterHost.Net wrote: perl -l -00pe's/\n/\t/;s/\//g;' FILENAME $ perl -MO=Deparse -l00pe's/\n/\t/;s/\//g' BEGIN { $/ = \n; $\ = \000; } In your example you have removed the -0 switch so it is doing something completely different. Oops. Quite right. Must remember not to stop checking my posts until they are correct. Thanks, John. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: OT: Email syntax validation
JupiterHost.Net wrote: When people undiscriminatingly advocate the use of modules whenever possible, I get unhappy. I'm using modules when I consider it to be suitable. Peace my friend, do whatever you want. It wasn't an attack, that's what the smiley's are for :) I didn't think you were attacking me. I thought we were discussing the use of modules in Perl programs in general, and in scripts distributed to 'non Perl-geeks' in particular. Smileys are nice, but they don't change the fact that we seem to have slightly different views on the matter, right? ;-) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: OT: Email syntax validation
Gunnar Hjalmarsson wrote: JupiterHost.Net wrote: When people undiscriminatingly advocate the use of modules whenever possible, I get unhappy. I'm using modules when I consider it to be suitable. Peace my friend, do whatever you want. It wasn't an attack, that's what the smiley's are for :) I didn't think you were attacking me. I thought we were discussing the use of modules in Perl programs in general, and in scripts distributed to 'non Perl-geeks' in particular. Smileys are nice, but they don't change the fact that we seem to have slightly different views on the matter, right? ;-) ok -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Can you help me design a perl class/classes ?
Hey all .. I'm thinkin about writing a web application using perl and object oriented techniques. I want to start off small ... lets say I want to put together a company intranet and the part I want to implement first is staff profiles. Each profile would contain their email address, name, username, picture, position, favourite quote etc. I'm thinking of implementing a profile class and a profiles class. the profile class would be a template class and the profiles class would be an abstraction of profile which would act like a container class for all the profile objects. I'm really unclear on object oriented programming, especially in perl as it doesn't really support OO properly. Can anyone give me some guidance as to how I would go about doing this, what methods I would need etc ... I'm a bit lost with this . Cheers for any advice. Graeme :) _ It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
speed of grep{s///} vs ??? or am i asking the wrong question?
here's what works for me so far: #!/usr/bin/perl use strict; use warnings; sub get_subdirectories{ # retrieves list of directories from passed directory # returns directory list as an array my $directory = shift; open LS, ls -l $directory|; local $/ = undef; my @dirs = grep {s/^d.*?\s*?(\w*)$/$1/} split ( /\n/, LS); } my @results = get_subdirectories(/home/corenth); print @results; __END__ --- now- just curious about speeding it up- pehaps a module would be fine, but i'd like to try this out explicitly. -- i think the s/// is what bothers me most. since i'm not all that comfortable with map() and grep() especialy in block form (perldoc -f grep and perldoc -f map) i'm not sure if what i'm doing really takes advantage of the features that these functions have to offer. any advice? thanks :) willy http://www.hackswell.com/corenth -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Serial Port Access
I'm looking for a module that will allow me to send/receive ascii data to a serial port. I have a program that will allow me to query its status over a serial connection, but I can't find a module on CPAN to handle the interface. Well, at least I'm not seeing one for *nix, I did find Win32API::CommPort, Win32::SerialPort, and Mac::Serial. Can someone point me in the right direction? Tim Donahue -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: speed of grep{s///} vs ??? or am i asking the wrong question?
#!/usr/bin/perl use strict; use warnings; sub get_subdirectories{ # retrieves list of directories from passed directory # returns directory list as an array my $directory = shift; open LS, ls -l $directory|; local $/ = undef; my @dirs = grep {s/^d.*?\s*?(\w*)$/$1/} split ( /\n/, LS); } my @results = get_subdirectories(/home/corenth); print @results; __END__ Try this, you don't need to shell out. It returns an array of subdirectories. opendir LS, $directory or die Can't opendir $directory: $!; my @dirs = grep { -d $_ } readdir LS; closedir LS; return @dirs; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Serial Port Access
On Mon, 4 Oct 2004, Tim Donahue wrote: I'm looking for a module that will allow me to send/receive ascii data to a serial port. I have a program that will allow me to query its status over a serial connection, but I can't find a module on CPAN to handle the interface. Well, at least I'm not seeing one for *nix, I did find Win32API::CommPort, Win32::SerialPort, and Mac::Serial. Can someone point me in the right direction? 90 seconds on Google turned this up: http://search.cpan.org/~cook/Device-SerialPort-1.02/SerialPort.pm Does it get you anywhere ? -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Doubt
How can I do to concatenate 2 strings? *** Esta mensagem pode conter informacoes confidenciais e privadas. A nao ser que voce seja o destinatario (ou autorizado pelo destinatario para receber esta mensagem), voce nao podera usar, copiar, distribuir ou divulgar para ninguem esta mensagem ou qualquer informacao nela contida. Se voce recebeu esta mensagem por engano, por favor comunique ao remetente, e apague a mensagem. Muito obrigado. This message contains information which may be confidential and privileged. Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail, and delete the message. Thank you very much. ***
Re: Doubt
On Mon, 4 Oct 2004 18:33:51 -0300, Sprogis, Rubens (V-Emeritis) [EMAIL PROTECTED] wrote: How can I do to concatenate 2 strings? Hi! Glad you are trying Perl! Welcome to the group! Let me offer you some advice. This mailing list works best when you write some of your own code, try it, test it and debug it yourself. THEN, if you still have trouble, post you code to this list and we'll help you. If you send us no code, we can't tell where your problem is. If you haven't written any code yet, keep in mind that we are NOT a free, code-writing service. Now, I am SURE you can find some answers to your problems on the net. I'll give you a hint. Try this web site first: http://learn.perl.org/ --Errin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
How can I do to concatenate 2 strings?, was Re: Doubt
Please use a constructive subject line. On Mon, 4 Oct 2004, Sprogis, Rubens (V-Emeritis) wrote: How can I do to concatenate 2 strings? There are many ways to do it. Here's one of them: $foo = $a . $b; This should be introductory material in any beginner's Perl book. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
CPAN
Hello! Anyone know how to remove a mirror from the list that CPAN uses? I would like to remove ftp://carroll.cac.psu.edu from the list as it keeps timing out Thanks! -- --==[ Bob Gordon ]==-- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
deleting a mirror from CPAN.pm, was Re: CPAN
Please use a more descriptive subject line. On Mon, 4 Oct 2004, Bob Gordon wrote: Anyone know how to remove a mirror from the list that CPAN uses? I would like to remove ftp://carroll.cac.psu.edu from the list as it keeps timing out Do you have a file at ~/.cpan/CPAN/MyConfig.pm ? If so, it's a declaration like CPAN::Config hash $CPAN::Config = { 'build_cache' = q[10], 'build_dir' = q[/Users/Shared/.cpan/build], # ... several lines skipped ... 'urllist' = [q[ftp://ftp.cise.ufl.edu/pub/mirrors/CPAN/], q[ftp://ftp.cpanel.net/pub/CPAN/], q[ftp://ftp.cs.colorado.edu/pub/perl/CPAN/], q[ftp://ftp.dc.aleron.net/pub/CPAN/], q[ftp://ftp.duke.edu/pub/perl/]], 'wget' = q[], }; 1; All you have to do is find and edit the 'urllist' declaration line. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: deleting a mirror from CPAN.pm, was Re: CPAN
On Mon, 4 Oct 2004 19:04:09 -0400 (EDT), Chris Devers [EMAIL PROTECTED] wrote: Anyone know how to remove a mirror from the list that CPAN uses? I would like to remove ftp://carroll.cac.psu.edu from the list as it keeps timing out Do you have a file at ~/.cpan/CPAN/MyConfig.pm ? If so, it's a declaration like CPAN::Config hash $CPAN::Config = { 'build_cache' = q[10], 'build_dir' = q[/Users/Shared/.cpan/build], # ... several lines skipped ... 'urllist' = [q[ftp://ftp.cise.ufl.edu/pub/mirrors/CPAN/], q[ftp://ftp.cpanel.net/pub/CPAN/], q[ftp://ftp.cs.colorado.edu/pub/perl/CPAN/], q[ftp://ftp.dc.aleron.net/pub/CPAN/], q[ftp://ftp.duke.edu/pub/perl/]], 'wget' = q[], }; 1; All you have to do is find and edit the 'urllist' declaration line. Thanks.. Didn't find it there but I was able to locate it in /usr/local/lib/perl5/5.8.5/CPAN -- --==[ Bob Gordon ]==-- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: array of hashes looping prob
From: Graeme McLaren mailto:[EMAIL PROTECTED] wrote: : Ok everyone I got it: : : for my $a (@result){ : : for my $h (keys %$a){ : : print $h = $a-{$h} BRBRBR; : } : } Avoid using $a and $b as variables. They are used by 'sort' and treated special by perl. Use descriptive variables instead. I used $key because I don't know how result is organized. ($column, $section, $row, etc. would be better.) for my $result ( @result ) { for my $key ( keys %$result ) { print $key = $result-{$key}BRBRBR; } } HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Problems installing IPC::Run on Mac OS X 10.3.5
Hello! I'm having some difficulty installing IPC::Run on Mac OS X 10.3.5. perl -v returns This is perl, v5.8.1-RC3 built for darwin-thread-multi-2level (with 1 registered patch, see perl -V for more detail) Interested parties can find perl -V output at the end of this email. I'm using CPANPLUS to install IPC::Run and get the following error (truncated a bit for clarity): -- snip / t/run..# Test 1 got: '012-89--' (t/run.t at line 160) # Expected: '012-8---' # t/run.t line 160 is: sub { ok( _map_fds, $fd_map ) ; $fd_map = _map_fds }, FAILED test 1 Failed 1/266 tests, 99.62% okay snip / Failed Test Stat Wstat Total Fail Failed List of Failed --- t/run.t 2661 0.38% 1 (1 subtest UNEXPECTEDLY SUCCEEDED), 61 subtests skipped. Failed 1/15 test scripts, 93.33% okay. 1/703 subtests failed, 99.86% okay. make: *** [test_dynamic] Error 45 MAKE TEST failed! - in CPANPLUS::Internals::Make::_make at Tue Oct 5 09:52:37 2004 at /Library/Perl/5.8.1/CPANPLUS/Internals/Make.pm line 503 An error occurred handling module IPC::Run in CPANPLUS::Internals::Install::_install_module at Tue Oct 5 09:52:37 2004 at /Library/Perl/5.8.1/CPANPLUS/Internals/Install.pm line 170 Installing IPC::Run failed! in CPANPLUS::Backend::install at Tue Oct 5 09:52:37 2004 at /Library/Perl/5.8.1/CPANPLUS/Backend.pm line 255 Error installed IPC::Run Problem installed one or more modules *** You can view the complete error buffer by pressing 'p' *** CPAN Terminal p Could not find or check module 'IPC::Run' in CPANPLUS::Internals::_can_use at Tue Oct 5 09:52:13 2004 Could not find or check module 'IPC::Run' in CPANPLUS::Internals::_can_use at Tue Oct 5 09:52:14 2004 Could not find or check module 'IPC::Run' in CPANPLUS::Internals::_can_use at Tue Oct 5 09:52:16 2004 Use of uninitialized value in concatenation (.) or string at t/pty.t line 256. in CPANPLUS::Internals::__ANON__ at Tue Oct 5 09:52:22 2004 Use of uninitialized value in concatenation (.) or string at t/pty.t line 257. in CPANPLUS::Internals::__ANON__ at Tue Oct 5 09:52:22 2004 # Test 1 got: '012-89--' (t/run.t at line 160) in CPANPLUS::Internals::__ANON__ at Tue Oct 5 09:52:23 2004 # Expected: '012-8---' in CPANPLUS::Internals::__ANON__ at Tue Oct 5 09:52:23 2004 # t/run.t line 160 is: sub { ok( _map_fds, $fd_map ) ; $fd_map = _map_fds }, in CPANPLUS::Internals::__ANON__ at Tue Oct 5 09:52:23 2004 v-strings are deprecated at (eval 1) line 1. in CPANPLUS::Internals::__ANON__ at Tue Oct 5 09:52:37 2004 v-string in use/require non-portable at (eval 1) line 3. in CPANPLUS::Internals::__ANON__ at Tue Oct 5 09:52:37 2004 Failed 1/15 test scripts, 93.33% okay. 1/703 subtests failed, 99.86% okay. in CPANPLUS::Internals::__ANON__ at Tue Oct 5 09:52:37 2004 make: *** [test_dynamic] Error 45 in CPANPLUS::Internals::__ANON__ at Tue Oct 5 09:52:37 2004 MAKE TEST failed! - in CPANPLUS::Internals::Make::_make at Tue Oct 5 09:52:37 2004 An error occurred handling module IPC::Run in CPANPLUS::Internals::Install::_install_module at Tue Oct 5 09:52:37 2004 Installing IPC::Run failed! in CPANPLUS::Backend::install at Tue Oct 5 09:52:37 2004 Stack printed successfully - Googling hasn't revealed much other than a report of the same failure on perl.cpan.testers with, unfortunately, no solution. I get the same t/run.t error installing via CPAN as well. Any ideas or suggestions? It seems that IPC::Run to install other modules I'm interested in using. Thanks for any and all assistance. Michael $ perl -V Summary of my perl5 (revision 5.0 version 8 subversion 1 RC3) configuration: Platform: osname=darwin, osvers=7.0, archname=darwin-thread-multi-2level uname='darwin hampsten 7.0 darwin kernel version 6.0: fri jul 25 16:58:41 pdt 2003; root:xnu-344.frankd.rootsxnu-344.frankd~objrelease_ppc power macintosh powerpc ' config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe -Dldflags=-Dman3ext=3pm -Duseithreads -Duseshrplib' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-g -pipe -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include', optimize='-Os', cppflags='-no-cpp-precomp -g -pipe -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include' ccversion='', gccversion='3.3 20030304 (Apple Computer, Inc. build 1495)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long',
smtp support attach?
could any one tell me that SMTP::Net support attachment, if yes how it could be to do so... thanks -- Allah Hafiz O! God Thy sea is so great and my boat is so small. Adam -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: How TO CREATE RUNTIME CONTROLS
atul ashpalia [EMAIL PROTECTED] wrote: Please reply to the list. : Thanks in advance for your help. please find the : attached filltasks.cgi. Why attached it? Show it inline. where it is easier to view. You are not using strict and warnings. How did you learn perl? use strict; use warnings; : use CGI; : : $query = new CGI; my $query = new CGI; : print $query-header; : : printEOF; : : HTML : HEAD : TITLEDaily Report/TITLE : /HEAD : BODY BGCOLOR=#EE [snipped form] : br : a href=filltasks.cgiNew Task/a : : brbrbr : input type=submit value=Submit : : /center : /form : : /BODY : /HTML : : EOF First thing you need to do is name your input fields and text areas. The name you use for the first fieldset would probably be numbered and the next ones would increment. : There's a hyperlink 'New Tasks' above the submit button. On : click of which i want to add the whole 'Fill Tasks' section : below the first one. You would need some indicator to tell the script that a new field is being added. a href=filltasks.cgi?action=new_taskNew Task/a Then in the script you would need to check the 'action' parameter. if ( $query-param( 'action' ) eq 'new_task' ) { # add fieldset with new names for each input # and print larger form } else { # print small form } Your next problem is how to maintain data across page updates and how to increment field names for each new fieldset. You might use a link like this. a href=filltasks.cgi?action=task-1New Task/a And then in the new link use a href=filltasks.cgi?action=task-2New Task/a To preserve data you could use a submit button instead of a link. These should submit the form allowing data to be kept across pages. input type=hidden name=task-count value=1 input type=submit name=new-task value=Add a new task : Then, the same hyperlink should appear below the : second 'Fill Tasks' section so that i can include the : third 'Fill Tasks' section below the second one, on : click of that link. And So on... : That is, the user may want to include as many tasks he/she want : to enter. : : On submit button click, the page is directed to : 'displaytasks.cgi' wherein i will display the user's data. You'd probably do better sending it to the same script as produced it. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response