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 PM, Daryl

Re: subroutine

2012-08-17 Thread Chris Stinemetz
> In the above line, `shift` will return just the first element from the > @_ array. $y will therefore be undefined. The line should be rewritten > as: > my ( $x, $y ) = @_; > Thank you. I should have caught that. Chris

Re: subroutine

2012-08-17 Thread Alan Haggai Alavi
Hello Chris, > Can this subroutine be better written? > I am getting the following erros: > > Use of uninitialized value $y in subtraction (-) at form.pl line 52. > Use of uninitialized value $y in addition (+) at form.pl line 52. > > sub avg_az { > my($x, $y) = shift(@_); In the above line, `s

Re: subroutine in seperate file, question

2012-08-11 Thread Rob Dixon
On 11/08/2012 12:43, Shawn H Corey wrote: No, @ISA is used only by Exporter.pm Exporter makes no use of @ISA at all. This array is a per-package variable used by Perl internally to implement object-oriented inheritance. It is very often used to make a package a subclass of Exporter, but that i

Re: subroutine in seperate file, question

2012-08-11 Thread Rajeev Prasad
August 11, 2012 6:43 AM Subject: Re: subroutine in seperate file, question On Sat, 11 Aug 2012 02:49:56 -0400 shawn wilson wrote: > On Aug 10, 2012 11:41 PM, wrote: > > > > > I mean to ask, wether they will clash with the same loaded modules > loaded > > > in ca

Re: subroutine in seperate file, question

2012-08-11 Thread Shawn H Corey
On Sat, 11 Aug 2012 02:49:56 -0400 shawn wilson wrote: > On Aug 10, 2012 11:41 PM, wrote: > > > > > I mean to ask, wether they will clash with the same loaded modules > loaded > > > in calling script? > > > > > > > No. they are loaded only once. > > > > Well, they will both be in ISA to look up

Re: subroutine in seperate file, question

2012-08-10 Thread shawn wilson
On Aug 10, 2012 11:41 PM, wrote: > > > I mean to ask, wether they will clash with the same loaded modules loaded > > in calling script? > > > > No. they are loaded only once. > Well, they will both be in ISA to look up separately but there is no conflict.

Re: subroutine in seperate file, question

2012-08-10 Thread pangj
> I mean to ask, wether they will clash with the same loaded modules loaded > in calling script? > No. they are loaded only once. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: subroutine in seperate file, question

2012-08-10 Thread Rajeev Prasad
I mean to ask, wether they will clash with the same loaded modules loaded in calling script? From: "pa...@riseup.net" To: Rajeev Prasad Cc: perl list Sent: Friday, August 10, 2012 9:05 PM Subject: Re: subroutine in seperate file, question Yes, t

Re: subroutine in seperate file, question

2012-08-10 Thread pangj
Yes, the modules in required file will be loaded. $ cat ext.pl use CGI; use DBI; 1; $ cat main.pl require 'ext.pl'; use Data::Dumper; print Dumper \%INC; Thus run perl main.pl to see what prints. > i want to keep a peice of code which uses CGI and DBIx module in a > seperate file, and want t

Re: subroutine returning data

2012-06-10 Thread Shlomi Fish
Hi all, On Tue, 05 Jun 2012 10:15:36 -0700 "John W. Krahn" wrote: > [ Please do not top-post your replies. Please remove non-relevant text > from your reply before posting. TIA ] > > don't insult and dismiss out of hand the findings of those who take the > > time to help you. > > If I insul

Re: subroutine returning data

2012-06-05 Thread John W. Krahn
[ Please do not top-post your replies. Please remove non-relevant text from your reply before posting. TIA ] Jack Maney wrote: ProTip: The top two results from Google state: PROTIP | Know Your Meme About PROTIP is a term often used in forums and comments to preface snarky, obvious, count

List behavior pro tips (was: Re: subroutine returning data)

2012-06-05 Thread John SJ Anderson
:08 AM, Jack Maney wrote: > ProTip: If you're going to ask for help, don't insult and dismiss out of hand > the findings of those who take the time to help you. > > -Original Message- > From: John W. Krahn [mailto:jwkr...@shaw.ca] > Sent: Tuesday, June 05, 201

RE: subroutine returning data

2012-06-05 Thread Jack Maney
ProTip: If you're going to ask for help, don't insult and dismiss out of hand the findings of those who take the time to help you. -Original Message- From: John W. Krahn [mailto:jwkr...@shaw.ca] Sent: Tuesday, June 05, 2012 2:18 AM To: Perl Beginners Subject: Re: subroutine

Re: subroutine returning data

2012-06-05 Thread John W. Krahn
Shlomi Fish wrote: On Mon, 04 Jun 2012 14:19:27 -0700 "John W. Krahn" wrote: Chris Stinemetz wrote: I have a subroutine that I want to "return 1" only if the value of %{$href->{$_[0]}} is equal to 'ND' for the whole 24 occurences. One way to do it: sub site_offAir { return values %{

Re: subroutine returning data

2012-06-04 Thread Shlomi Fish
Hello John, On Mon, 04 Jun 2012 14:19:27 -0700 "John W. Krahn" wrote: > Chris Stinemetz wrote: > > I have a subroutine that I want to "return 1" only if the value of > > %{$href->{$_[0]}} is equal to 'ND' for the whole 24 occurences. > > > One way to do it: > > sub site_offAir { > return

Re: subroutine returning data

2012-06-04 Thread John W. Krahn
Chris Stinemetz wrote: I have a subroutine that I want to "return 1" only if the value of %{$href->{$_[0]}} is equal to 'ND' for the whole 24 occurences. One way to do it: sub site_offAir { return values %{ $href->{ $_[ 0 ] } } == grep( $_ eq 'ND', values %{ $href->{ $_[ 0 ] } } ) ? 1 :

Re: subroutine returning data

2012-06-04 Thread Chris Stinemetz
Thank you everyone. Your help has been very helpful.. Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: subroutine returning data

2012-06-04 Thread Shawn H Corey
On 12-06-04 02:01 PM, Bill Stephenson wrote: The "values %{$href->{$_[0]}}" code is pretty ugly but I get it now. And it make sense to break out of the loop as soon as you don't pass the test. sub site_offAir { my $site_id = shift @_; for my $activity_code ( values %{ $activity_of->{$sit

Re: subroutine returning data

2012-06-04 Thread Bill Stephenson
Thanks Shawn! The "values %{$href->{$_[0]}}" code is pretty ugly but I get it now. And it make sense to break out of the loop as soon as you don't pass the test. Kindest Regards, Bill Stephenson On Jun 4, 2012, at 12:49 PM, Shawn H Corey wrote: > On 12-06-04 12:30 PM, Chris Stinemetz wrote

Re: subroutine returning data

2012-06-04 Thread Shawn H Corey
On 12-06-04 12:30 PM, Chris Stinemetz wrote: I have a subroutine that I want to "return 1" only if the value of %{$href->{$_[0]}} is equal to 'ND' for the whole 24 occurences. Any suggestions is greatly appreciated. Thank you, Chris sub site_offAir { for (values %{$href->{$_[0]}}) { r

Re: subroutine returning data

2012-06-04 Thread Bill Stephenson
On Jun 4, 2012, at 11:30 AM, Chris Stinemetz wrote: > I have a subroutine that I want to "return 1" only if the value of > %{$href->{$_[0]}} is equal to 'ND' for the whole 24 occurences. > > Any suggestions is greatly appreciated. > Chris, I don't know how to read your hash directly (hash of ha

Re: subroutine returning data

2012-06-04 Thread Paul Johnson
On Mon, Jun 04, 2012 at 11:30:30AM -0500, Chris Stinemetz wrote: > I have a subroutine that I want to "return 1" only if the value of > %{$href->{$_[0]}} is equal to 'ND' for the whole 24 occurences. > > Any suggestions is greatly appreciated. > > Thank you, > > Chris > > sub site_offAir { >

Re: subroutine call

2011-12-05 Thread Shlomi Fish
Hi Ganesh, On Mon, 5 Dec 2011 14:16:29 +0530 ganesh vignesh wrote: > stop mail to me The instructions at the bottom of every E-mail read: [QUOTE] To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ [/QUOTE] Ple

Re: subroutine call

2011-12-05 Thread Shlomi Fish
Hello, John. On Sun, 04 Dec 2011 12:46:40 -0800 "John W. Krahn" wrote: > > You should assign $marketInfo{$mkt} to a variable, or alternatively do: > > > > my ($start, $end) = @{$marketInfo{$mkt}}{qw(start end)}; > > > >> my $end = $marketInfo{$mkt}->{"end"}; > >> if( $cell>=

Re: subroutine call

2011-12-04 Thread John W. Krahn
Shlomi Fish wrote: in addition to the good advice that Uri gave you - some comments on your code. On Sun, 4 Dec 2011 07:40:09 -0600 Chris Stinemetz wrote: I have a program that I am working on improveing. The fist step I have taken is converting it in using the strict pragma. Now when this

Re: subroutine call

2011-12-04 Thread Dr.Ruud
On 2011-12-04 18:12, Shlomi Fish wrote: Chris wrote: my $cell = substr($market,0,index($market,"_")); print "$_ <", substr( $_, 0, index $_, "_" ), ">\n" for qw/ foo1 foo2_bar foo3_bar_baz /; foo1 foo2_bar foo3_bar_baz This can be more idiomatically (and more briefly) done us

Re: subroutine call

2011-12-04 Thread Shlomi Fish
Hi Chris, in addition to the good advice that Uri gave you - some comments on your code. On Sun, 4 Dec 2011 07:40:09 -0600 Chris Stinemetz wrote: > I have a program that I am working on improveing. The fist step I have > taken is converting it in using the strict pragma. > > Now when this subr

Re: subroutine call

2011-12-04 Thread Uri Guttman
On 12/04/2011 08:40 AM, Chris Stinemetz wrote: I have a program that I am working on improveing. The fist step I have taken is converting it in using the strict pragma. Now when this subroutine call is made I get the following compilation error: Global symbol "$cell" requires explicit package n

Re: Subroutine question: Placement of subroutine definitions matter?

2010-11-02 Thread Akhthar Parvez K
On Wednesday 03 Nov 2010, Uri Guttman wrote: > the recommended style IS to call subs with (). where did you get the > opposite idea? As I said, I think I'd read it somewhere. Yeah, may be that was required with only Perl 4 or earlier. > APK> I remember I'd read in the past that & should be us

Re: Subroutine question: Placement of subroutine definitions matter?

2010-11-02 Thread Uri Guttman
> "APK" == Akhthar Parvez K writes: APK> On Sunday 31 Oct 2010, Shlomi Fish wrote: APK> [ snipped ] >> > &testsub1(); >> >> Don't use leading ampersands in subroutine calls: APK> Suppose a subroutine definition is written down the line and it's APK> called without (), which is

Re: Subroutine question: Placement of subroutine definitions matter?

2010-11-02 Thread Akhthar Parvez K
On Sunday 31 Oct 2010, Shlomi Fish wrote: [ snipped ] > > &testsub1(); > > Don't use leading ampersands in subroutine calls: Suppose a subroutine definition is written down the line and it's called without (), which is the recommended style: &SubRoutine or SubRoutine I remember I'd read in the

Re: Subroutine question: Placement of subroutine definitions matter?

2010-10-30 Thread Shlomi Fish
Hi Owen, On Saturday 30 October 2010 20:56:57 Owen Chavez wrote: > A straightforward question I hope. > > Can someone explain why the following code runs without a hitch: > > #!C:/strawberry/perl/bin/perl.exe > use strict; > use warnings; > > my $testvar = "TEST"; > &testsub1(); Don't use lead

Re: Subroutine question: Placement of subroutine definitions matter?

2010-10-30 Thread Uri Guttman
> "OC" == Owen Chavez writes: OC> use strict; OC> use warnings; that is good. OC> my $testvar = "TEST"; OC> &testsub1(); that is wrong. don't call subs with & as it isn't needed and can cause a bug if you don't know what you are doing with it. OC> sub testsub1 { OC> print "The

Re: Subroutine

2010-10-11 Thread Rob Coops
On Mon, Oct 11, 2010 at 5:28 PM, Jyoti wrote: > Hello, > > Can anyone help me out to call all subroutines from different .pm files in > a > specific directory please ? > > Many Thanks, > Jyoti > Hi Jyoti, I think you should be a little more specific I assume you are asking how to include a mod

Re: Subroutine doesn't write to file

2010-04-12 Thread Philip Potter
On 12 April 2010 16:39, Uri Guttman wrote: >> "PP" == Philip Potter writes: > >  PP> On 12 April 2010 11:34, Shlomi Fish wrote: >  >> Hi Uri and Philip (and Abimael), >  >> On Monday 12 Apr 2010 10:32:36 Uri Guttman wrote: >  >>>   PP> Where did I say PBP was always right? I just didn't want

Re: Subroutine doesn't write to file

2010-04-12 Thread Uri Guttman
> "PP" == Philip Potter writes: PP> On 12 April 2010 11:34, Shlomi Fish wrote: >> Hi Uri and Philip (and Abimael), >> On Monday 12 Apr 2010 10:32:36 Uri Guttman wrote: >>>   PP> Where did I say PBP was always right? I just didn't want to let your >>>   PP> style argument be the onl

Re: Subroutine doesn't write to file

2010-04-12 Thread Shlomi Fish
On Monday 12 Apr 2010 13:59:31 Philip Potter wrote: > On 12 April 2010 11:34, Shlomi Fish wrote: > > Hi Uri and Philip (and Abimael), > > > > On Monday 12 Apr 2010 10:32:36 Uri Guttman wrote: > >> PP> Where did I say PBP was always right? I just didn't want to let > >> your PP> style argument b

Re: Subroutine doesn't write to file

2010-04-12 Thread Philip Potter
On 12 April 2010 11:34, Shlomi Fish wrote: > Hi Uri and Philip (and Abimael), > On Monday 12 Apr 2010 10:32:36 Uri Guttman wrote: >>   PP> Where did I say PBP was always right? I just didn't want to let your >>   PP> style argument be the only one in this thread, since there are >> clearly PP> peo

Re: Subroutine doesn't write to file

2010-04-12 Thread Shlomi Fish
Hi Uri and Philip (and Abimael), On Monday 12 Apr 2010 10:32:36 Uri Guttman wrote: > > "PP" == Philip Potter writes: > PP> On 12 April 2010 07:55, Uri Guttman wrote: > >>> "PP" == Philip Potter writes: > >> PP> On 12 April 2010 04:31, Uri Guttman wrote: > >> >>> "AM" == A

Re: Subroutine doesn't write to file

2010-04-12 Thread Uri Guttman
> "PP" == Philip Potter writes: PP> On 12 April 2010 07:55, Uri Guttman wrote: >>> "PP" == Philip Potter writes: >> >>  PP> On 12 April 2010 04:31, Uri Guttman wrote: >>  >>> "AM" == Abimael Martinez writes: >>  >> >>  >>  AM>   print {$tmp} "$div_start"; >>  >>

Re: Subroutine doesn't write to file

2010-04-12 Thread Philip Potter
On 12 April 2010 07:55, Uri Guttman wrote: >> "PP" == Philip Potter writes: > >  PP> On 12 April 2010 04:31, Uri Guttman wrote: >  >>> "AM" == Abimael Martinez writes: >  >> >  >>  AM>   print {$tmp} "$div_start"; >  >> >  >> no need for the {} around a single scalar handle. > >  PP> Bu

Re: Subroutine doesn't write to file

2010-04-11 Thread Uri Guttman
> "PP" == Philip Potter writes: PP> On 12 April 2010 04:31, Uri Guttman wrote: >>> "AM" == Abimael Martinez writes: >> >>  AM>   print {$tmp} "$div_start"; >> >> no need for the {} around a single scalar handle. PP> But it *does* comply with Perl Best Practices #136.

Re: Subroutine doesn't write to file

2010-04-11 Thread Philip Potter
On 12 April 2010 04:31, Uri Guttman wrote: >> "AM" == Abimael Martinez writes: > >  AM>   print {$tmp} "$div_start"; > > no need for the {} around a single scalar handle. But it *does* comply with Perl Best Practices #136. * It makes the filehandle obviously different from the other argumen

Re: Subroutine doesn't write to file

2010-04-11 Thread John W. Krahn
Abimael Martinez wrote: Hi, Hello, I am having some problems making this little script work, it is supposed glob files from current dir, and add stuff at the top and bottom of such files. I am also unshure how the "autoflush" works. use strict; use IO::File; use IO::Handle qw( ); my @

Re: Subroutine doesn't write to file

2010-04-11 Thread Uri Guttman
> "AM" == Abimael Martinez writes: AM> Hi, AM> I am having some problems making this little script work, it is supposed AM> glob files from current dir, and add stuff at the top and bottom of such AM> files. I am also unshure how the "autoflush" works. AM> use strict; AM> u

Re: Subroutine foo redefined a bar

2009-07-29 Thread Dermot
2009/7/29 Shawn H. Corey : > Chas. Owens wrote: >> >> On Wed, Jul 29, 2009 at 04:37, Dermot wrote: >> snip >>> >>> I'll grab myself a version of Scalar::Utils and have a play. >> >> snip >> >> If your version of Perl is 5.8.0 or later you already have >> Scalar::Utils (it is in the core). More la

Re: Subroutine foo redefined a bar

2009-07-29 Thread Shawn H. Corey
Chas. Owens wrote: On Wed, Jul 29, 2009 at 04:37, Dermot wrote: snip I'll grab myself a version of Scalar::Utils and have a play. snip If your version of Perl is 5.8.0 or later you already have Scalar::Utils (it is in the core). Actually, that would be Scalar::Util You may, however, wish

Re: Subroutine foo redefined a bar

2009-07-29 Thread Chas. Owens
On Wed, Jul 29, 2009 at 04:37, Dermot wrote: snip > I'll grab myself a version of Scalar::Utils and have a play. snip If your version of Perl is 5.8.0 or later you already have Scalar::Utils (it is in the core). -- Chas. Owens wonkden.net The most important skill a programmer can have is the ab

Re: Subroutine foo redefined a bar

2009-07-29 Thread Dermot
2009/7/29 John W. Krahn : > Dermot wrote: >> >> 2009/7/28 John W. Krahn : >>> >>> Dermot wrote: 2009/7/28 John W. Krahn : Thanx for gettig back to me. > Which error?  Copy and paste the error message you are receiving. Opps sorry. Here you are. Every time I st

Re: Subroutine foo redefined a bar

2009-07-28 Thread John W. Krahn
Dermot wrote: 2009/7/28 John W. Krahn : Dermot wrote: 2009/7/28 John W. Krahn : Thanx for gettig back to me. Which error? Copy and paste the error message you are receiving. Opps sorry. Here you are. Every time I start the httpd I get Processing config file: /etc/apache-modperl/conf.d/de

Re: Subroutine foo redefined a bar

2009-07-28 Thread Chas. Owens
On Tue, Jul 28, 2009 at 17:05, Dermot wrote: snip >>    my $bid = shift; >>    my $items = ref $_[0] ? $_[0] : \...@_; >> > > Perhaps you can expand, if $_[0] was a scalar wouldn't that get > assigned to $items? snip Normal scalars (i.e. strings and numbers) are not references, therefore the resul

Re: Subroutine foo redefined a bar

2009-07-28 Thread Dermot
2009/7/28 John W. Krahn : > Dermot wrote: >> >> 2009/7/28 John W. Krahn : >> >> Thanx for gettig back to me. >> >>> Which error?  Copy and paste the error message you are receiving. >> >> Opps sorry. Here you are. Every time I start the httpd I get >> > > That message means that you have defined tw

Re: Subroutine foo redefined a bar

2009-07-28 Thread John W. Krahn
Dermot wrote: 2009/7/28 John W. Krahn : Thanx for gettig back to me. Which error? Copy and paste the error message you are receiving. Opps sorry. Here you are. Every time I start the httpd I get Processing config file: /etc/apache-modperl/conf.d/dev_vhost.conf Subroutine addItemsToBasket

Re: Subroutine foo redefined a bar

2009-07-28 Thread Dermot
2009/7/28 John W. Krahn : Thanx for gettig back to me. > Which error?  Copy and paste the error message you are receiving. Opps sorry. Here you are. Every time I start the httpd I get Processing config file: /etc/apache-modperl/conf.d/dev_vhost.conf Subroutine addItemsToBasket redefined at /ex

Re: Subroutine foo redefined a bar

2009-07-28 Thread John W. Krahn
Dermot wrote: Hi, Hello, I noticed this error appearing when I stop/started my httpd server recently (yes this is modperl 1 code). Which error? Copy and paste the error message you are receiving. This offending code reads a like this: package Some::Pack; .. .. sub addItemsToBasket {

RE: Subroutine getting its own path

2009-01-27 Thread Malyj, Mark
Shawn, Your code my ( $whoami ) = grep { m{ \b ServiceScript \. pl \b }msx } values %INC; print "$whoami\n"; works great!! If you have time, could you explain to a Windows guy like me what the grep is doing? Yes, I know that someone could still spoof me, but this is my first line of defense. -

Re: Subroutine getting its own path

2009-01-27 Thread mark . malyj
Sorry, I had a typo. My code snippet above should have said: require 'ServiceScript.pl'; my $svccmdline = "$uspname $uspparams"; $rtncode = ServiceRoutine($svccmdline, \...@rtndata); - Marko -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h.

RE: Subroutine getting its own path

2009-01-27 Thread Mr. Shawn H. Corey
On Tue, 2009-01-27 at 12:27 -0500, Malyj, Mark wrote: > Your code > > my ( $whoami ) = grep { m{ \b ServiceScript \. pl \b }msx } values % > INC; > print "$whoami\n"; > > works great!! If you have time, could you explain to a Windows guy > like > me what the grep is doing? See `perldoc -f grep`

Re: Subroutine getting its own path

2009-01-27 Thread Mr. Shawn H. Corey
On Mon, 2009-01-26 at 15:07 -0800, mark.ma...@gdit.com wrote: > My question is this – how can my ServiceRoutine in ServiceScript.pl > get its own path? I would like to record this to the database for > auditing purposes as well, to make sure no one is using a substitute > version of ServiceRoutine

Re: subroutine

2008-03-26 Thread Bobby
Thanks, the latter one works for me. Appreciate all the help. "Chas. Owens" <[EMAIL PROTECTED]> wrote: On Wed, Mar 26, 2008 at 12:32 PM, Bobby wrote: > Chas, > > Thanks for all your pointers. I guess i should read a Perl book first before > attempting to write codes in it :). I'm learning the h

Re: subroutine

2008-03-26 Thread Chas. Owens
On Wed, Mar 26, 2008 at 12:32 PM, Bobby <[EMAIL PROTECTED]> wrote: > Chas, > > Thanks for all your pointers. I guess i should read a Perl book first before > attempting to write codes in it :). I'm learning the hard way but making > small progresses. I was using what little knowledge i have and duc

Re: subroutine

2008-03-26 Thread Bobby
Chas, Thanks for all your pointers. I guess i should read a Perl book first before attempting to write codes in it :). I'm learning the hard way but making small progresses. I was using what little knowledge i have and duck taped my way around the problem. Maybe one day i will get this Perl thi

Re: subroutine

2008-03-25 Thread Chas. Owens
On Tue, Mar 25, 2008 at 1:47 PM, Bobby <[EMAIL PROTECTED]> wrote: > Hi, > > I need another set of eyes to help look over the codes below. I have a > subroutine that check for a comma in $strA and do some regex replacement, if > there's no comma then return the values of the two arguments passed

Re: subroutine in here document

2008-03-14 Thread Jenda Krynicky
From: "Kashif Salman" <[EMAIL PROTECTED]> > I know I can create html code using CGI and call a subroutine in there > easily but if i were to use a here document for my html code, can I > call a subroutine in there? > > print< HTML code > <--Can I call foo() in here somehow? > E

Re: subroutine in here document

2008-03-14 Thread Rob Dixon
Kashif Salman wrote: > I know I can create html code using CGI and call a subroutine in there easily but if i were to use a here document for my html code, can I call a subroutine in there? print< Yes you can, but I'd rather not tell you how because it's likely to be the ugliest of several poss

Re: subroutine in here document

2008-03-14 Thread Gunnar Hjalmarsson
Kashif Salman wrote: I know I can create html code using CGI and call a subroutine in there easily but if i were to use a here document for my html code, can I call a subroutine in there? print< Check out the FAQ entry perldoc -q "function calls" -- Gunnar Hjalmarsson Email: http://www.gu

Re: subroutine simultaneousness

2008-02-18 Thread Chas. Owens
On Feb 18, 2008 11:17 AM, David Moreno <[EMAIL PROTECTED]> wrote: > > On Feb 17, 2008 3:48 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > > > use IO::Handle; > > STDOUT->autoflush; > > > > to the start of your program. > > > What's the difference from this to setting $| to true? snip In this speci

Re: subroutine simultaneousness

2008-02-18 Thread David Moreno
On Feb 17, 2008 3:48 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > use IO::Handle; > STDOUT->autoflush; > > to the start of your program. What's the difference from this to setting $| to true? -- David Moreno - http://www.damog.net/ Yes, you can.

Re: subroutine simultaneousness

2008-02-18 Thread MK
PROBLEM SOLVED on comp.lang.perl.tk: $MW->update; # whenever you want the screen updated On 02/18/2008 09:46:51 AM, MK wrote: okay, this is definitely a Tk or GUI issue, since incorporating a for real "print" (ie. to STDOUT) statement does come out in proper sequence. -- To unsubsc

Re: subroutine simultaneousness

2008-02-18 Thread MK
okay, this is definitely a Tk or GUI issue, since incorporating a for real "print" (ie. to STDOUT) statement does come out in proper sequence. Does anyone know if there is a filehandle other than STDOUT for tk requests? The simplest version of the problem: use IO::Handle; sub tmptest {

Re: subroutine simultaneousness

2008-02-17 Thread MK
On 02/17/2008 03:48:40 PM, Rob Dixon wrote: MK wrote: > I have a subroutine that begins with a message ("Processing...") and then proceeds to perform several gigs worth of file transfer via system calls. Basically: sub transfer { print "Processing...\n"; foreach $e (@array) {

Re: subroutine simultaneousness

2008-02-17 Thread John W. Krahn
MK wrote: I have a subroutine that begins with a message ("Processing...") and then proceeds to perform several gigs worth of file transfer via system calls. Basically: sub transfer { print "Processing...\n"; foreach $e (@array) { print "file $e\n"; system "cp $e"; #

Re: subroutine simultaneousness

2008-02-17 Thread Rob Dixon
MK wrote: > I have a subroutine that begins with a message ("Processing...") and then proceeds to perform several gigs worth of file transfer via system calls. Basically: sub transfer { print "Processing...\n"; foreach $e (@array) { print "file $e\n"; system "cp $e"; #

Re: subroutine references

2007-08-27 Thread Jenda Krynicky
From: "Mr. Shawn H. Corey" <[EMAIL PROTECTED]> > Dr.Ruud wrote: > >> Why do people who write these books have exercises of little > >> practical value? > > > > An exercise needs to be educational. > > I have worked in programming for 25 years and during that time I have > never use a closure an

Re: subroutine references

2007-08-27 Thread Jenda Krynicky
From: Chris <[EMAIL PROTECTED]> > Ok, if anyone is interested, here is my answer: > > #!/usr/bin/perl -w > > # Testing code for Exercise 6-1. Your task is to write the sub > # gather_mtime_between. > > use strict; > > use File::Find; > use Time::Local; > > my ($start, $stop)

Re: subroutine references

2007-08-27 Thread Peter Scott
On Sun, 26 Aug 2007 13:04:48 -0400, Mr. Shawn H. Corey wrote: > I have worked in programming for 25 years and during that time I have > never use a closure and have never seen one used. Boggle. I don't think any program I write these days doesn't have one. They're the most convenient way of re

Re: subroutine references

2007-08-26 Thread Chas Owens
On 8/26/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: > Dr.Ruud wrote: > >> Why do people who write these books have exercises of little > >> practical value? > > > > An exercise needs to be educational. > > I have worked in programming for 25 years and during that time I have never > use a >

Re: subroutine references

2007-08-26 Thread brian d foy
In article <[EMAIL PROTECTED]>, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: > Chris wrote: > > I'm working on yet another exercise from Intermediate Perl. I've been > > given a script that searches for files that fall between a two > > timestamps. > Why do people who write these books have e

Re: subroutine references

2007-08-26 Thread Rob Dixon
Mr. Shawn H. Corey wrote: Dr.Ruud wrote: Why do people who write these books have exercises of little practical value? An exercise needs to be educational. I have worked in programming for 25 years and during that time I have never use a closure and have never seen one used. I may be har

Re: subroutine references

2007-08-26 Thread Randal L. Schwartz
> "Shawn" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes: Shawn> Oh, I get it. When I said 25 years, you thought that I meant 25 years Shawn> with Perl. No. Shawn> Sorry, about the confusion. No confusion. Shawn> I have programmed in many different languages and have never seen a

Re: subroutine references

2007-08-26 Thread Mr. Shawn H. Corey
Randal L. Schwartz wrote: "Shawn" == Shawn H Corey <[EMAIL PROTECTED]> writes: Shawn> Why do you include an insult with every thing you post? I don't think I do. I was only making fun of your claim, since you made the claim. Why did you include "25 years"? It just sets you up for a fall. :)

Re: subroutine references

2007-08-26 Thread Randal L. Schwartz
> "Shawn" == Shawn H Corey <[EMAIL PROTECTED]> writes: Shawn> Why do you include an insult with every thing you post? I don't think I do. I was only making fun of your claim, since you made the claim. Why did you include "25 years"? It just sets you up for a fall. :) Shawn> BTW, what lege

Re: subroutine references

2007-08-26 Thread Mr. Shawn H. Corey
Randal L. Schwartz wrote: Think of closures as "variables that hold behavior". Sure, maybe you've never needed that in your legendary 25 years in the industry, but I've used it *frequently* in my 30 years. :) Why do you include an insult with every thing you post? BTW, what legends do you ha

Re: subroutine references

2007-08-26 Thread Randal L. Schwartz
> ""Mr" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes: Mr> Objects can do the same things as closures, which is store and hide data, Mr> but don't have this problem of having to keep in mind two phases of the Mr> same code. But objects have fixed code with variable data. Closures can have

Re: subroutine references

2007-08-26 Thread Mr. Shawn H. Corey
Dr.Ruud wrote: Why do people who write these books have exercises of little practical value? An exercise needs to be educational. I have worked in programming for 25 years and during that time I have never use a closure and have never seen one used. I may be harsh in my definitions but t

Re: subroutine references

2007-08-25 Thread Dr.Ruud
Chris schreef: > #!/usr/bin/perl -w Toss the -w, and insert a "use warnings;". > my ($start, $stop) = @_; > my @starting_directories = @_; This doesn't do what I think that you think it does. > my($sec, $min, $hour, $day, $mon, $yr, $dow) = localtime; Is the start/top related to today? What

Re: subroutine references

2007-08-25 Thread Chris
Ok, if anyone is interested, here is my answer: #!/usr/bin/perl -w # Testing code for Exercise 6-1. Your task is to write the sub # gather_mtime_between. use strict; use File::Find; use Time::Local; my ($start, $stop) = @_; my @starting_directories = @_; my @found_items; sub gather_mtime_betw

Re: subroutine references

2007-08-25 Thread Dr.Ruud
Shawn schreef: > Chris: >> I'm working on yet another exercise from Intermediate Perl. I've >> been given a script that searches for files that fall between a two >> timestamps. For the exercise, I am supposed to write the >> gather_mtime_between subroutine that will return two references to >>

Re: subroutine references

2007-08-25 Thread Mr. Shawn H. Corey
Mr. Shawn H. Corey wrote: Chris wrote: I'm working on yet another exercise from Intermediate Perl. I've been given a script that searches for files that fall between a two timestamps. For the exercise, I am supposed to write the gather_mtime_between subroutine that will return two references t

Re: subroutine references

2007-08-25 Thread Mr. Shawn H. Corey
Chris wrote: I'm working on yet another exercise from Intermediate Perl. I've been given a script that searches for files that fall between a two timestamps. For the exercise, I am supposed to write the gather_mtime_between subroutine that will return two references to two subroutines. One wil

Re: subroutine references

2007-08-25 Thread Tom Phoenix
On 8/25/07, Chris <[EMAIL PROTECTED]> wrote: > if (my $start <= $timestamp <= my $stop){ Until Perl 6, you have to break down chain comparisons like this into separate comparisons, usually joined with 'and': if ($start <= $timestamp and $timestamp <= $stop) { ... } But the real problem

Re: subroutine call makes foreach exit?

2006-11-16 Thread John W. Krahn
Andy Greenwood wrote: > I'm writing a script for work that will dig for DNS records for a > given domain name and put the entries into an array. At the end of the > digging, it outputs the array elements to the screen, asks if > everything looks good, and if so, writes them out to the shell and > b

Re: subroutine call makes foreach exit?

2006-11-16 Thread Tom Phoenix
On 11/16/06, Andy Greenwood <[EMAIL PROTECTED]> wrote: if (/^$domain.+MX\s+(\d+)\s+(.+)/) { Because $domain is a string (and not a pattern), interpolating it into a pattern could cause troubles. First, any metacharacters it contains may affect the match. But also, is that pattern going

Re: subroutine call makes foreach exit?

2006-11-16 Thread Andy Greenwood
On 11/16/06, Jay Savage <[EMAIL PROTECTED]> wrote: On 11/16/06, Andy Greenwood <[EMAIL PROTECTED]> wrote: > I'm writing a script for work that will dig for DNS records for a > given domain name and put the entries into an array. At the end of the > digging, it outputs the array elements to the sc

Re: subroutine call makes foreach exit?

2006-11-16 Thread Jay Savage
On 11/16/06, Andy Greenwood <[EMAIL PROTECTED]> wrote: I'm writing a script for work that will dig for DNS records for a given domain name and put the entries into an array. At the end of the digging, it outputs the array elements to the screen, asks if everything looks good, and if so, writes th

Re: Subroutine returning 2 arrays

2006-10-12 Thread Mumia W.
On 10/12/2006 11:23 AM, Moon, John wrote: -Original Message- From: Gallagher, Tim F (NE) [mailto:[EMAIL PROTECTED] Sent: Thursday, October 12, 2006 11:55 AM To: Perl Beginners Subject: Subroutine returning 2 arrays From a subroutine I would like to return 2 separate arrays like this

RE: Subroutine returning 2 arrays

2006-10-12 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Believe you want to do as a reference otherwise it justs returns the data as a flat file or stream of data. Here is a snippet. Would get away from a and b since the $a and $b are used by sort. Know that it is an array, but would get away from that. Also use strict and warnings. #!perl use strict

RE: Subroutine returning 2 arrays

2006-10-12 Thread Moon, John
-Original Message- From: Gallagher, Tim F (NE) [mailto:[EMAIL PROTECTED] Sent: Thursday, October 12, 2006 11:55 AM To: Perl Beginners Subject: Subroutine returning 2 arrays >From a subroutine I would like to return 2 separate arrays like this sub TEST { @a = ("a1","a2","a3","a4","a5","

Re: Subroutine returning 2 arrays

2006-10-12 Thread Mumia W.
On 10/12/2006 10:55 AM, Gallagher, Tim F (NE) wrote: From a subroutine I would like to return 2 separate arrays like this sub TEST { @a = ("a1","a2","a3","a4","a5","a6","a7"); @b = ("b1","b2","b3","b4","b5","b6","b7"); return (@a, @b); } my(@lala,@baba) = TEST; print @lala; The probl

  1   2   3   >