NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Something odd in the sample chapter (Score:1)
#!/usr/bin/perl
# filename: counter.pl
use strict;
use warnings;
# Declare $counter lexical within the foreach loop
foreach my $counter (0
{
print "Counter = $counter\n";
$counter++;
}
# $counter has disappeared -- fatal compilation error!
print "Counter at the end is $counter\n";
I was wondering why $counter is incremented. I thought that would be taken care of as it loops
Re:Something odd in the sample chapter (Score:1)
In this sample program, $counter is declared to be lexical for the "foreach" block. So foreach increments $counter once per iteration -- and when the block ends, our lex
Re:Something odd in the sample chapter (Score:1)
Re:Something odd in the sample chapter (Score:1)
I guess that the errata listing on my site will go up later today...
Re:Something odd in the sample chapter (Score:1)
Re:Something odd in the sample chapter (Score:2)
--Nat
Re:debugging books (Score:1)
To amplify what Gnat said, books have no symbolic debugger. They have no compiler. Every thing must be checked by hand, just like in the Golden Age of mainframe computers. This is an extraordinary task even for a simple book. What frequently seems to happen is that the harder bits of code are looked at much more carefully than the seemingly harmless bits. After all, everyone can toss of "hello, world" right?
I've tech reviewed a half dozen books and co-authored one and I'm still amazed at how many things ge
Re:Something odd in the sample chapter (Score:1)
Small suggestion (if I may). Throughout the earlier parts of the chapter where you're explaining lexical and package variables you've got things like: print "main::x = '$x'\n". You make your point exceedingly well, but I'd be really careful about surrounding variable names with ' marks because they're valid package separators (I didn't see you mention that either) and you might wind up saying something you didn't mean
Re:Something odd in the sample chapter (Score:2, Interesting)
For example, I originally had a section on prototypes in the book. I dumped it because most Perl programmers don't use them on anything approa
Not to be picky... (Score:1)
The loop sets(aliases actually) counter
to succesive elements of the list which is
in this case 1..10
Were that I say, pancakes?
Why? (Score:1)
-gb Epistemologist at-large
Re:Why? (Score:1)
Re:Why? (Score:2)
(Actually, it's many audiences; some beginners prefer the existing intro-to-perl books, while others find them lacking)
Read a review of Core Perl (Score:1)