adir
adir

Reputation: 1287

perl - how to take part of a line

I want to take a part of line using perl example for 2 lines:

/Tests/CpuStrmRd_MemAccSmB_WrBgDis_RdBgDis_WrAlcDis__Ddr64_2to1_DlbEn_PrfEn_1_StrmRd/
/Tests/puStrmWr_MemAccSmB_WrBgDis_RdBgRnd_WrAlcEN__Ddr64_2to1_DlbEn_PrfEn_81_StrmWr/

and the part of the line (for each line) I want to take is:

CpuStrmRd_MemAccSmB_WrBgDis_RdBgDis_WrAlcDis

(which is between /Tests/ and __Ddr )

Thanks for any help

Upvotes: 0

Views: 120

Answers (1)

jjmerelo
jjmerelo

Reputation: 23537

If it's between /Tests/ and __Ddr, it sounds like

my ($match) = ($line =~ m{/Tests/(.+?)__Ddr});

That will do literally what you are asking for; . matches any character.

Upvotes: 1

Related Questions