DCPM: perltutopen blues....
mb at matthewb.org
Mon Jul 7 03:01:27 CDT 2003
-----BEGIN PGP SIGNED MESSAGE-----
On Friday 04 July 2003 23:37, Simon Waters wrote:
> Thanks, I think I was just getting confused with the documentation.
> I'm still slightly vague on when perl is doing file handles, and when
> it is expecting file names... When they look vaguely like good old
> fashioned Bourne shell file handles all is clear.
Perl filehandles look pretty much the same as in C. The ones you are
dealing with are hidden behind two layers of obscurity. First, your
module takes a filename as an argument and manipulates the filhandle
internally, second it does so by means of the IO::File (standard)
FWIW, I typically use IO::File because it allows you to treat a
filehandle as a scalar (by returning a reference to one) which is cool
if you want a painless way to build an array of them or chuck them
around various functions etc.
> My script has gained a plethora of "options", including the
> ubiquitous "--debug" ;-)
> Maybe trying to learn emacs and perl at the same time was a bit
> ambitious, but it will be the best indented code I've written in
They make a good team:
C-x h C-u M-| perl -pe 'EXPR' (Mark Jason Dominus)
...I have bound F12 to a Lisp function that runs the script I am
working on, diplaying the output in a new buffer. That is quite handy.
Also, check out M-x cperl-perldoc for context-specific help. Use
cperl-mode, not the default perl-mode with GNU Emacs.
> Next fun bit will be a signal handler, it all looks simple("use
> sigtrap" ?), but I never seen to find any example scripts - maybe I
> should squander another book token. Hmm 15GBP book tokens, 10GBP
> extra if WH Smiths... I'll go check the review section.
I guess the Camel is your best bet. I have read pretty much all the
books there are on Perl (seriously) and if there is one that really
made me think *wow* it is `Object-Oriented Perl' by Damien Conway
(Manning). Having said that, it does not address your problem.
> Then ensuring it is self documenting....
$ perldoc perlpod
> then sorting the output
> routines, and I'll be ready to fix the special cases...
> Why does "use warnings" dislike "@array" and suggest "$array",
> seems less clear to me, or am I missing something elementary?
The first is an array slice, the second an array element. While
contrary to the conventions we see in other languages, Perl wants you
to refer to a scalar as a scalar, even if it is an element of an array.
The first is a list, albeit with one element.
Just keep telling yourself: `it all makes perfect sense'...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
-----END PGP SIGNATURE-----
More information about the Devoncornwall-pm