Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 cooling their heels in the Monastery: (10)
As of 2015-07-28 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls