Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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?
[marioroy]: LA, yeah. than there's no reason why it cannot work inside qx. But chatting is hard in PM. I cannot see the code now.
[shmem]: Lady_Aleena: sometimes a quick glance isn't enough.
[Lady_Aleena]: What?! Can't stat ~/Music: No such file or directory? The ~/ doesn't expand?
[Lady_Aleena]: And the env variable $HOME doesn't work either. !@#$
[shmem]: no, that's a shell feature. Use $ENV{HOME}

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2017-04-23 21:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.