Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
We don't bite newbies here... much
 
PerlMonks  

Tie: Creating Special Objects

by btrott (Parson)
on Apr 21, 2000 at 10:46 UTC ( #8344=perltutorial: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        use Sys::uptime;
        my $uptime;
    ...
    
        printf "Load average over the last minute: %s\n",
            $uptime->load('one');
    
  2. or download this
        package Sys::uptime;
        use Class::Struct;
        use Carp;
        use strict;
    
  3. or download this
        my $WAIT_CACHE = 5;
    
  4. or download this
        struct 'Uptime' => [
            'uptime'    => '$',
    ...
            'load'      => '%',
            'as_string' => '$',
        ];
    
  5. or download this
        sub TIESCALAR {
            my $class = shift;
    ...
            bless $self, $class;
            $self;
        }
    
  6. or download this
        printf "Load average over the last minute: %s\n",
            $uptime->load('one');
    
  7. or download this
        sub FETCH {
            my $self = shift;
    ...
            }
            return $self->{up};
        }
    
  8. or download this
        sub get_uptime {
            local $_ = `uptime`;
    ...
                croak "What was that? Bad uptime.";
            }
        }
    
  9. or download this
        package Sys::uptime;
        use Class::Struct;
    ...
        }
    
        1;
    
  10. or download this
        use Sys::uptime;
    
    ...
    
            sleep 3;
        }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-04-20 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (487 votes), past polls