hysteriaweb has asked for the wisdom of the Perl Monks concerning the following question:

because i don't have enough hours in my day or enough capacity in my brain I have decided to learn perl is just not going to happen.

I am a c++ programmer and seem to be able to work my way round scripts of most kinds.

Anyway I have been doing to mrtg logging and I have a couple of scripts which need to pull an uptime from my modem using snmp.

I have the script to do it BUT I need a tiny bit of help with the pattern matching so I can pull the string out of the returned string from the snmpget command.

ok, there are TWO formats I could get back

system.sysUpTime.0 = Timeticks: (28926461) 3 days, 8:21:04.61.

OR

system.sysUpTime.0 = Timeticks: (28926461) 8:21:04.61.

I have a script but I need the pattern matching string to accept this line and pull out EVERYTHING after the ')'

i.e.

3 days, 8:21:04.61.
or
8:21:04.61.

Please help, I managed some basic pattern matching but the fact that it uses a ')' and then I need everything after it, seems to have me stumped.

Thanks guys

Replies are listed 'Best First'.
Re: easy one this
by ignatz (Vicar) on Mar 04, 2002 at 22:21 UTC
    #!/usr/bin/perl -w use strict; my $foo = "system.sysUpTime.0 = Timeticks: (28926461) 8:21:04.61"; $foo =~ /\)(.*)$/g; print $1 . "\n";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ()-()                                                      ()-()
     \"/    DON'T   BLAME   ME,   I  VOTED   FOR    PACO!       \"/
      `                                                          ` 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      Thank you very much ignatz
Re: easy one this
by gellyfish (Monsignor) on Mar 04, 2002 at 22:18 UTC

    This doesn't address your original question but you might want to look at the module Net::SNMP so you can get this stuff directly in Perl

    /J\

Re: easy one this
by stephen (Priest) on Mar 04, 2002 at 22:17 UTC
    (untested):
    my $uptime = 'system.sysUpTime.0 = Timeticks: (28926461) 8:21:04.61.'; $uptime =~ m/\) (.+)$/; my $after_paren = $1;

    stephen