number
Hi there I'm a new bird to Perl - and I have a little problem. I have a file input where I split the file into an array and that works fine, but there is some spam in the beginning of the file I want to get rid of - the problem is that I never know how many lines there is with this spam! Therefore I want to make a check that excludes all lines there doesn't start with a number in other languages I would make a check like If (! isNaN(string)) { } How do I make this check In Perl? I haven't been able to find something similar in Perl, but I know that it should be possible. Best regards Bo -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: number
on Thu, 20 Jun 2002 18:16:59 GMT, Bo Mangor wrote: I have a file input where I split the file into an array and that works fine, but there is some spam in the beginning of the file I want to get rid of - the problem is that I never know how many lines there is with this spam! Therefore I want to make a check that excludes all lines there doesn't start with a number [...] How do I make this check In Perl? #! perl -w use strict; while (DATA) { last if /^\d+/; } do { print; # or do something else with $_ } while (DATA); __DATA__ spam spam spam more spam 1 no spam 2 no spam either 25455487 and this neither -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: number
Sorry, that was hasty...shoulda been something more like my $file = '/path/to/file'; open(THEFILE,$file); my @ary = THEFILE; close(THEFILE); for my $line(@ary) { if($line !~ /^\d/) { } } -Original Message- From: Bo Mangor [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 20, 2002 1:17 PM To: [EMAIL PROTECTED] Subject: number Hi there I'm a new bird to Perl - and I have a little problem. I have a file input where I split the file into an array and that works fine, but there is some spam in the beginning of the file I want to get rid of - the problem is that I never know how many lines there is with this spam! Therefore I want to make a check that excludes all lines there doesn't start with a number in other languages I would make a check like If (! isNaN(string)) { . } How do I make this check In Perl? I haven't been able to find something similar in Perl, but I know that it should be possible. Best regards Bo -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
SV: number
Hi again Great thanks to all the quickly answers! I tried a couple of them and - yes it works - thanks! But how does it work? if(string =~/^[0-9]/) The part string =~/^[0-9]/ - does it split the string into single numbers and check if each of them is a part of the list [0-9] ?? I want to be scour that I have understood the Principe correct. Best regards Bo -Oprindelig meddelelse- Fra: Christopher G Tantalo [mailto:[EMAIL PROTECTED]] Sendt: 20. juni 2002 20:25 Til: Bo Mangor Emne: Re: number Bo Mangor wrote: Hi there I'm a new bird to Perl - and I have a little problem. I have a file input where I split the file into an array and that works fine, but there is some spam in the beginning of the file I want to get rid of - the problem is that I never know how many lines there is with this spam! Therefore I want to make a check that excludes all lines there doesn't start with a number in other languages I would make a check like If (! isNaN(string)) { } How do I make this check In Perl? if(string =~/^[0-9]/) { # do something # number at start of string... } else { # do something else } that should work I haven't been able to find something similar in Perl, but I know that it should be possible. Best regards Bo -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- --- Just Your Friendly Neighborhood _SPIDEY_ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SV: number
Bo Mangor wrote: But how does it work? if(string =~/^[0-9]/) The part string =~/^[0-9]/ - does it split the string into single numbers and check if each of them is a part of the list [0-9] ?? I want to be scour that I have understood the Principe correct. i would suggest reading the perl faq on regular expressions: http://www.perldoc.com/perl5.6/pod/perlfaq6.html or buying a book on them: http://www.oreillynet.com/search/index.ncsp?sp-q=mastering+regular+expressionssp-k=all -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: number
if($string =~ /^[0-9]/) checks to see if the string starts with 0. If it doesn't, it checks if the string starts with 1. If it doesn't, it checks if the string starts with 2, and so on until the condition is true. If the condition is never true, then it will do whatever is in your else {} (or elsif). The ^ character means starts with in a regex. Scot R. inSite -Original Message- From: Bo Mangor [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 20, 2002 1:49 PM To: [EMAIL PROTECTED] Subject: SV: number Hi again Great thanks to all the quickly answers! I tried a couple of them and - yes it works - thanks! But how does it work? if(string =~/^[0-9]/) The part string =~/^[0-9]/ - does it split the string into single numbers and check if each of them is a part of the list [0-9] ?? I want to be scour that I have understood the Principe correct. Best regards Bo -Oprindelig meddelelse- Fra: Christopher G Tantalo [mailto:[EMAIL PROTECTED]] Sendt: 20. juni 2002 20:25 Til: Bo Mangor Emne: Re: number Bo Mangor wrote: Hi there I'm a new bird to Perl - and I have a little problem. I have a file input where I split the file into an array and that works fine, but there is some spam in the beginning of the file I want to get rid of - the problem is that I never know how many lines there is with this spam! Therefore I want to make a check that excludes all lines there doesn't start with a number in other languages I would make a check like If (! isNaN(string)) { } How do I make this check In Perl? if(string =~/^[0-9]/) { # do something # number at start of string... } else { # do something else } that should work I haven't been able to find something similar in Perl, but I know that it should be possible. Best regards Bo -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- --- Just Your Friendly Neighborhood _SPIDEY_ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Please, ASP or PERL?
Why should I use PERL with CGI instead of ASP? Thanks, JP _ 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: exit from subs // creating frames
Root wrote at Thu, 20 Jun 2002 14:04:30 +0200: ok, found a solution to display the framessets although it works just fine, I would really appreciate comments etc on how to optimize the code :) ... my $path_info = $q-path_info; if (!$path_info) { frameset; exit 0; } } if ($path_info =~/menu/) { menu; }; if ($path_info =~/top/) { top; }; if ($path_info =~/main/) { main; }; Well, doesn't look very readable. There are thousands ways of calling a subroutine depending on a variable. Let's look at some: for ($q-path_info) { ! defined($_) frameset or /menu/menu or /top/ top or /main/main } Also a hash solution would be a good idea. BTW, why is it necessary to exit after the frameset. I'm afraid it's used to avoid a $path_info isn't defined warning. I think it won't be necessary so I removed it. In that special case, you want to call a subroutine with the same name as $path_info is. Here we could use perl's powerful dynamic referencing like with (untested) my $path_info = $q-path_info() || 'frameset'; { no strict 'subs'; {$path_info} } (O.K., the security guys should include a $path_info =~ /frameset|menu|top|main/) sub frameset { my $script_name = $q-script_name; print qq~ html head/head body frameset rows=* cols=206,* frameborder=yes border=1 framespacing=0 frame src=$script_name/menu name=menu scrolling=NO noresize id=left frameset rows=133,* cols=* framespacing=0 frameborder=NO border=0 frame src=$script_name/top name=top frameborder=yes scrolling=auto noresize bordercolor=#FF id=top frame src=$script_name/main name=main id=main /frameset /frameset noframesbody Your browser does not display frames get a life and download a new browser!! /body/noframes hr /body Stupid question (I'm perl fan, not HTML fan): Shouldn't be the frameset definition between the header and the body. And there are two body tags, the first after the header, the second in the noframes part. (similar to /body) /html ~; exit 0; Again, why to exit ? } } Cheerio, Janek PS: My browser doesn't display frames. Should I feel dead ? Normally I ignore pages telling me, that a shall use a new browser where I'm already using the quickest one. :-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Please, ASP or PERL?
It's like asking which, Java or VB? It's up to you to decide which you know better, which is better for your application, which is better for the portablity that you want. -Original Message- From: joao silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 20, 2002 3:11 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Please, ASP or PERL? Why should I use PERL with CGI instead of ASP? Thanks, JP _ 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] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Please, ASP or PERL?
Perl works everywhere, ASP works (basically) only on Micro$oft crap. Perl has mod_perl available for Apache, which will blow away any ASP. Perl also has things like HTML::Mason which allow you to embed Perl direclty into your HTML... Do I sound a bit biased? Heehee, too bad. I dislike Micro$oft. http://www.wehadthewayout.com Brent joao silva jpaulorio@hotmaiTo: [EMAIL PROTECTED], [EMAIL PROTECTED] l.com cc: (bcc: Brent Michalski/STL/MASTERCARD) Subject: Please, ASP or PERL? 06/20/02 04:10 PM Why should I use PERL with CGI instead of ASP? Thanks, JP _ 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]
PERL!! : )
I hate microsoft too, actually I´m trying to convince my boss to use PERL, so I need strongs arguments to do that. Thanks, JP. From: Brent Michalski [EMAIL PROTECTED] To: joao silva [EMAIL PROTECTED] CC: [EMAIL PROTECTED],[EMAIL PROTECTED] Subject: Re: Please, ASP or PERL? Date: Thu, 20 Jun 2002 14:13:50 -0500 Perl works everywhere, ASP works (basically) only on Micro$oft crap. Perl has mod_perl available for Apache, which will blow away any ASP. Perl also has things like HTML::Mason which allow you to embed Perl direclty into your HTML... Do I sound a bit biased? Heehee, too bad. I dislike Micro$oft. http://www.wehadthewayout.com Brent joao silva jpaulorio@hotmaiTo: [EMAIL PROTECTED], [EMAIL PROTECTED] l.com cc: (bcc: Brent Michalski/STL/MASTERCARD) Subject: Please, ASP or PERL? 06/20/02 04:10 PM Why should I use PERL with CGI instead of ASP? Thanks, JP _ 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] _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PERL!! : )
Heh, I probably came off a bit too harsh, Micro$oft really does it all to themselves... - Perl is MUCH more widely used than ASP. - Perl is more maintainable (good management buzzword). I would bet the farm that there are more *GOOD* Perl programmers than ASP programmers. I would bet the ASP has more programmers, but most of them could not program their way out of a wet paper bag. - Perl undoubtably has more modules available than ASP. www.cpan.org - Does your boss *really* want to run IIS? What do you want to patch today? Note: If your boss is strictly set on running IIS, RUN, don't walk to the nearest exit!When (and I said when) it gets hacked, who is going to take the fall??? Brent joao silva jpaulorio@hotmaiTo: [EMAIL PROTECTED] l.com cc: [EMAIL PROTECTED] Subject: PERL!! : ) 06/20/02 04:27 PM I hate microsoft too, actually I´m trying to convince my boss to use PERL, so I need strongs arguments to do that. Thanks, JP. From: Brent Michalski [EMAIL PROTECTED] To: joao silva [EMAIL PROTECTED] CC: [EMAIL PROTECTED],[EMAIL PROTECTED] Subject: Re: Please, ASP or PERL? Date: Thu, 20 Jun 2002 14:13:50 -0500 Perl works everywhere, ASP works (basically) only on Micro$oft crap. Perl has mod_perl available for Apache, which will blow away any ASP. Perl also has things like HTML::Mason which allow you to embed Perl direclty into your HTML... Do I sound a bit biased? Heehee, too bad. I dislike Micro$oft. http://www.wehadthewayout.com Brent joao silva jpaulorio@hotmaiTo: [EMAIL PROTECTED], [EMAIL PROTECTED] l.com cc: (bcc: Brent Michalski/STL/MASTERCARD) Subject: Please, ASP or PERL? 06/20/02 04:10 PM Why should I use PERL with CGI instead of ASP? Thanks, JP _ 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] _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PERL!! : )
We have one.. IIS machine... I forget what it does, but the Sysadmin has made it an untrusted machine. I wonder why???.. (all the holes and some how Mirco$oft still floats, maybe it's a giant turd). -Original Message- From: Brent Michalski [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 20, 2002 3:33 PM To: joao silva Cc: [EMAIL PROTECTED] Subject: Re: PERL!! : ) Heh, I probably came off a bit too harsh, Micro$oft really does it all to themselves... - Perl is MUCH more widely used than ASP. - Perl is more maintainable (good management buzzword). I would bet the farm that there are more *GOOD* Perl programmers than ASP programmers. I would bet the ASP has more programmers, but most of them could not program their way out of a wet paper bag. - Perl undoubtably has more modules available than ASP. www.cpan.org - Does your boss *really* want to run IIS? What do you want to patch today? Note: If your boss is strictly set on running IIS, RUN, don't walk to the nearest exit!When (and I said when) it gets hacked, who is going to take the fall??? Brent joao silva jpaulorio@hotmaiTo: [EMAIL PROTECTED] l.com cc: [EMAIL PROTECTED] Subject: PERL!! : ) 06/20/02 04:27 PM I hate microsoft too, actually I´m trying to convince my boss to use PERL, so I need strongs arguments to do that. Thanks, JP. From: Brent Michalski [EMAIL PROTECTED] To: joao silva [EMAIL PROTECTED] CC: [EMAIL PROTECTED],[EMAIL PROTECTED] Subject: Re: Please, ASP or PERL? Date: Thu, 20 Jun 2002 14:13:50 -0500 Perl works everywhere, ASP works (basically) only on Micro$oft crap. Perl has mod_perl available for Apache, which will blow away any ASP. Perl also has things like HTML::Mason which allow you to embed Perl direclty into your HTML... Do I sound a bit biased? Heehee, too bad. I dislike Micro$oft. http://www.wehadthewayout.com Brent joao silva jpaulorio@hotmaiTo: [EMAIL PROTECTED], [EMAIL PROTECTED] l.com cc: (bcc: Brent Michalski/STL/MASTERCARD) Subject: Please, ASP or PERL? 06/20/02 04:10 PM Why should I use PERL with CGI instead of ASP? Thanks, JP _ 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] _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
using Net::SMTP
is there a way I can get Net::SMTP to return errors that it might encounter into a variable, or something? so that on the page that pops up after the mail is sent, it can display errors if there were any. I have read the man page on it and cant figure out a way to do this any help would be appreciated Thanks in advance Nate
Re: PERL!! : )
Thanks to everyone! I guess now I have enough arguments to convince my Boss to buy me a lot of books from O´Reilly... :) I´m the only one here who knows anything about Linux and Perl... but I´m just starting... I hope that I´d become able to help you someday. JP. From: Bill Odom [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: PERL!! : ) Date: Thu, 20 Jun 2002 15:00:08 -0500 (CDT) JP: While I agree with Brent (hi, Brent), it doesn't have to be an all-or-nothing decision. I've had a lot of success running Perl *with* ASP. In fact, I'm finishing a project right now that - has to run on IIS - has to run under ASP So what is a self-respecting Perl programmer to do? Use PerlScript, ActiveState's extension that allows Perl to run as a full-fledged ASP scripting language. You get all the advantages of ASP, all the power of Perl, and none of the gut-wrenching inadequacy of VBScript or soullessness of JavaScript. I've built very large applications this way. It really works. It's also a great way to introduce Perl to an all-Microsoft shop, demonstrate Perl's power and maintainability, and start to loosen the Microsoft death-grip. --Bill Odom Heh, I probably came off a bit too harsh, Micro$oft really does it all to themselves... - Perl is MUCH more widely used than ASP. - Perl is more maintainable (good management buzzword). I would bet the farm that there are more *GOOD* Perl programmers than ASP programmers. I would bet the ASP has more programmers, but most of them could not program their way out of a wet paper bag. - Perl undoubtably has more modules available than ASP. www.cpan.org - Does your boss *really* want to run IIS? What do you want to patch today? Note: If your boss is strictly set on running IIS, RUN, don't walk to the nearest exit!When (and I said when) it gets hacked, who is going to take the fall??? Brent _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: exit from subs // creating frames
Root wrote: if ($path_info =~/menu/) { menu; }; if ($path_info =~/top/) { top; }; if ($path_info =~/main/) { main; }; validate $path_info to make sure it has an acceptable subroutine name, then replace the above stuff with: $path_info(); As another tip, you shouldnt ever print() from your subs, you should return a string, and print when you are ready. The CGI programs I write rarely have more than one print statement. It makes the code easier to maintain and debug. $output = path_info(); print $path_info; Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
fetchall problem
Hello, I am stuck on a bug in my perl cgi program that uses a mysql database. In executing the following code I am getting a message in the dump that the fetch failed --fetch () without execute () would anyone be able to see what I am doing wrong or be able to give me any idea of how to go about debugging this. The execute seemed to go OK and returned 8 records. $sql = SELECT clientcode FROM clientemployee WHERE clientemployee.empid=?; $sth = $dbh-prepare($sql); $sth-execute($validemp); my $sites = $sth-fetchall_arrayref; print DBI::dump_results($sth); print \n\n; Thanks, Maureen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
POSIX 'strftime' issue
Good afternoon, I have small problem here, check out the following: #!/usr/bin/perl use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use POSIX 'strftime'; # This works fine on Earthlink's servers using: print OUT strftime('%A, %B %1d, %Y %I:%M %p',localtime) ,\n; #returns: Wednesday, June 19, 2002 02:01 PM #but at CI-Host, I get this string: print OUT strftime('%A, %B %D, %Y %I:%M %p',localtime) ,\n; #returns: Wednesday, June d, 2002 12:53 PM How can I fix this to work at CI-Host, (I think they are runing Apache) Thanks Dave Cora Connection: Your West African Music Source Resources, Recordings, Instruments More! http://www.coraconnection.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]