[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Newbee comments for macperl book



I do'nt know if these are two common problems with newbees but these two
items kept me head scratching for quite a while while learning macPerl.
1 - There seems to be no direct help reference to the "here" construct.
There is a comment in the book programming perl that says something like,
final token must be on a line all by itself. Now you tell me. The reference
in perldiag man page to:  "Can't find string terminator %s anywhere before
EOF"  did'nt help much.
$_ = <<'EOL';
   all text from here to that string above in single quotes goes into $_
   including the newlines.
   next line intentionally left blank

   EOL #and this because its not on a line by itself
EOL

2 -  If you split the above string  on newlines the blank is an element in
the array.You cannot use "\n" or  "" or even undef to parse out the empty
element as below.  I think because of the dynamic linked list nature of
arrays in perl. Now where did I read that?
#continuing from above
@lines = split("\n",$_);
foreach (@lines) {    #$_ is target
if("\n") { next; }     #wrong
if("")    { next; }         #wrong
if(undef) { next; }   #wrong
if(!$_)     { next; }  #correct. $_ is logically false because linked list
node has no string
...
}



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch