in reply to Re: Meaning of stat's 'rdev' value.
in thread Meaning of stat's 'rdev' value.

This is off topic sorta, but what's the point of

sub MAJOR_MASK () { 03777400 } sub MAJOR_SHIFT () { 0000010 } sub MINOR_MASK () { 037774000377 } sub MINOR_SHIFT () { 0000000 }
?

Those subs only return numbers, why not just put them into constants or even variables?

meh.

Replies are listed 'Best First'.
Re^3: Meaning of stat's 'rdev' value.
by mr_mischief (Monsignor) on Sep 06, 2006 at 15:25 UTC
    I can't speak for gellyfish. Once upon a time that was a popular way to do constants in Perl, though. The pragmas haven't always been around, and not changing an upper-cased variable just by convention often doesn't cut it. By making it returned from a sub, you can make it really constant without pragmas.


    Christopher E. Stith
Re^3: Meaning of stat's 'rdev' value.
by gellyfish (Monsignor) on Sep 06, 2006 at 15:37 UTC

    In File::Stat::Bits these (and some other values) are defined in a separate .ph file that is generated at install time. As mr_mischief points out it is probably preferable to have these as constants so that they aren't changed from underneath you, but using constant in a separate file is going to add another layer of complexity, when all it does really is create a subroutine just like the above - the extra stuff is just to put the subroutines in the right package and make sure you don't overwrite some important symbols.

    /J\