in reply to creating 2 file writing objects

I'd be grateful if someone can point out where I'm going wrong

Brother postman, since you have displayed interest in our (my) advice, let me suggest to you that it's always better to use modules that are already on the CPAN other than re-invent your own wheel. The advantage of this approach is a plenty. First, CPAN modules are generally well (or sufficiantly) tested. Second, you don't have to do any work re-implementing the tool/functionality.

As for specific module suggestions, check out these ones:

UPDATE:

Also, as far as your class code goes, you aren't doing proper OO implementation. The $filehandle should be stored 'inside' your object. So, your constructor should look as follows:
sub new { my $class_name = shift; my $self = {}; $self->{output_file} = shift; $self->{append} = shift; $self->{file_handle} = undef ; bless ($self,$class_name); # bless ($self); # AHA! How could I have missed that one! +Thanks go to [bronto] for pointing that out. No need to bless the thi +ng twice.. one time is enough already! ;> return $self; }
Further, the rest of the methods in your modules aren't even true 'member' methods as they don't make use of the object 'reference'. In Perl, you've got to link a method to an object as so:
sub start { my $self = shift; # Get 'reference' to the class instance (aka obje +ct)! # use this reference to retrieve object specific attributes! open($self->{filehandle}, " . . . "); # . . . Rest of your code . . . }


Update: bronto thanks for pointing that out. However, the last portion of your statement is invalid:
but I don't see the need to bless $self twice, an error that you inherited from vladb's code

I didn't make any errors and therefore noone could have 'inherited' any from me. I simply copied and pasted the original poster's code and overlooked that he (the original author, not I) called the 'bless' method twice.

_____________________
# Under Construction

Replies are listed 'Best First'.
Re: Re: creating 2 file writing objects
by bronto (Priest) on Jun 27, 2002 at 14:21 UTC

    I subscribe the advice of using CPAN modules and of putting the filehandle inside the object, but I don't see the need to bless $self twice, an error that you inherited from vladb's code

    Update: s/[vladb]/[postman]/

    Sorry, wrong target ;-)

    Ciao!
    --bronto

    # Another Perl edition of a song:
    # The End, by The Beatles
    END {
      $you->take($love) eq $you->made($love) ;
    }