Re: Subroutine return value

2025-05-14 Thread Jim Gibson via beginners
Put this line as the last line executed in your subroutine: return $sum; That makes it explicit as to what you want the subroutine to do. Don’t depend upon some obscure behavior of Perl to save a few keystrokes. Your program will be better for it. > On May 14, 2025, at 4:15

Subroutine return value

2025-05-14 Thread Daryl Lee
In “Learning Perl”, Pg. 116, is found this sentence: Whatever calculation is last performed in a subroutine is automatically also the return value. I have a subroutine that (almost) ends with this loop: foreach my $line (@lines) { $sum += evaluate($line); } What I want to return

Re: return the list content

2018-06-14 Thread Paul Johnson
On Mon, Aug 18, 2014 at 06:07:59AM -0700, John SJ Anderson wrote: On Mon, Aug 18, 2014 at 1:38 AM, Paul Johnson wrote: > On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote: >> which one is the better way to return the list content? And if the >> method is an instance metho

Re: keyboard input without pressing return?

2017-05-14 Thread Jim Gibson
> On May 5, 2017, at 6:06 PM, lee wrote: > > > Hi, > > how can a sleeping program react to a key that was pressed without > return being pressed? > See ‘perldoc -q "How can I read a single character from a file? From the keyboard?” Jim Gibson jgib...@snowla

Re: keyboard input without pressing return?

2017-05-14 Thread lee
Shlomi Fish writes: > On Sun, 14 May 2017 12:08:59 +0300 > Shlomi Fish wrote: > >> Hi lee, >> >> On Sat, 06 May 2017 02:06:19 +0100 >> lee wrote: >> >> > Hi, >> > >> > how can a sleeping program react to a key that was presse

Re: keyboard input without pressing return?

2017-05-14 Thread Shlomi Fish
On Sun, 14 May 2017 12:08:59 +0300 Shlomi Fish wrote: > Hi lee, > > On Sat, 06 May 2017 02:06:19 +0100 > lee wrote: > > > Hi, > > > > how can a sleeping program react to a key that was pressed without > > return being pressed? > > > >

Re: keyboard input without pressing return?

2017-05-14 Thread Shlomi Fish
Hi lee, On Sat, 06 May 2017 02:06:19 +0100 lee wrote: > Hi, > > how can a sleeping program react to a key that was pressed without > return being pressed? > > > perl -e 'use Term::ReadKey; my $ke = ReadKey(10); print "k: $ke\n";' > > >

keyboard input without pressing return?

2017-05-13 Thread lee
Hi, how can a sleeping program react to a key that was pressed without return being pressed? perl -e 'use Term::ReadKey; my $ke = ReadKey(10); print "k: $ke\n";' ... shows that: + ReadKey() returns undef after the timeout + ReadKey() returns undef after the timeout e

Re: How do I fork a process and return results to the user?

2015-08-30 Thread Shlomi Fish
> process in the fork does a webservice query which may take a few minutes to > return results. What I want to do is forward the user to a "Searching for > results" page which polls periodically for results. Eventually it will > display the search results. How can I do this?

How do I fork a process and return results to the user?

2015-08-30 Thread G M
Hi, Can anyone help me with this? I have two scripts, the first one calls the exec command which then invokes the second script. The second script then creates a fork process. The child process in the fork does a webservice query which may take a few minutes to return results. What I want to

Re: Get return value when running cmd like this

2015-01-05 Thread Charles DeRykus
On Mon, Jan 5, 2015 at 3:20 PM, Harry Putnam wrote: > When running shell commands from perl script with an open() instead of > system() or exec how is the return value snagged. > > I guess, if it doesn't die, it worked but how to snag that information > and at what point?

Re: Get return value when running cmd like this

2015-01-05 Thread Brandon McCaig
Harry: On Mon, Jan 05, 2015 at 06:20:06PM -0500, Harry Putnam wrote: > When running shell commands from perl script with an open() instead of > system() or exec how is the return value snagged. > > I guess, if it doesn't die, it worked but how to snag that information &g

Get return value when running cmd like this

2015-01-05 Thread Harry Putnam
When running shell commands from perl script with an open() instead of system() or exec how is the return value snagged. I guess, if it doesn't die, it worked but how to snag that information and at what point? --- 8< snip -- 8< snip -- 8', "$log"

Re: return the list content

2014-09-12 Thread Charles DeRykus
erence to the copy. >> >> >> Since this is a shadow copy, I don't think the first array will be >> deleted completely. Isn't it? > > > The second option is this > > sub myfunc { >my @x=(1,2,3); >return [@x]; > } > > And yes, t

Re: return the list content

2014-09-10 Thread Rob Dixon
etely. Isn't it? The second option is this sub myfunc { my @x=(1,2,3); return [@x]; } And yes, the array @x is created, populated, and deleted completely every time the subroutine is called. In the first option sub myfunc { my @x=(1,2,3); return \@x; } the array isn't del

Re: return the list content

2014-09-08 Thread Ken Peng
Since this is a shadow copy, I don't think the first array will be deleted completely. Isn't it? The second option creates the same array and populates it, but then copies it to another anonymous array, deletes the first array, and returns a reference to the copy. -- To unsubscribe, e-mail:

Re: return the list content

2014-09-08 Thread Rob Dixon
On 18/08/2014 09:17, Ken Peng wrote: sub myfunc { my @x=(1,2,3); return \@x; } # or, sub myfunc { my @x=(1,2,3); return [@x]; } which one is the better way to return the list content? And if the method is an instance method? The first version of the subroutine is the best

Re: returning arrays (was: Re: return the list content)

2014-09-08 Thread Shawn H Corey
On Tue, 09 Sep 2014 00:13:13 +0200 lee wrote: > Shawn H Corey writes: > > > On Mon, 18 Aug 2014 16:17:53 +0800 > > Ken Peng wrote: > > > >> sub myfunc { > >> my @x=(1,2,3); > >> return \@x; > >> } > >> >

Re: returning arrays (was: Re: return the list content)

2014-09-08 Thread Jim Gibson
On Sep 8, 2014, at 3:13 PM, lee wrote: > Shawn H Corey writes: > >> On Mon, 18 Aug 2014 16:17:53 +0800 >> Ken Peng wrote: >> >>> sub myfunc { >>> my @x=(1,2,3); >>> return \@x; >>> } >>> >>> # or, >>&g

returning arrays (was: Re: return the list content)

2014-09-08 Thread lee
Shawn H Corey writes: > On Mon, 18 Aug 2014 16:17:53 +0800 > Ken Peng wrote: > >> sub myfunc { >> my @x=(1,2,3); >> return \@x; >> } >> >> # or, >> >> sub myfunc { >> my @x=(1,2,3); >> return [@x]; >> } >

Re: return the list content

2014-08-18 Thread John SJ Anderson
On Mon, Aug 18, 2014 at 1:38 AM, Paul Johnson wrote: > On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote: >> which one is the better way to return the list content? And if the >> method is an instance method? > > Functionally, the two are identical. The first is

Re: return the list content

2014-08-18 Thread Shawn H Corey
On Mon, 18 Aug 2014 16:17:53 +0800 Ken Peng wrote: > sub myfunc { > my @x=(1,2,3); > return \@x; > } > > # or, > > sub myfunc { > my @x=(1,2,3); > return [@x]; > } # or sub myfunc { return [ 1, 2, 3 ]; } -- Don't stop where the ink does.

Re: return the list content

2014-08-18 Thread Paul Johnson
On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote: > Hello, > > sub myfunc { > my @x=(1,2,3); > return \@x; > } > > # or, > > sub myfunc { > my @x=(1,2,3); > return [@x]; > } > > which one is the better way to return the list conte

return the list content

2014-08-18 Thread Ken Peng
Hello, sub myfunc { my @x=(1,2,3); return \@x; } # or, sub myfunc { my @x=(1,2,3); return [@x]; } which one is the better way to return the list content? And if the method is an instance method? Thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: Grabbing HTML fields, return them as hash

2014-06-10 Thread Christopher Brenk
, Jun 9, 2014 at 12:25 PM, Mike wrote: > Hello everyone. Can anyone point me in the direction of a module that will > allow me to grab HTML fields and return them as a hash? > > Thanks. > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional

Re: Grabbing HTML fields, return them as hash

2014-06-09 Thread Hao Wu
http://mojolicio.us/perldoc/Mojo/DOM not exactly what you want, but it is good to use. On Mon, Jun 9, 2014 at 12:25 PM, Mike wrote: > Hello everyone. Can anyone point me in the direction of a module that will > allow me to grab HTML fields and return them as a hash? > > Thanks.

Grabbing HTML fields, return them as hash

2014-06-09 Thread Mike
Hello everyone. Can anyone point me in the direction of a module that will allow me to grab HTML fields and return them as a hash? Thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: return just a match from an array without changing the array

2014-03-08 Thread Janek Schleicher
Am 04.03.2014 00:35, schrieb shawn wilson: So, when I do this: my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0]; I get a full line and not just the capture: # ARIN WHOIS data and services are subject to the Terms of Use When I do this: my $src = (grep {s/.*(ARIN|APNIC).*(\n)?/$1/} @r

Re: return just a match from an array without changing the array

2014-03-04 Thread Dr.Ruud
On 2014-03-04 00:35, shawn wilson wrote: So, when I do this: my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0]; I get a full line and not just the capture: # ARIN WHOIS data and services are subject to the Terms of Use First understand what you coded: grep() is a filter: it only passes

Re: return just a match from an array without changing the array

2014-03-04 Thread Rob Dixon
On 03/03/2014 23:35, shawn wilson wrote: So, when I do this: my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0]; I get a full line and not just the capture: # ARIN WHOIS data and services are subject to the Terms of Use When I do this: my $src = (grep {s/.*(ARIN|APNIC).*(\n)?/$1/} @ret

Re: return just a match from an array without changing the array

2014-03-04 Thread shawn wilson
On Mar 4, 2014 9:46 AM, "Shawn H Corey" wrote: > > On Tue, 4 Mar 2014 09:24:53 -0500 > shawn wilson wrote: > > > my $src = (map {s/.*(ARIN|APNIC).*(?:\n)?/$1/r} @ret)[0]; > > You do realize this is process the whole array and then throwing out > all but the first? And it has the side effect of mo

Re: return just a match from an array without changing the array

2014-03-04 Thread Shawn H Corey
On Tue, 4 Mar 2014 09:24:53 -0500 shawn wilson wrote: > my $src = (map {s/.*(ARIN|APNIC).*(?:\n)?/$1/r} @ret)[0]; You do realize this is process the whole array and then throwing out all but the first? And it has the side effect of modifying the array? -- Don't stop where the ink does.

Re: return just a match from an array without changing the array

2014-03-04 Thread shawn wilson
It needs to be grep as a map would return the first line no matter what - not what I want. Also, this doesn't work: sub whois { my ($whois) = @_; my $sock = IO::Socket::INET->new( PeerAddr=>$whois, PeerPort=>'43', Timeout=>'60', );

Re: return just a match from an array without changing the array

2014-03-03 Thread Shawn H Corey
On Mon, 3 Mar 2014 18:35:55 -0500 shawn wilson wrote: > So, when I do this: > my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0]; > I get a full line and not just the capture: > # ARIN WHOIS data and services are subject to the Terms of Use If you can't figure out what's wrong, neither wil

Re: return just a match from an array without changing the array

2014-03-03 Thread Ken Slater
I think you want to use 'map' instead of grep. HTH, Ken On Mon, Mar 3, 2014 at 6:35 PM, shawn wilson wrote: > So, when I do this: > my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0]; > I get a full line and not just the capture: > # ARIN WHOIS data and services are subject to the Terms o

return just a match from an array without changing the array

2014-03-03 Thread shawn wilson
So, when I do this: my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0]; I get a full line and not just the capture: # ARIN WHOIS data and services are subject to the Terms of Use When I do this: my $src = (grep {s/.*(ARIN|APNIC).*(\n)?/$1/} @ret)[0]; I get just the match but it also alters

Re: Make a sub routine return

2013-09-11 Thread Harry Putnam
Harry Putnam writes: Jesus... who wrote this illiterate crud? > Harry Putnam writes: > > Sorry to have dropped out on this. I called away and now have other ^ got > scripting to get done. > > But didn't want anyone to

Re: Make a sub routine return

2013-09-11 Thread Harry Putnam
Harry Putnam writes: Sorry to have dropped out on this. I called away and now have other scripting to get done. But didn't want anyone to think I didn't appreciate the replies. The walk thru of my (poor) could is very helpful... Thanks -- To unsubscribe, e-mail: beginners-unsubscr...@perl

Re: Make a sub routine return

2013-09-04 Thread Brandon McCaig
On Wed, Aug 28, 2013 at 11:48:45AM -0400, Harry Putnam wrote: > I know the format and scripting are probably pretty backwards but I > seem to recall it being important to have a `return' line in a > function. > > The code below was a script by itself but now I need to turn

Re: Make a sub routine return

2013-08-28 Thread Rob Dixon
On 28/08/2013 16:48, Harry Putnam wrote: The code below was a script by itself but now I need to turn it into a function inside a larger script... I've done something that sort of works but fails on a specific file name that looks like `.#somefile'. What does "fails" mean? Does it crash?, prod

Make a sub routine return

2013-08-28 Thread Harry Putnam
I know the format and scripting are probably pretty backwards but I seem to recall it being important to have a `return' line in a function. The code below was a script by itself but now I need to turn it into a function inside a larger script... I've done something that sort of works

Re: Need clarification in using return value for modules

2013-03-28 Thread *Shaji Kalidasan*
o God. --- From: Nathan Hilterbrand To: beginners@perl.org Sent: Thursday, 28 March 2013 8:54 PM Subject: Re: Need clarification in using return value for modules On 03/28/2013 11:17 AM, *Shaji Kalidasan* wrote: > G

Re: Need clarification in using return value for modules

2013-03-28 Thread Nathan Hilterbrand
0.1; sub foo() { print "Inside foo\n"; } sub bar { print "Inside bar\n"; } [/module] #Please note that I am not using a return value (1 in this case) as the last statement [code] use My::GoldenRock::Utilities 'bar'; print bar(); [/code] [output] Inside bar 1 [/output]

Need clarification in using return value for modules

2013-03-28 Thread *Shaji Kalidasan*
r { print "Inside bar\n"; } [/module] #Please note that I am not using a return value (1 in this case) as the last statement [code] use My::GoldenRock::Utilities 'bar'; print bar(); [/code]   [output] Inside bar 1 [/output] From where is the number 1 coming in the output. Ear

Re: Return values more than 256?

2013-03-08 Thread Charles DeRykus
id altogether since there's an implicit waitpid when the pipe gets closed. It gets a bit confusing but the pipe close needs to be checked first and then subsequently the child return as another poster demonstrated: close $trexe or warn $! ? "Error closing $tr pipe: $!"

Re: Return values more than 256?

2013-03-08 Thread WFB
On 8 March 2013 11:49, Dr.Ruud wrote: > On 2013-03-07 10:21, WFB wrote: > > waitpid($pid, 0); >> close($trexe); >> my $tr_ret = ($?>>8); >> > > Never postpone the reading of a global variable, > just snapshot it as early as possible. > > my $child = waitpid $pid, 0; > my $child_error = $?;

Re: Return values more than 256?

2013-03-08 Thread Dr.Ruud
On 2013-03-07 10:21, WFB wrote: waitpid($pid, 0); close($trexe); my $tr_ret = ($?>>8); Never postpone the reading of a global variable, just snapshot it as early as possible. my $child = waitpid $pid, 0; my $child_error = $?; # snapshot a global $child == -1 and die "No child with pid

Re: Return values more than 256?

2013-03-07 Thread Brandon McCaig
On Thu, Mar 07, 2013 at 02:24:58PM -0800, John W. Krahn wrote: > Or, instead of the three argument open, use the list option and you > won't need quotes: > > my $pid = open my $trexe, '-|', $tr, $tr_params > or die "Could not start TestRunner. $!"; Good catch. :) I didn't think that o

Re: Return values more than 256?

2013-03-07 Thread John W. Krahn
the return values of our program. This return codes are all in an area from 55000 to 6. I use open to invoke our program and print the output. Finally I use the $? variable and print the error code in case of an error. sub start_test_runner { my ($tr = shift, $tr_params) = @_; I don't

Re: Return values more than 256?

2013-03-07 Thread WFB
> > with different parameters. > > > > It works very well, but I have a problem with the return values > > of our program. This return codes are all in an area from 55000 > > to 6. I use open to invoke our program and print the > > output. Finally I use the $? vari

Re: Return values more than 256?

2013-03-07 Thread Brandon McCaig
On Thu, Mar 07, 2013 at 10:05:56AM -0500, Brandon McCaig wrote: > Apparently Windows supports 32-bit integers... The Web suggests > that if you want to get full 32-bit integers on Windows then you > should use the Win32::Process module instead of open. It's not > portable, but at least it will do w

Re: Return values more than 256?

2013-03-07 Thread Brandon McCaig
On Thu, Mar 07, 2013 at 10:21:40AM +0100, WFB wrote: > Hi, List, Hello, > To test our software I use perl to start it several times. My > perl script gather some information and start then the program > with different parameters. > > It works very well, but I have a probl

Return values more than 256?

2013-03-07 Thread WFB
. It works very well, but I have a problem with the return values of our program. This return codes are all in an area from 55000 to 6. I use open to invoke our program and print the output. Finally I use the $? variable and print the error code in case of an error. sub start_test_runner { my ($tr

Re: bool test return issues

2013-01-07 Thread David Precious
On Sat, 5 Jan 2013 09:01:26 -0700 Elim Qiu wrote: > perl shell is a good idear (I'm using ipython a lot. That's why I like > to try perl shell), but it really has problems. See attached > screenshot. Ah. Yeah, that's a different animal to Perl. This list can help you with problems with Perl, b

Re: bool test return issues

2013-01-07 Thread Brandon McCaig
Hello: On Sat, Jan 05, 2013 at 09:01:26AM -0700, Elim Qiu wrote: > perl shell is a good idear (I'm using ipython a lot. That's why I like > to try perl shell), but it really has problems. See attached > screenshot. I think you forgot to mention that you were using this psh. :) That or I missed it

Re: bool test return issues

2013-01-05 Thread Elim Qiu
perl shell is a good idear (I'm using ipython a lot. That's why I like to try perl shell), but it really has problems. See attached screenshot. On Sat, Jan 5, 2013 at 7:16 AM, David Precious wrote: > On Fri, 4 Jan 2013 15:43:41 -0700 > Elim Qiu wrote: > >> It's on snow leopard, perl version 5.10

Re: bool test return issues

2013-01-05 Thread David Precious
On Fri, 4 Jan 2013 15:43:41 -0700 Elim Qiu wrote: > It's on snow leopard, perl version 5.10.0 > > > > print 3 > 1, "\n"; > > prints 1 and ignored "\n" Includes the newline for me. If I had to hazard a guess, I'd say perhaps when you ran it you accidentally mistyped "." instead of "," (so yo

Re: bool test return issues

2013-01-04 Thread Rich Johnson
I'm getting both new lines to print. [code] use 5.10.0; print "1: "; print 3 > 1, "\n"; print "2: "; print 3 == 3, "\n"; [/code] [output] >perl booltest.pl 1: 1 2: 1 > [/output] Richard Johnson (708)253-8130 On Fri, Jan 4, 2013 at 5:43 PM, Elim Qiu wrote: > It's on snow leopard, perl versi

bool test return issues

2013-01-04 Thread Elim Qiu
It's on snow leopard, perl version 5.10.0 print 3 > 1, "\n"; prints 1 and ignored "\n" print 3 == 3, "\n"; prints 1 and "\n" There're some in consistency here. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn

Re: return something

2012-11-21 Thread timothy adigun
Hi shawn, On Wed, Nov 21, 2012 at 11:48 PM, shawn wilson wrote: > how do i return something when i've got a long regex and one of the > captures is empty? > > $_ = '"435" "" "634"; > my ($one, $two, $three)= /^ >"(\d

Re: return something

2012-11-21 Thread Shawn H Corey
On Wed, 21 Nov 2012 17:48:00 -0500 shawn wilson wrote: > how do i return something when i've got a long regex and one of the > captures is empty? > > $_ = '"435" "" "634"; > my ($one, $two, $three)= /^ >"(\d+)"\ >

Re: return something

2012-11-21 Thread Danny Gratzer
Instead of + use *. * means 0 or more while + means 1 or more On Nov 21, 2012 4:51 PM, "shawn wilson" wrote: > how do i return something when i've got a long regex and one of the > captures is empty? > > $_ = '"435" "" "634"; >

return something

2012-11-21 Thread shawn wilson
how do i return something when i've got a long regex and one of the captures is empty? $_ = '"435" "" "634"; my ($one, $two, $three)= /^ "(\d+)"\ "(\d+)"\ "(\d+)" /x; -- To unsubscribe, e-mail: beginners-unsubscr...@

Re: subroutines only return once

2012-07-29 Thread lina
On Sun, Jul 29, 2012 at 11:19 PM, Andy Bach wrote: > On Sun, Jul 29, 2012 at 10:01 AM, lina wrote: >> Strangely, it only substituted once, but not for the later once. >> Thanks ahead for your suggestions, I don't know why, > > Not exactly sure what you're up to - but you only open fh1 once - so >

Re: subroutines only return once

2012-07-29 Thread Andy Bach
On Sun, Jul 29, 2012 at 10:01 AM, lina wrote: > Strangely, it only substituted once, but not for the later once. > Thanks ahead for your suggestions, I don't know why, Not exactly sure what you're up to - but you only open fh1 once - so the inner while in your sub is going to read until eof and c

subroutines only return once

2012-07-29 Thread lina
Hi, I have written something as following, my $template_file="template"; my $h_data_file="h_data"; open my $fh1, '<', $template_file; open my $fh2, '<', $h_data_file; while(<$fh2>){ my ($h11,$h21,$h22,$h33)=split ' ', $_; &substitute($h11,$h21,$h22,$h33); say $h11,$h21

Re: return two varibles

2012-06-07 Thread Chris Nehren
On Thu, Jun 07, 2012 at 16:59:58 -0400 , Shawn H Corey wrote: > On 12-06-07 04:48 PM, Chris Stinemetz wrote: > >sub getMarketCells { > > my $val = shift; > > foreach my $k ( keys %apcHash ) { > > my($start, $end) = @{$apcHash{$k}}{qw/start end/}; > > r

Re: return two varibles

2012-06-07 Thread Robert Wohlfarth
On Thu, Jun 7, 2012 at 3:48 PM, Chris Stinemetz wrote: > sub getMarketCells { > my $val = shift; > foreach my $k ( keys %apcHash ) { >my($start, $end) = @{$apcHash{$k}}{qw/start end/}; >return($start, $end) if $val eq $k; > } > return ""; > } >

Re: return two varibles

2012-06-07 Thread Chris Stinemetz
> You may be returning two values, but you're only catching one. > > Try > > my( $start, $end ) = getMarketCells( $apc ); > > > chrs, > john. You are correct. Thank you very much! Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@per

Re: return two varibles

2012-06-07 Thread Shawn H Corey
On 12-06-07 04:48 PM, Chris Stinemetz wrote: sub getMarketCells { my $val = shift; foreach my $k ( keys %apcHash ) { my($start, $end) = @{$apcHash{$k}}{qw/start end/}; return($start, $end) if $val eq $k; } return ""; return; } A return with any arg

Re: return two varibles

2012-06-07 Thread Jim Gibson
On Jun 7, 2012, at 1:48 PM, Chris Stinemetz wrote: > Not sure what I am doing wrong but my subroutine is only returning the > value on varible. I would like it to return both $end and $start for > the correct parameter I am passing. If you want to return two or more values from a s

Re: return two varibles

2012-06-07 Thread John SJ Anderson
On Thursday, June 7, 2012 at 4:48 PM, Chris Stinemetz wrote: > my $test = getMarketCells($apc); > You may be returning two values, but you're only catching one. Try my( $start, $end ) = getMarketCells( $apc ); chrs, john. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For addi

return two varibles

2012-06-07 Thread Chris Stinemetz
Not sure what I am doing wrong but my subroutine is only returning the value on varible. I would like it to return both $end and $start for the correct parameter I am passing. Thank you for your help. #!/usr/bin/perl use warnings; use strict; my %apcHash = ( M => { "sta

RE: MIME::Lite Return-Path not being set

2012-04-25 Thread Bob McConnell
> From: sono-io > > > According to the RFC's, "Return-path" is reserved for use by the transport > servers. It is likely your server is stripping out the suggestion you have > put in > there. > > But I can set it using SMTP, so does sendmail handl

Re: MIME::Lite Return-Path not being set

2012-04-24 Thread sono-io
Hi Bob, Thanks for the reply. > According to the RFC's, "Return-path" is reserved for use by the transport > servers. It is likely your server is stripping out the suggestion you have > put in there. But I can set it using SMTP, so does sendmail ha

RE: MIME::Lite Return-Path not being set

2012-04-24 Thread Bob McConnell
> From: sono-io > > Unfortunately, I can't switch to SMTP right now (long story) and so I > need to find a way to get Mime::Lite to send the Return-Path. Does anyone > know how to do this? > > If Mime::Lite can't do it, does anyone have anot

Re: MIME::Lite Return-Path not being set

2012-04-24 Thread sono-io
Unfortunately, I can't switch to SMTP right now (long story) and so I need to find a way to get Mime::Lite to send the Return-Path. Does anyone know how to do this? If Mime::Lite can't do it, does anyone have another module they can recommend? The reason I

Re: MIME::Lite Return-Path not being set

2012-04-23 Thread sono-io
On Apr 23, 2012, at 5:06 PM, sono...@fannullone.us wrote: > I'm trying to set the Return-Path in emails that I send out, but I'm not > having any luck. Apparently the culprit is sendmail, which is the default for Mime::Lite. If I use SMTP instead, I'm able to

MIME::Lite Return-Path not being set

2012-04-23 Thread sono-io
I'm trying to set the Return-Path in emails that I send out, but I'm not having any luck. Here's the code I'm trying: use strict; use warnings; use MIME::Lite; my $msg = MIME::Lite->new ( From => 'sen...@example.c

Re: return ()

2011-02-10 Thread Uri Guttman
In Google Mail it BM> appeared as a new thread. >>  BM> sub test3 >>  BM> { >>  BM>     my @empty_array = (); >> >>  BM>     return @empty_array; >>  BM> } >> >> that is very different than the above two. BM> The

Re: return ()

2011-02-10 Thread Brandon McCaig
my @empty_array = (); > >  BM>     return @empty_array; >  BM> } > > that is very different than the above two. The point was to compare the results. It wasn't supposed to be the same. :-/ > have it by definition. the array is returned in scalar context and it >

Re: return ()

2011-02-10 Thread Uri Guttman
n the thread. BM> sub test1 BM> { BM> return (); BM> } BM> sub test2 BM> { BM> return; BM> } those two are the same. period. the parens are only to group an expression if any. there is NO forming of a list by those parens. BM> sub test3 BM>

Re: about return

2011-02-10 Thread Ramesh Kumar
From: terry peng To: beginners Sent: Thu, February 10, 2011 2:07:43 PM Subject: about return >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: return ()

2011-02-10 Thread Brandon McCaig
2011/2/10 terry peng : > does "return ()" mean return an empty list, or just mean "return" since "()" > is optional in Perl? I would have guessed an empty list, but the best way to find out is to check. :) According to my tests, it's returning accord

return ()

2011-02-10 Thread terry peng
does "return ()" mean return an empty list, or just mean "return" since "()" is optional in Perl? thanks!

Re: about return

2011-02-10 Thread Uri Guttman
>>>>> "AW" == Alex Wang02 writes: AW> Terry, AW> Here is my understanding: AW> You can try defined function to verify the return value in List AW> context, you can find the return value is (undef) instead of undef AW> once the condition is fa

RE: Re[2]: about return

2011-02-10 Thread Alex Wang02
Terry, Here is my understanding: You can try defined function to verify the return value in List context, you can find the return value is (undef) instead of undef once the condition is false. Because you are using @result=&yoursubName instead of $result=&yoursubName. Please correct

Re[2]: about return

2011-02-10 Thread terry peng
Thu, 10 Feb 2011 10:04:55 +0200 письмо от Shlomi Fish : > > In List context it will return an empty list. You may have meant in scalar > context in which case: > > Sorry , my typo. I did mean the scalar context. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: about return

2011-02-10 Thread Shlomi Fish
On Thursday 10 Feb 2011 09:13:34 terry peng wrote: > 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 pr

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

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 {

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

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 a

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&

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 lis

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 : (...); w

Re: Return value from function

2011-01-13 Thread John Delacour
At 02:34 -0500 13/01/2011, shawn wilson wrote: I dig what you're saying about always using return. However I don't (have never used / seen) a case where a sub returns last expression. An example maybe? #!/usr/local/bin/perl use strict; use feature qw(say); say &SUB(); sub SU

Re: Return value from function

2011-01-13 Thread Dr.Ruud
On 2011-01-13 08:18, John W. Krahn wrote: If you want to return a false value it is usually better to use return with no value: return; I prefer subs to normally return a single scalar, which can be a direct value like undef, or a reference to a more complex data structure, etc. If you

Re: Return value from function

2011-01-13 Thread Dr.Ruud
On 2011-01-12 22:23, Parag Kalra wrote: On shell, successful command returns exit status of 0. As a best practice what status value shall a Perl function return. A function can return other kinds of values too. Going by the fact that Perl function returns the value of last command in it

Re: Return value from function

2011-01-12 Thread Uri Guttman
>>>>> "sw" == shawn wilson writes: sw> I dig what you're saying about always using return. However I sw> don't (have never used / seen) a case where a sub returns last sw> expression. An example maybe? the classic case which is used in the c

  1   2   3   4   5   6   7   8   >