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
} > }, > sub { return @found_items } > ) > } If you do it this way there is no point in returning the subroutine references in the first place. You are using global variables here (even though you declare them with my). You can'

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

subroutine references

2007-08-25 Thread 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 two subroutines. One will use File::Fin