Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: File::CounterFile problems and hashes

by particle (Vicar)
on Oct 23, 2002 at 23:39 UTC ( #207575=note: print w/replies, xml ) Need Help??

in reply to File::CounterFile problems and hashes

you should be locking and unlocking the File::CounterFile object, not the class.

## File::CounterFile->lock(); ## should be $counter->lock(); $counter->inc; ## File::CounterFIle->unlock(); ## should be $counter->unlock();

i haven't tested, but this looks like the likely problem. the error message stems from the fact that a File::CounterFile object is a blessed hash reference, so perl is trying to use the string 'File::CounterFlie' as a reference to the object (a hash reference.)

~Particle *accelerates*

Replies are listed 'Best First'.
Re: Re: File::CounterFile problems and hashes
by cecil36 (Pilgrim) on Oct 24, 2002 at 12:57 UTC
    Another problem.
    $counter = File::CounterFile->new("./msgid", "1"); $id = $counter->value(); $filename = "pagemsg".$id;
    I get a "Bad counter magic" error when the value is accessed. Am I accessing the counter file properly?
      According to the File::CounterFile code unless the first line of the counter file is #COUNTER-1.0 you'll get the Bad counter magic error. Was the counter file created by File::CounterFile? If not remove the existing file and let the module do the rest.


      i'm having trouble installing File::CounterFile. 'nmake test' is barfing badly on perl 5.6.1 build 626 for MSWin32. i get a 'bad counter magic' error from 't/basic.t'. until this is resolved, i can't help you debug File::CounterFile any more. perhaps i'll get a chance to look at the module later this week.

      ~Particle *accelerates*

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://207575]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2020-02-19 09:37 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (81 votes). Check out past polls.