in reply to Re: regexp problem - extract all but last part of SNMP OID
in thread regexp problem - extract all but last part of SNMP OID

Alternatively, if the initial condition is essential, you can use a capture on the lead in. This is inefficient, but necessary without variable-length look behind support.

$oidfila  =~ s/(^[0-9\.]+)\.[0-9]+$/$1/;

Replies are listed 'Best First'.
Re^3: regexp problem - extract all but last part of SNMP OID
by hbm (Hermit) on Nov 21, 2011 at 19:18 UTC

    Which, according to perlre, can be written more efficiently with the "keep" construct:

    $oidfila =~ s/^[\d.]+\K\.\d+$//;