Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Tie: Creating Special Objects

by btrott (Parson)
on Apr 21, 2000 at 10:46 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: perltutorial [id://8344]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-19 06:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found