Skip Menu |

This queue is for tickets about the NetAddr-MAC CPAN distribution.

Report information
The Basics
Id: 96045
Status: resolved
Priority: 0/
Queue: NetAddr-MAC

People
Owner: Nobody in particular
Requestors: OLIVER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: $NetAddr::MAC::errstr is not reset between calls to new()
Hi, I notice a few strange things with errstr: $NetAddr::MAC::errstr is not reset between calls to new(). This results in the variable remaining with an "error" message even after a future successful call to new(). Also, it's not clear when the ->errstr() method should be used from the docs. Finally there seems to be an _errstr slot in the object but it's never used? (what I'm trying to achieve is calling ->new() and then easily finding out whether the module thinks a valid MAC address has been provided, before doing further things.) regards, oliver.
Thanks for calling my attention to this oliver. I will look through this problem later this evening. On Wed May 28 19:53:24 2014, OLIVER wrote: Show quoted text
> Hi, > > I notice a few strange things with errstr: > > $NetAddr::MAC::errstr is not reset between calls to new(). This > results in the variable remaining with an "error" message even after a > future successful call to new(). > > Also, it's not clear when the ->errstr() method should be used from > the docs. > > Finally there seems to be an _errstr slot in the object but it's never > used? > > (what I'm trying to achieve is calling ->new() and then easily finding > out whether the module thinks a valid MAC address has been provided, > before doing further things.) > > regards, > oliver.
Sorry, i meant to get to this sooner but was caught up in other things. I have created an rt96045 branch and pushed it to github, please see https://github.com/djzort/NetAddr-MAC/tree/rt96045 I have also released 0.82_01 to CPAN Please feel free to pull/push etc. NOTE: I havent added any new tests yet! Show quoted text
> $NetAddr::MAC::errstr is not reset between calls to new(). This > results in the variable remaining with an "error" message even after a > future successful call to new().
Good find, i am now setting it to undef. See above branch link or cpan. Show quoted text
> Also, it's not clear when the ->errstr() method should be used from > the docs.
I have expanded its pod. I would be grateful if you could review it, i tend to typo frequently. Show quoted text
> Finally there seems to be an _errstr slot in the object but it's never > used?
Indeed you are right, an ommission on my part. There is only one object method that can give an error at this point - and i have updated it. Show quoted text
> (what I'm trying to achieve is calling ->new() and then easily finding > out whether the module thinks a valid MAC address has been provided, > before doing further things.)
The errstr() function is intended to be used _after_ the object is created. When creating objects you can either use the or//$variable style method (sort of like DBI) or you can enable and use the eval{}/die() method. The pod covers the two options in exhaustive detail, but if you would be kind enough to provide feedback i will very gladly incorporate it! I made a major change in behaviour at 0.8 as I found it tiresome to use in my most common use case (dealing with cable modem mac addresses in ISP systems). But provided both approaches for both compatibility and also there are still instances where the eval{}/die() style is useful (big try{} blocks for example).
ive pushed these fixed in 0.83