|
In a message dated 4/11/2006 6:30:12 A.M. Eastern Standard Time,
[EMAIL PROTECTED] writes:
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: 11 April 2006 07:16 > To: [EMAIL PROTECTED] > Cc: [email protected] > Subject: Re: messy regex > > > [...] > > i intended the test code to be > > invoked like this: > > > > perl test_code.pl test_data.dat > > > > if the code and data are placed in separate files, the perl code will > > open the > > data file and process the data line by line, with each line being a > > listing. > > Actually, it is easier if the code and test data are in the same file > for instances like this. That is what the __DATA__ tag, and the DATA > file handle are for. See 'perldoc perldata' for more info. > > HTH > > -- > Brian Raven hi brian --
i tend to reserve the use of the DATA handle to configuration-ish
purposes
and to other uses that are integral to the operation of the code (or of
a
module) rather than for testing. see, e.g., ``perldoc
SelfLoader''.
some reasons for this...
firstly, there does not seem to be (or i have not yet found) a neat,
simple
way to fall back to use of the DATA filehandle in the absence of a
file
name specified on the command line. matters are further
complicated
by the difference between the ``lexical scalar reference'' filehandle,
which
i prefer, and the ``package global'' nature of the DATA
filehandle.
secondly, if you have a mechanism, neat or not, for automatic
fallback
to built-in test data in the absence of ``real-world'' data (almost always,
in
my experience, contained in a separate file), it is extremely easy -- at
least
for me -- to get confused about just what data you are really working
with.
after about the second or third time i discovered that, because the data
file
was in a different directory or for some other reason inaccessible, i had
been
exercising some mickey-mouse, built-in data over and over again instead
of gnarly, real-world data, i started to avoid the built-in test
data technique.
and thirdly... i think there was a third reason, but i can't
think of it
right now, so...
best regards -- bill walters
|
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
