Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Regex to capture field values

by choroba (Archbishop)
on Jan 13, 2016 at 12:53 UTC ( #1152670=note: print w/replies, xml ) Need Help??


in reply to Regex to capture field values

When you encounter name, start a new hash.
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my @array = ( 'name riya', 'age 34', 'company xxxx', 'name vinoth', 'age 25', 'call 12345678', 'company xxxx', 'address asdd', 'country Ind', ); my %hash; my $name; while (@array) { my $line = shift @array; if (my ($field, $value) = $line =~ /^(.*) (.*)/) { $name = $value if 'name' eq $field; $hash{$name}{$field} = $value; } else { warn "Invalid line '$line'.\n"; } } print Dumper \%hash;
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2020-09-20 06:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (119 votes). Check out past polls.

    Notices?