Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: cut a string in a string

by serf (Chaplain)
on Feb 03, 2006 at 17:57 UTC ( #527751=note: print w/ replies, xml ) Need Help??


in reply to cut a string in a string

If you are matching many instances of this (say reading a log file that is 700MB or more and checking each line for this string) then you are likely to find that the performance improves if you:

  • tie the match down to the bare minimum of wildcard characters,
  • specify everything that you know is going to be in the match,
  • and also anchor the match where possible to the beginning and end of the string (or line) so it doesn't have to try iterating over the string...
use strict; use warnings; my $line = "SNMPv2-MI::enterprises.343.2.10.3.5.100.1.0=INT"; my $match = $1 if $line =~ /^SNMPv2-MI::enterprises([0-9\.]+)=INT$/;


Comment on Re: cut a string in a string
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://527751]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2015-07-03 08:39 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 (49 votes), past polls