Skip Menu |

This queue is for tickets about the File-Tail-Multi CPAN distribution.

Report information
The Basics
Id: 83561
Status: open
Priority: 0/
Queue: File-Tail-Multi

People
Owner: Nobody in particular
Requestors: perl [...] dannywarren.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.1
Fixed in: 0.1



Subject: File::Tail::Multi isn't actually object oriented
After seeing some very strange behavior from an application, I finally traced the issue back to File::Tail::Multi. It looks as if this module isn't actually object oriented, as per the documentation. It stores a single globally-scoped copy of all class attributes, which means that any additional instances of this module will clobber the previous one. This breaks the following scenarios: 1) Creating multiple instances of the module within the same application (say you wanted different "MaxAge" or "NumLines" settings for different groups of files) 2) If two different modules each use this module, and you happen to use both in your application, they will clobber each other To demonstrate, here is some sample code: use File::Tail::Multi; my $obj_one = File::Tail::Multi->new ( Files => ['/tmp/file_one'], RemoveDuplicate => 0, MaxAge => 5, NumLines => 5, ); my $obj_two = File::Tail::Multi->new ( Files => ['/tmp/file_two'], RemoveDuplicate => 0, MaxAge => 10, NumLines => 10, ); printf "obj_one: maxage: %d\n", $obj_one->{MaxAge}; foreach my $file ( @{ $obj_one->{FileArray} } ) { printf "obj_one: %s\n", $file->{name}; } print "\n"; printf "obj_two: maxage: %d\n", $obj_two->{MaxAge}; foreach my $file ( @{ $obj_two->{FileArray} } ) { printf "obj_two: %s\n", $file->{name}; } You would expect this code to output: obj_one: maxage: 5 obj_one: /tmp/file_one obj_two: maxage: 10 obj_two: /tmp/file_two But instead you get: obj_one: maxage: 10 obj_one: /tmp/file_one obj_one: /tmp/file_two obj_two: maxage: 10 obj_two: /tmp/file_one obj_two: /tmp/file_two
I must have bumped the "fixed in" dropdown when submitting this, apologies. You will need to clear that out as I am unable to.