in reply to Re^2: how to extract multiple pattern into array
in thread how to extract multiple pattern into array

Oops, thanks :-)

  • Comment on Re^3: how to extract multiple pattern into array

Replies are listed 'Best First'.
Re^4: how to extract multiple pattern into array
by herman4016 (Acolyte) on Feb 04, 2015 at 07:25 UTC
    I had finished my code , thank you for your help!
    #!/usr/bin/perl use 5.010; use strict; use warnings; my $reS = qr{\..*?\s*?\(\s*?([0-9a-zA-Z_]*?)\s*?\)}s; my $reM = qr{\..*?\s*?\(\s*?\{\s*?(.*?)\s*?\}\s*?\)}s; open my $fh, "analog_atop_inst.v" or die $!; my @fields=(); my @matchM=(); my @matchS=(); my @allfield=(); my $entire_dataS = ''; my $entire_dataM = ''; while (<$fh>) { chomp; $entire_dataS .= $_; $entire_dataM .= $_; } #print $entire_data; while (1) { if ($entire_dataS =~ /$reS/){ push @matchS, $1; $entire_dataS = $';} else { last;} } while (1) { if ($entire_dataM =~ /$reM/){ push @matchM, $1; $entire_dataM = $';} else { last;} } #say "@@@@@@@@@@@@ MatchS @@@@@@@@@@@@@@@@@"; foreach my $fieldS (@matchS){ push @allfield, $fieldS ; } #say "############ MatchM #################"; foreach my $fieldM (@matchM){ my @fieldsplit = split / ,\s+/, $fieldM; foreach my $fieldMs (@fieldsplit){ push @allfield, $fieldMs ; } } foreach my $fieldT (@allfield){ say $fieldT; }