Re[2]: about return

2011-02-09 Thread terry peng
Wed, 9 Feb 2011 22:44:10 -0800 (PST) письмо от "C.DeRykus" : > On Feb 9, 10:07 pm, terry.p...@mail.ru (terry peng) wrote: > > hello, > > > > when in the case "return undef" I prefer just "return" coz in list context > it will return an empty list. > > > > my $exist = ... > > if ($exist) { > >

Re: about return

2011-02-09 Thread C.DeRykus
On Feb 9, 10:07 pm, terry.p...@mail.ru (terry peng) wrote: > hello, > > when in the case "return undef" I prefer just "return" coz in list context it > will return an empty list. > > my $exist = ... > if ($exist) { >     return 1; > > } else { >     return; > } > > the code above can work, but hav

Re: about return

2011-02-09 Thread Uri Guttman
> "PK" == Parag Kalra writes: PK> Is this what you mean PK> ($exist) ? return 1 : return undef PK> I think even this should work PK> ($exist) ? 1 : 0; he wants an empty list in a list context when returning the false value so neither of those works. uri -- Uri Guttman -- u

Re[2]: about return

2011-02-09 Thread terry peng
> > return 1 if $exists ; > return ; > > then it is easy to see what conditions will return what values. no need > for if/else blocks or noisy ?: ops. > That's a good solution. Thanks much. :) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginner

Re: about return

2011-02-09 Thread Uri Guttman
> "tp" == terry peng writes: tp> when in the case "return undef" I prefer just "return" coz in list tp> context it will return an empty list. tp> my $exist = ... tp> if ($exist) { tp> return 1; tp> } else { tp> return; tp> } tp> the code above can work, but having

Re: about return

2011-02-09 Thread Parag Kalra
Is this what you mean ($exist) ? return 1 : return undef I think even this should work ($exist) ? 1 : 0; ~Parag 2011/2/9 terry peng > > hello, > > when in the case "return undef" I prefer just "return" coz in list context > it will return an empty list. > > my $exist = ... > if ($exist) {

about return

2011-02-09 Thread terry peng
hello, when in the case "return undef" I prefer just "return" coz in list context it will return an empty list. my $exist = ... if ($exist) { return 1; } else { return; } the code above can work, but having many lines. So I want: return $exist ? 1 : (...); what should be put in (...)

Re: print $myhash{key} gets SCALAR(0x1b8db540) instead of "0"

2011-02-09 Thread John W. Krahn
gry wrote: [[v5.8.8 built for x86_64-linux-thread-multi] #!/usr/bin/perl -W use Getopt::Long; my $dml = 0; my $iterations = 10; my %options = ("dml!" => \$dml, "iterations=i" => \$iterations); GetOptions(%options) || die "bad options"; printf "dml=$dml\n"; That should be eithe

encapsulate static data

2011-02-09 Thread Jim Green
Hello: I have some static data I want to wrap in a Data.pm, what is the best way of doing this. package data; use strict; use warnings; my $data=1; 1; I tried use data; print $data; but it doesn't work, also I tried print data::$data and still doesn't work. Thanks for helping! Jim -- To unsu

Re: print $myhash{key} gets SCALAR(0x1b8db540) instead of "0"

2011-02-09 Thread Shawn H Corey
On 11-02-09 04:52 PM, gry wrote: [[v5.8.8 built for x86_64-linux-thread-multi] #!/usr/bin/perl -W use Getopt::Long; my $dml = 0; my $iterations = 10; my %options = ("dml!" => \$dml, "iterations=i" => \$iterations); GetOptions(%options) || die "bad options"; printf "dml=$dml\n";

Re: Randomizing a 24hr time period

2011-02-09 Thread Paul Johnson
On Wed, Feb 09, 2011 at 10:52:24PM +, Rob Dixon wrote: > On 09/02/2011 17:05, Paul Johnson wrote: > > > >Of course you can redefine the problem this way, but it's more interesting to > >solve the original problem. > > > >To go with Rob's solution, here's something that's (more) correct: > Hey

print $myhash{key} gets SCALAR(0x1b8db540) instead of "0"

2011-02-09 Thread gry
[[v5.8.8 built for x86_64-linux-thread-multi] #!/usr/bin/perl -W use Getopt::Long; my $dml = 0; my $iterations = 10; my %options = ("dml!" => \$dml, "iterations=i" => \$iterations); GetOptions(%options) || die "bad options"; printf "dml=$dml\n"; print %options; foreach $key (sort ke

Re: Randomizing a 24hr time period

2011-02-09 Thread Mike Blezien
- Original Message - From: "Jim Gibson" To: "Perl List" Sent: Wednesday, February 09, 2011 6:15 PM Subject: Re: Randomizing a 24hr time period On 2/9/11 Wed Feb 9, 2011 2:30 PM, "Mike Blezien" scribbled: - Original Message - From: "Jim Gibson" To: "Perl List" Sent: Wed

Re: Randomizing a 24hr time period

2011-02-09 Thread Jim Gibson
On 2/9/11 Wed Feb 9, 2011 2:30 PM, "Mike Blezien" scribbled: > - Original Message - > From: "Jim Gibson" > To: "Perl List" > Sent: Wednesday, February 09, 2011 4:04 PM > Subject: Re: Randomizing a 24hr time period > > >> On 2/9/11 Wed Feb 9, 2011 1:05 PM, "Mike Blezien" >> scribb

Re: Randomizing a 24hr time period

2011-02-09 Thread Rob Dixon
On 09/02/2011 17:05, Paul Johnson wrote: Of course you can redefine the problem this way, but it's more interesting to solve the original problem. To go with Rob's solution, here's something that's (more) correct: #!/usr/bin/perl use strict; use warnings; my ($messages, $time_period) = @ARG

Re: Randomizing a 24hr time period

2011-02-09 Thread Mike Blezien
- Original Message - From: "Jim Gibson" To: "Perl List" Sent: Wednesday, February 09, 2011 4:04 PM Subject: Re: Randomizing a 24hr time period On 2/9/11 Wed Feb 9, 2011 1:05 PM, "Mike Blezien" scribbled: - Original Message - From: "Paul Johnson" To: "Uri Guttman" Cc: "

Re: Randomizing a 24hr time period

2011-02-09 Thread Jim Gibson
On 2/9/11 Wed Feb 9, 2011 1:05 PM, "Mike Blezien" scribbled: > - Original Message - > From: "Paul Johnson" > To: "Uri Guttman" > Cc: "Mike Blezien" ; "Perl List" > Sent: Wednesday, February 09, 2011 11:05 AM > Subject: Re: Randomizing a 24hr time period > > >> On Wed, Feb 09, 2011

Re: Randomizing a 24hr time period

2011-02-09 Thread Mike Blezien
- Original Message - From: "Paul Johnson" To: "Uri Guttman" Cc: "Mike Blezien" ; "Perl List" Sent: Wednesday, February 09, 2011 11:05 AM Subject: Re: Randomizing a 24hr time period On Wed, Feb 09, 2011 at 11:16:07AM -0500, Uri Guttman wrote: > "MB" == Mike Blezien writes: >

net::snmp and fetching extend data

2011-02-09 Thread Joseph L. Casale
I am trying to write a script that takes the extend name as an arg and retrieves the output for further processing. I am not sure how to do this, get_request() needs a numeric oid, is there a way around this or is get_request() not the best way to do this? Thanks for any help, jlc -- To unsubscr

Re: Randomizing a 24hr time period

2011-02-09 Thread Mike Blezien
- Original Message - From: "Paul Johnson" To: "Uri Guttman" Cc: "Mike Blezien" ; "Perl List" Sent: Wednesday, February 09, 2011 11:05 AM Subject: Re: Randomizing a 24hr time period On Wed, Feb 09, 2011 at 11:16:07AM -0500, Uri Guttman wrote: > "MB" == Mike Blezien writes: >

Re: Randomizing a 24hr time period

2011-02-09 Thread Paul Johnson
On Wed, Feb 09, 2011 at 11:16:07AM -0500, Uri Guttman wrote: > > "MB" == Mike Blezien writes: > > >> as i said a simple solution is to slice up the 24 hours into fixed > >> intervals. then pick a random time INSIDE each interval. random enough > >> for those types of people. this is clo

Re: Randomizing a 24hr time period

2011-02-09 Thread Robert Wohlfarth
On Wed, Feb 9, 2011 at 9:41 AM, Rob Dixon wrote: > On 07/02/2011 21:30, Mike Blezien wrote: > >> I'm trying to come up with a function to send out X number of message per >> day(24hr day) but we need to randomize the time factore each day. For >> example if >> 50 messages are scheduled to be sent

Re: Randomizing a 24hr time period

2011-02-09 Thread Uri Guttman
> "MB" == Mike Blezien writes: >> as i said a simple solution is to slice up the 24 hours into fixed >> intervals. then pick a random time INSIDE each interval. random enough >> for those types of people. this is close to one message an hour so there >> is plenty of variability within

Re: Randomizing a 24hr time period

2011-02-09 Thread Skirv
New to this mailing list so this is my first response. Why not just take (24*60)/[number of unsent messages] and send them on that interval? You probably dont want messages appearing in the dead of night, so you can safely assume the last 2 hours and first 6 are off limits by doing ((16*60)/[numb

Re: Randomizing a 24hr time period

2011-02-09 Thread Mike Blezien
- Original Message - From: "Uri Guttman" To: "Mike Blezien" Cc: "Perl List" ; "Mike McClain" Sent: Wednesday, February 09, 2011 9:35 AM Subject: Re: Randomizing a 24hr time period "MB" == Mike Blezien writes: MB> What they have right now are about 25 messages they wish to spread

Re: Randomizing a 24hr time period

2011-02-09 Thread Rob Dixon
On 07/02/2011 21:30, Mike Blezien wrote: Hello, I'm trying to come up with a function to send out X number of message per day(24hr day) but we need to randomize the time factore each day. For example if 50 messages are scheduled to be sent out in 24 hr time period we want to randomize the times

Re: Randomizing a 24hr time period

2011-02-09 Thread Uri Guttman
> "MB" == Mike Blezien writes: MB> What they have right now are about 25 messages they wish to spread MB> out through out a 24hr period so they are sent out randomly during MB> this 24 period, not a pre determined every X minutes or X MB> hours. Why I'm not really sure, but that'

Re: perl's threads

2011-02-09 Thread Rob Coops
Just adding a little to this discussion then. :-) Threads regardless of the language are meant to do multiple things in parallel. For instance I'm at the moment working on a tool that extracts vast amounts of data from a web service as the calls to that service are pretty much independent and the

Re: perl's threads

2011-02-09 Thread Shlomi Fish
On Tuesday 08 Feb 2011 10:05:47 Dr.Ruud wrote: > On 2011-02-07 11:30, Shlomi Fish wrote: > > Threads work pretty well in C, though they are extremely tricky to get > > right for non-trivial programs > > That they work "pretty well" is probably about user experience of some > heavily interactive sy

Re: Randomizing a 24hr time period

2011-02-09 Thread Mike Blezien
What they have right now are about 25 messages they wish to spread out through out a 24hr period so they are sent out randomly during this 24 period, not a pre determined every X minutes or X hours. Why I'm not really sure, but that's what they want to do. I think I have it figured out thou

Re: Randomizing a 24hr time period

2011-02-09 Thread Uri Guttman
> "MB" == Mike Blezien writes: MB> Uri, MB> yes that does make sense but that's what the customer wants :) MB> There always right aren't they !! then do something very simple. send a message every N minutes where N is randomly picked from say 5-10. they will never know it wasn't a mor

Re: Randomizing a 24hr time period

2011-02-09 Thread Mike Blezien
Uri, yes that does make sense but that's what the customer wants :) There always right aren't they !! Mike(mickalo)Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - Original Message - Fr

Re: Randomizing a 24hr time period

2011-02-09 Thread Uri Guttman
> "MB" == Mike Blezien writes: MB> it isn't for spam I assure you. A client of ours sends out 25-50, MB> messages/quotes, a day to various spiritual web sites. And they MB> have already been approved by the web sites they are posted MB> too. They just wanted a solution to randomize wh

Re: Randomizing a 24hr time period

2011-02-09 Thread Mike Blezien
it isn't for spam I assure you. A client of ours sends out 25-50, messages/quotes, a day to various spiritual web sites. And they have already been approved by the web sites they are posted too. They just wanted a solution to randomize when the messages go out so they are like a "surprize" when

Re: perl's threads

2011-02-09 Thread Dr.Ruud
On 2011-02-07 07:44, Octavian Rasnita wrote: From: "Dr.Ruud" On 2011-02-06 12:12, terry peng wrote: What's the suggested module for perl's threads? I have been using Perl 5.12 under linux. Stay away from threads. Design and develop in a way that no internal resources (but read-only data) a

Re: perl's threads

2011-02-09 Thread Dr.Ruud
On 2011-02-07 11:30, Shlomi Fish wrote: Threads work pretty well in C, though they are extremely tricky to get right for non-trivial programs That they work "pretty well" is probably about user experience of some heavily interactive system. But only if the user accepts crashes and deadlocks

Re: Randomizing a 24hr time period

2011-02-09 Thread Mike McClain
On Mon, Feb 07, 2011 at 03:30:03PM -0600, Mike Blezien wrote: > I'm trying to come up with a function to send out X number of message per > day(24hr day) but we need to randomize the time factore each day. For > Hope this makes sense, and someone may have done this before or may have > some in