Andrew Gaffney <[EMAIL PROTECTED]> wrote:
: <code>
: package Skyline;
: : <big SNIP of other module code>
: : sub generate_report_html([EMAIL PROTECTED]@) {
: my ($title, $columns, $data) = @_;
Here begins my problems with prototypes. Let's try this sample script:
sub generate_report_html([EMAIL PROTECTED]@);
my $title = 'foo'; my @column_names = 1 .. 4; my @data = ( [1 .. 4], [5 .. 8] );
generate_report_html $title, @column_names, @data;
sub generate_report_html([EMAIL PROTECTED]@) { my ($title, $columns, $data) = @_; print "Report Done"; }
Everything is just fine until I decide to get my column names from a subroutine:
generate_report_html $title, column_names(), @data;
sub column_names { return 1 .. 4; }
Now I have to go into a library and find out why things are failing and repair them. If I repair them, do I now have a problem with all the other programs written using that library of sub routines?
I could massage the output of column_names() to work with generate_report_html(),
generate_report_html $title, @{ [ column_names() ] }, @data;
Or I could change the output of column_names(). But if column_names() is another library sub routine I'm back to square one.
I like perl because I tend to not have to jump through hoops to program. Protoypes limit me too much. I'd rather not have to plan so far ahead when solving a problem.
Based on your advice and that of other posters, I have removed the prototype. I was already sending the function array/hash references, so I didn't have to change anything.
-- Andrew Gaffney Network Administrator Skyline Aeronautics, LLC. 636-357-1548
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>