Re: Log::Log4perl
On Wed, Oct 15, 2008 at 9:47 PM, Chas. Owens [EMAIL PROTECTED] wrote: On Wed, Oct 15, 2008 at 06:04, Rob Coops [EMAIL PROTECTED] wrote: Hi all, I am a little stumped here, I have a nice little application that makes use of Log4perl (which I really like a lot) and now that all the basic functionality is in there I have started working on makking things go a little faster. One of the things is optimizing the way data is fetched (all data gets pulled in from a webbased API), of couse sending a single request at a time is not realy optimal usage so threads where introduced in order to process up to 10 requests at the same time, which speeds things up quite a bit, but... Does Log4perl work well with threads? - It seems to as I am not seeing any errors - All threads log to the same file which so far every time contains all lines expected - The Log4perl documentation does not state clearly if it is thread safe or not I have looked at the Log4perl source code and at the Log::Log4perl::Appender::File module that I am using to write the logs but they do not seem to take into account multiple treads. Yet my knowledge of threads and perl is not good enough to say for certain that this means, so far I have just been lucky and in a strange situation things might still blow up in my face or there is nothing to worry about and things will be fine. Does anyone on the list have experiance with Log4perl and threads, or is able to confirm in another way if Log4perl is thread safe? Thanks, Rob Based on a cursory glance at the FAQ*, it looks as if it is thread-safe. You may also want to ask on the log4perl mailing list**. * http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/FAQ.html specifically: http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/FAQ.html#04256 ** https://lists.sourceforge.net/lists/listinfo/log4perl-devel -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. Thank you, that is what I mentioned it seems to be thread safe looking at the FAQ but there is no definite yes or no anywhere. I'll ask on that mailing list to make sure then.
Different keys have same value in a hash?
Hello, What is the best (shortest) way to define a hash where different keys have same values: %my_hash = { 1 = 'something', 2 = 'something', 3 = 'something else'}; Is there a way to write something like: %my_hash = { 1,2 = 'something', 3 = 'something else', etc...} Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: variable in perl
* Telemachus [2008.10.15 12:35]: In Debian (and so probably many of its children), perl-doc is a distinct package and not installed automatically when you install the perl package. Stupid, but true. Well, not to drift off-topic but it is my understanding that it is general Debian policy to have the documentation as separate packages. Not all machines that *run* perl are used for *development* with perl. And perl-doc is not that hard to find anyway: $ aptitude show perl | grep '^Recommends' Recommends: perl-doc, netbase -- JR -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
How to list all used modules?
Hello, Conside I have the code: use LWP::UserAgent (); use Apache::DBI (); use DBI (); ... ... Some points later, I want to list all the used modules, is it possible? E.g. Print out LWP::UserAgent Apache::DBI DBI Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: How to list all used modules?
On Thu, Oct 16, 2008 at 6:06 AM, howa [EMAIL PROTECTED] wrote: Hello, Conside I have the code: use LWP::UserAgent (); use Apache::DBI (); use DBI (); ... ... Some points later, I want to list all the used modules, is it possible? E.g. Print out LWP::UserAgent Apache::DBI DBI Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ I think this: Devel::Loadedhttp://search.cpan.org/~mlfisher/pmtools-1.10/Devel/Loaded.pm which will show you exactly what you have loaded should do the trick, but I am not sure if they will make this same list available on the command line. Then again would your end users really care that you loaded these modules? In my experience they are more then happy when the thing works, how it works they usually couldn't care less. Rob.
Re: Different keys have same value in a hash?
On Wed, Oct 15, 2008 at 03:17, Marko Krstic [EMAIL PROTECTED] wrote: Hello, What is the best (shortest) way to define a hash where different keys have same values: %my_hash = { 1 = 'something', 2 = 'something', 3 = 'something else'}; Is there a way to write something like: %my_hash = { 1,2 = 'something', 3 = 'something else', etc...} Thanks I can think of two ways off the top of my head: use map* to build a list (my prefered way) or use hash slice** notation and the repetition operator***. #!/usr/bin/perl use strict; use warnings; use Data::Dumper; #exploit the list nature of hash assignment my %a = ( one = 1, two = 2, map { $_ = 3 } qwthree four five six seven ); #use a hash slice my %b = ( one = 1, two = 2, ); @b{qwthree four five six seven} = (3) x 5; print a:\n, Dumper(\%a), \n, b:\n, Dumper(\%b), \n, * http://perldoc.perl.org/functions/map.html ** http://perldoc.perl.org/perldata.html#Slices *** http://perldoc.perl.org/perlop.html#Multiplicative-Operators -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
if condition question
Hi all, Kindly go through the below codes: use warnings; use strict; my $string = test; if ($string eq test) { print correct; } Output: Correct Now when I write the same if condition in program as below, I get warning along with output. use warnings; use strict; my $string = test; $string eq test ? print correct : ; Output: Correct Useless use of constant in void context at line 5. Can any one suggest the reason of warning in Case2. Thanks Regards, Sanket Vaidya http://www.patni.com World-Wide Partnerships. World-Class Solutions. _ This e-mail message may contain proprietary, confidential or legally privileged information for the sole use of the person or entity to whom this message was originally addressed. Any review, e-transmission dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this e-mail in error kindly delete this e-mail from your records. If it appears that this mail has been forwarded to you without proper authority, please notify us immediately at [EMAIL PROTECTED] and delete this mail. _
Re: How to list all used modules?
On Thu, Oct 16, 2008 at 00:06, howa [EMAIL PROTECTED] wrote: Hello, Conside I have the code: use LWP::UserAgent (); use Apache::DBI (); use DBI (); ... ... Some points later, I want to list all the used modules, is it possible? E.g. Print out LWP::UserAgent Apache::DBI DBI Thanks. You can use the global hash %INC* to find all files loaded via require, use, or do. #!/usr/bin/perl use strict; use warnings; use Data::Dumper; print files loaded:\n, map { \t$_\n } sort keys %INC; #make the files look like they would on a use print modules loaded:\n, map { s#/#::#g; s/\.pm$//; \t$_\n } sort keys %INC; * http://perldoc.perl.org/perlvar.html#%INC -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: if condition question
On Thu, Oct 16, 2008 at 05:05, Chas. Owens [EMAIL PROTECTED] wrote: snip What the ternary operator* is saying is roughly equivalant to snip Whoops, left out the footnote: * http://perldoc.perl.org/perlop.html#Conditional-Operator -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
RE: if condition question
--- On Thu, 10/16/08, sanket vaidya [EMAIL PROTECTED] wrote: From: sanket vaidya [EMAIL PROTECTED] Subject: RE: if condition question To: beginners@perl.org Date: Thursday, October 16, 2008, 6:12 AM -Original Message- From: Chas. Owens [mailto:[EMAIL PROTECTED] Sent: Thursday, October 16, 2008 2:36 PM To: sanket vaidya Cc: beginners@perl.org Subject: Re: if condition question On Thu, Oct 16, 2008 at 04:54, sanket vaidya [EMAIL PROTECTED] wrote: snip Now when I write the same if condition in program as below, I get warning along with output. snip $string eq test ? print correct : ; snip Useless use of constant in void context at line 5. snip What the ternary operator* is saying is roughly equivalant to if ($string eq test) { print correct } else { } That empty string by itself is what is causing the warning. What you really want to say is print $string eq test ? correct : ; How can I write if ($string eq test) { print correct } else { die others } In above way? $string eq test ? print correct : die others; But I don't think this is a recommended syntax. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Process start time in windows
On Wed, Oct 15, 2008 at 11:21, Zeba [EMAIL PROTECTED] wrote: Hi, I'm trying to write a perl program where I need to check when a process was started. I have found a way to do this in linux. Can any one help me on how to accomplish this in windows? I tried using the tasklist windows command, but that seems to give only the process ID and some other details ( no start time / last updated time, etc) snip A quick search of CPAN* yielded Win32::Process::Info** which seems to do what you want. * http://search.cpan.org ** http://search.cpan.org/dist/Win32-Process-Info/lib/Win32/Process/Info.pm -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: if condition question
On Thu, Oct 16, 2008 at 06:12, sanket vaidya [EMAIL PROTECTED] wrote: snip How can I write if ($string eq test) { print correct } else { die others } In above way? snip In general, the ternary operator should only be used when choosing between two (or more in the case of nested ternary operators) scalar values. I would probably write the code above like this: die bad value in \$string: $string unless $string eq 'test'; print correct; -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: if condition question
On Thu, Oct 16, 2008 at 03:20:13AM -0700, Jeff Pang wrote: --- On Thu, 10/16/08, sanket vaidya [EMAIL PROTECTED] wrote: From: Chas. Owens [mailto:[EMAIL PROTECTED] What you really want to say is print $string eq test ? correct : ; print correct if $str eq test; How can I write if ($string eq test) { print correct } else { die others } In above way? $string eq test ? print correct : die others; But I don't think this is a recommended syntax. die others unless $string eq test; print correct; -- 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/
Re: parse ini usage results in uninitialized value in concatenation
On Oct 14, 6:41 am, [EMAIL PROTECTED] (Protoplasm) wrote: I'm attempting to write some code using the Config::INI::Simple module. When I run the app I get the following: Use of uninitialized value in concatenation (.) or string at ./open- file2.pl line 35. Use of uninitialized value in concatenation (.) or string at ./open- file2.pl line 36. Use of uninitialized value in concatenation (.) or string at ./open- file2.pl line 37. snip print $conf-{TestPaths}-{c_tests} . \n; print $conf-{TestPaths}-{j_tests} . \n; print $conf-{JarPath}-{jaest} . \n; I see the problem. In the case of there being no ini file in existence when the app is run the values are not initialized. I'll have to add some logic to get around this. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Redirect option
Is there any option to redirect a URL in perl other than Location ? Regards Sheela
Re: Log::Log4perl
If this helps: I am using Log4Perl in a typical forked-to-background-daemon. I had to do a little thinking to figure out the best place to initialize Log4Perl. The problem is, that the utilized shared vars lost their sharedness in the child proc. Maybe you have to initialize your Log4Perl-Object in each thread that want to use Log4Perl in. (I guess this is the saved thing at all... but ram usage and i/o behaviour might change, and race conditions on the logfile (if you only use one in total) may occure. You will notice that by cutted lines in the log.) Bye, D. Rob Coops [EMAIL PROTECTED] hat am 16. Oktober 2008 um 07:47 geschrieben: On Wed, Oct 15, 2008 at 9:47 PM, Chas. Owens [EMAIL PROTECTED] wrote: On Wed, Oct 15, 2008 at 06:04, Rob Coops [EMAIL PROTECTED] wrote: Hi all, I am a little stumped here, I have a nice little application that makes use of Log4perl (which I really like a lot) and now that all the basic functionality is in there I have started working on makking things go a little faster. One of the things is optimizing the way data is fetched (all data gets pulled in from a webbased API), of couse sending a single request at a time is not realy optimal usage so threads where introduced in order to process up to 10 requests at the same time, which speeds things up quite a bit, but... Does Log4perl work well with threads? - It seems to as I am not seeing any errors - All threads log to the same file which so far every time contains all lines expected - The Log4perl documentation does not state clearly if it is thread safe or not I have looked at the Log4perl source code and at the Log::Log4perl::Appender::File module that I am using to write the logs but they do not seem to take into account multiple treads. Yet my knowledge of threads and perl is not good enough to say for certain that this means, so far I have just been lucky and in a strange situation things might still blow up in my face or there is nothing to worry about and things will be fine. Does anyone on the list have experiance with Log4perl and threads, or is able to confirm in another way if Log4perl is thread safe? Thanks, Rob Based on a cursory glance at the FAQ*, it looks as if it is thread-safe. You may also want to ask on the log4perl mailing list**. * http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/FAQ.html specifically: http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/FAQ.html#04256 ** https://lists.sourceforge.net/lists/listinfo/log4perl-devel -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. Thank you, that is what I mentioned it seems to be thread safe looking at the FAQ but there is no definite yes or no anywhere. I'll ask on that mailing list to make sure then.
eval and script performance ?
The last time I considered using eval is years ago. I remember that I had read an article somewhere that doing eval could lead to dramatic performance issues. I want to use eval{} to check my db-transactions. I looking for informations at perldoc eval, but there is nothing mentioned about performance influences. (I also looked at programming the perl dbi book, eval is only mentioned one time and the http://www.perl.com/pub/a/1999/10/DBI.html and http://www.saturn5.com/~jwb/dbi-examples.html) In general I am a little bit unsure about DBI and EVAL, both things I rarely needed or used before. ### use DBI; use DBD::mysql; eval { my $dbh = DBI-connect(DBI:mysql:dummy_db:test_db:,'adm','adm'); }; if ($@) { ... handle errror... } my $sth = $db-prepare(select dummies from dummy_table); eval{ $sth-execute(); }; if ( $@ ) { #... handle errors print __LINE__ . sth-err . $sth-err() . \n; print __LINE__ . sth-errstr . $sth-errstr() . \n; print __LINE__ . sth-state . $sth-state() . \n; print __LINE__ . DBI::err . $DBI::err . \n; print __LINE__ . DBI::errstr . $DBI::errstr . \n; print __LINE__ . DBI::state . $DBI::state . \n; } #versus my $dbh2 = DBI-connect(DBI:mysql:dummy_db:test_db:,'adm','adm'); if (defined $DBI::errstr) { #...error handling... } my $sth2 = $db-prepare(select dummies from dummy_table); $sth2-execute(); if (defined $DBI::errstr) { #..error handling... } ##
Re: translate IP mask
Net::Netmask does such things, too. John W. Krahn [EMAIL PROTECTED] hat am 16. Oktober 2008 um 12:57 geschrieben: Sandy lone wrote: I need to translate an IP addr with its mask from this form: 192.168.1.30/255.255.255.0 to this one: 192.168.1.30/24 One way to do it: $ perl -le' use Socket; my $stuff = 192.168.1.30/255.255.255.0; my ( $ip, $mask ) = split /\//, $stuff; print $ip/ . unpack %32b*, inet_aton $mask; ' 192.168.1.30/24 John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
translate IP mask
I need to translate an IP addr with its mask from this form: 192.168.1.30/255.255.255.0 to this one: 192.168.1.30/24 which module/method is right to use? Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: sendmail module
Jeff. --- On Thu, 10/16/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: From: [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: sendmail module To: beginners@perl.org Date: Thursday, October 16, 2008, 5:25 AM Hi All, I am using Perl 5.6.1 and want to sue sendmail module. I have copied the Sendmail.pm module to the mail dir. But still it is not executing properly. Following is the exact error. Can't locate MIME/Base64.pm in @INC (@INC contains: from what you show, you need to install MIME::Base64 module, which is used for encoding a message body. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re:Redirect option
Message du 16/10/08 13:19 De : sheela b A : beginners@perl.org Copie à : Objet : Redirect option Is there any option to redirect a URL in perl other than Location ? Why not Location? If you use CGI.pm, you could look for redirect() method in it. But it is essentially printing a Location IMO. Jeff. Créez votre adresse électronique [EMAIL PROTECTED] 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
Re: eval and script performance ?
On Thu, Oct 16, 2008 at 12:38:54PM +0100, Deviloper wrote: The last time I considered using eval is years ago. I remember that I had read an article somewhere that doing eval could lead to dramatic performance issues. I want to use eval{} to check my db-transactions. I looking for informations at perldoc eval, but there is nothing mentioned about performance influences. Really? Although the word performance is not mentioned, it does talk about efficiency and penalties in the context of performance. Take another look. Also note the two type of eval - string and block. If you are using block evals you probably don't even need to think about performance. Certainly not until you have proven that that is your bottleneck. And if you are using string eval you should probably be looking for some other way to do it anyway. This, though, is probably the type of eval you have remembered as being a potential performance problem. -- 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/
RE: sendmail module
Message du 16/10/08 14:12 De : [EMAIL PROTECTED] A : [EMAIL PROTECTED], beginners@perl.org Copie à : Objet : RE: sendmail module Hi All/Jeff, Somehow I am not able to install/configure Sendmail module. Can somebody have another option/script/module then please let me know. I am really stuck. Lots of modules on CPAN for sending emails, like Mail::Send,MIME::Lite etc. For myself I always use Net::SMTP for the tasks, conbined with MIME::Lite it's easy to send all kinds of messages. Jeff. Créez votre adresse électronique [EMAIL PROTECTED] 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
Re: if condition question
sanket vaidya wrote: Hi all, This is the exact same question you asked 16 days ago. Did you not like the answer you got then? (Which is the same as the answers you are getting now.) John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order.-- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Process start time in windows
Hi, I'm trying to write a perl program where I need to check when a process was started. I have found a way to do this in linux. Can any one help me on how to accomplish this in windows? I tried using the tasklist windows command, but that seems to give only the process ID and some other details ( no start time / last updated time, etc) Please help ! Thanks, Zeba -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: if condition question
On Thu, 16 Oct 2008 14:24:56 +0530, sanket vaidya wrote: use warnings; use strict; Good! use warnings has shown you a bug in your code. my $string = test; $string eq test ? print correct : ; Output: Correct Useless use of constant in void context at line 5. Your program says that if $string eq test then execute: print correct otherwise execute: That's a (constant) string in void context. You meant: print $string eq test ? correct : ; -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
sendmail module
Hi All, I am using Perl 5.6.1 and want to sue sendmail module. I have copied the Sendmail.pm module to the mail dir. But still it is not executing properly. Following is the exact error. Can't locate MIME/Base64.pm in @INC (@INC contains: /usr/perl5/5.6.1/lib/sun4-solaris-64int /usr/perl5/5.6.1/lib /usr/perl5/site_perl/5.6.1/sun4-solaris-64int /usr/perl5/site_perl/5.6.1 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.6.1/sun4-solaris-64int /usr/perl5/vendor_perl/5.6.1 /usr/perl5/vendor_perl .) at /usr/perl5/5.6.1/lib/sun4-solaris-64int/SendMail.pm line 61. BEGIN failed--compilation aborted at /usr/perl5/5.6.1/lib/sun4-solaris-64int/SendMail.pm line 61. Compilation failed in require at ./cc_label.pl line 7. BEGIN failed--compilation aborted at ./cc_label.pl line 7. As per the FAQ, in order to install the sendmail module we have to just copy the Perl module to the mail dir. I have done that but still the problem is same. Please help/suggest. Regards Irf. This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful.
Re: translate IP mask
Sandy lone wrote: I need to translate an IP addr with its mask from this form: 192.168.1.30/255.255.255.0 to this one: 192.168.1.30/24 One way to do it: $ perl -le' use Socket; my $stuff = 192.168.1.30/255.255.255.0; my ( $ip, $mask ) = split /\//, $stuff; print $ip/ . unpack %32b*, inet_aton $mask; ' 192.168.1.30/24 John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order.-- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: if condition question
--- On Thu, 10/16/08, sanket vaidya [EMAIL PROTECTED] wrote: From: sanket vaidya [EMAIL PROTECTED] Subject: if condition question To: beginners@perl.org Date: Thursday, October 16, 2008, 4:54 AM Hi all, Kindly go through the below codes: use warnings; use strict; my $string = test; if ($string eq test) { print correct; } Output: Correct Now when I write the same if condition in program as below, I get warning along with output. use warnings; use strict; my $string = test; $string eq test ? print correct : the above should be: print $string eq test ? correct : others; Jeff. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
RE: if condition question
-Original Message- From: Chas. Owens [mailto:[EMAIL PROTECTED] Sent: Thursday, October 16, 2008 2:36 PM To: sanket vaidya Cc: beginners@perl.org Subject: Re: if condition question On Thu, Oct 16, 2008 at 04:54, sanket vaidya [EMAIL PROTECTED] wrote: snip Now when I write the same if condition in program as below, I get warning along with output. snip $string eq test ? print correct : ; snip Useless use of constant in void context at line 5. snip What the ternary operator* is saying is roughly equivalant to if ($string eq test) { print correct } else { } That empty string by itself is what is causing the warning. What you really want to say is print $string eq test ? correct : ; How can I write if ($string eq test) { print correct } else { die others } In above way? http://www.patni.com World-Wide Partnerships. World-Class Solutions. _ This e-mail message may contain proprietary, confidential or legally privileged information for the sole use of the person or entity to whom this message was originally addressed. Any review, e-transmission dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this e-mail in error kindly delete this e-mail from your records. If it appears that this mail has been forwarded to you without proper authority, please notify us immediately at [EMAIL PROTECTED] and delete this mail. _ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: cpan shell wrong
On Wed, Oct 15, 2008 at 5:17 AM, [EMAIL PROTECTED] wrote: I had a similar problem. Check out the contents of your urllist. This is what mine looked like: cpan[1] o conf urllist urllist 0 [] 1 [ftp://carroll.cac.psu.edu/pub/CPAN/] 2 [ftp://cpan-du.viaverio.com/pub/CPAN/] 3 [ftp://cpan-sj.viaverio.com/pub/CPAN/] 4 [ftp://cpan.calvin.edu/pub/CPAN] Type 'o conf' to view all configuration items For some reason the first URL in my list got blown away. If this is your problem do the following and you should be all fix0rd: cpan[2] o conf urllist shift Thanks. The solution is really cool. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
RE: sendmail module
Hi All/Jeff, Somehow I am not able to install/configure Sendmail module. Can somebody have another option/script/module then please let me know. I am really stuck. Please help/advise. Regards Irf. -Original Message- From: Jeff Pang [mailto:[EMAIL PROTECTED] Sent: Thursday, October 16, 2008 2:59 PM To: beginners@perl.org; Sayed, Irfan (Cognizant) Subject: Re: sendmail module Jeff. --- On Thu, 10/16/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: From: [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: sendmail module To: beginners@perl.org Date: Thursday, October 16, 2008, 5:25 AM Hi All, I am using Perl 5.6.1 and want to sue sendmail module. I have copied the Sendmail.pm module to the mail dir. But still it is not executing properly. Following is the exact error. Can't locate MIME/Base64.pm in @INC (@INC contains: from what you show, you need to install MIME::Base64 module, which is used for encoding a message body. This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: translate IP mask
On Thu, Oct 16, 2008 at 05:44, Sandy lone [EMAIL PROTECTED] wrote: I need to translate an IP addr with its mask from this form: 192.168.1.30/255.255.255.0 to this one: 192.168.1.30/24 which module/method is right to use? Thanks. A quick search of CPAN* turned up NetAddr::IP which seems to do what you want. I would probably say something like #!/usr/bin/perl use strict; use warnings; use List::Util qwsum; print netmask_to_cidr(192.168.1.30/255.255.255.0), \n; sub netmask_to_cidr { my ($ip_and_netmask) = shift; #FIXME: do better checking of arguments die bad argument: $ip_and_netmask unless my ($ip, $netmask) = $ip_and_netmask =~ m{(.*)/(.*)}; #FIXME: this may be wrong, but I think we just need to count the number #of bits that are on my $cidr = sum map {(sprintf %b, $_) =~ tr/1//} split /\./, $netmask; return $ip/$cidr; } * http://search.cpan.org ** http://search.cpan.org/dist/NetAddr-IP/IP.pm -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: if condition question
On Thu, Oct 16, 2008 at 04:54, sanket vaidya [EMAIL PROTECTED] wrote: snip Now when I write the same if condition in program as below, I get warning along with output. snip $string eq test ? print correct : ; snip Useless use of constant in void context at line 5. snip What the ternary operator* is saying is roughly equivalant to if ($string eq test) { print correct } else { } That empty string by itself is what is causing the warning. What you really want to say is print $string eq test ? correct : ; -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
using algorithm-permute
Hi, I need to create permutations of a given set of values. The set is itself present in an array. From this I am trying to create another array that has permutations of this set. I am able to create a small example and run but from the description of the module I am not sure how to put the permutations into another array. Can someone tell me how the code given below can be modified. PS: I am not well versed with perl classes Regards, #!/usr/bin/perl use warnings; use Algorithm::Permute; my @array = (1..4); Algorithm::Permute::permute { print @array\n } @array; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: eval and script performance ?
Deviloper wrote: The last time I considered using eval is years ago. I remember that I had read an article somewhere that doing eval could lead to dramatic performance issues. I want to use eval{} to check my db-transactions. I looking for informations at perldoc eval, but there is nothing mentioned about performance influences. (I also looked at programming the perl dbi book, eval is only mentioned one time and the http://www.perl.com/pub/a/1999/10/DBI.html and http://www.saturn5.com/~jwb/dbi-examples.html) There are some good notes on using eval in the DBI perldoc - an excerpt: A major advantage of the eval approach is that the transaction will be properly rolled back if any code (not just DBI calls) in the inner application dies for any reason. The major advantage of using the $h-{RaiseError} attribute is that all DBI calls will be checked automatically. Both techniques are strongly recommended. Otherwise there is little difference between the two - *provided* you do error checking on every call you make to the database. I would lean towards using eval, as any DBI failures will be propagated upwards to your app, and if you don't deal with them your app will die - this is generally more desirable than continuing on, blithely unaware that your database transactions have failed! In terms of performance, any hit that the use of eval has on your code will be completely negligible compared to the delays involved in waiting for any SQL database. My own testing shows that eval, in block form, is very fast indeed. Remember that eval is the standard exception handling idiom in perl. If you are ever not sure about the speed of a construct, feel free to test it - there are many ways to do it, including the excellent 'Benchmark' module. - Justin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: if condition question
On Oct 16, 2008, at 8:08 AM, John W. Krahn [EMAIL PROTECTED] wrote: sanket vaidya wrote: Hi all, This is the exact same question you asked 16 days ago. Did you not like the answer you got then? (Which is the same as the answers you are getting now.) John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order.-- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ I thought I had a feeling of déjà vu. Tom -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/