The perldl shell supports my variables but only within a single line or context (e.g. in braces). The pdl2 shell maintains lexical (and package) information throughout the session.
--Chris On Thu, Oct 20, 2011 at 3:12 PM, Joel Berger <[email protected]> wrote: > perldl uses PDL::NiceSlice by default. > Perl scripts do not. Add 'use PDL::NiceSlice' and it should work. > > Joel > > On Thu, Oct 20, 2011 at 2:09 PM, Joel Berger <[email protected]> wrote: >> This is an effect of the 'strict' pragma. All it means is that you >> need 'my' in front of the declaration of $section, and all other >> variables. The perldl shell has some problems with 'my' variables. I'm >> not so sure if pdl2 has that problem. Anyway the code will work >> without 'use strict' but since you want it, use 'my'. >> >> Joel >> >> On Thu, Oct 20, 2011 at 1:13 PM, zentara <[email protected]> wrote: >>> Hi, >>> >>> I was going thru the Newbook today, and came upon a few >>> typos, as I read with a fine tooth comb. :-) >>> >>> First, is there somewhere to report spelling and typo errors? >>> I already found 3 in the first few lessons. Where and how should they be >>> reported? >>> >>> Also, this is a nit-pick, but it is confusing. >>> I was going thru the code example on node3.html , under the >>> section Twinkle, twinkle, little star. >>> >>> <quote> >>> >>> Twinkle, twinkle, little star. >>> Let's look at something else, we'll zoom in on a small piece of the image: >>> >>> $section = $gal(337:357,178:198); >>> imag $section; # It's the bright star >>> >>> </quote> >>> >>> When I try to put the above code, (which runs fine in perldl ), >>> into a conventional Perl script, it won't run, and stops with an error >>> >>> " syntax error at ./z line 18, near "$gal(" >>> Global symbol "$section" requires explicit package name at ./z line 19, >>> <DATA> line 387. >>> Execution of ./z aborted due to compilation errors." >>> >>> The script to generate the error is: >>> >>> #!/usr/bin/perl >>> use warnings; >>> use strict; >>> use PDL; >>> use PDL::Graphics::PGPLOT; >>> >>> my $a = rfits "m51_raw.fits"; >>> my $flat = rfits "m51_flatfield.fits"; >>> imag $flat; >>> <>; >>> >>> my $gal = $a / $flat; >>> my $section = $gal(337:357, 178:198 ); >>> imag $section; # It's the bright star >>> <>; >>> __END__ >>> >>> It's obvious that >>> my $section = $gal(337:357, 178:198 ); >>> is not proper Perl code, but the question becomes >>> how many other exceptions are there? >>> >>> The tutorial starts out by saying that the same code >>> can be used in perldl as in a conventional Perl script. >>> >>> So, how much leeway is there between Perl syntax, and perldl syntax? >>> >>> Thanks, >>> zentara >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> Perldl mailing list >>> [email protected] >>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl >>> >> > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
