Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: some regex help

by DamnDirtyApe (Curate)
on Apr 05, 2004 at 22:17 UTC ( #342776=note: print w/replies, xml ) Need Help??


in reply to some regex help

Would this do the trick?

#! /usr/bin/perl use strict; use Data::Dumper; my %hash; for (<DATA>) { $hash{$1} = $2 if /Managed Code\s+(\S+)\s*=\s*(\S+)/; } print Dumper \%hash; __DATA__ Managed Node XYZ123 = MN Type = Combo Rim = Planner

_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche

Replies are listed 'Best First'.
Re: Re: some regex help
by emilford (Friar) on Apr 06, 2004 at 01:04 UTC
    I think your solution might be the best approach. There shouldn't be any spaces in the variables, so \S+ should catch everything I would want. Great.
      Well remember now that "-" and "_" are not alpha_numeric characters and are used quiet often in file names, directory names, variable names, subroutine names, etc..

      It is up to you how you want to implement something but don't be too nearsighted to be able to envision future possible snags. This is how you could get into trouble on larger projects.

      www.perlskripts.com
        If you go back to the code discussed, you'll notice that the test was for \S, which matches any non-whitespace characters. Including - and _. Therefore your objection does not apply.
        A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2020-06-02 18:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (19 votes). Check out past polls.

    Notices?