Home: Perl Programming Help: Beginner:
Extracting data between arrows



ianilkumar
Novice

Nov 5, 2012, 10:08 AM


Views: 3717
Extracting data between arrows

Hi,

I want to extract string between the arrow:

Encrypted data is --->&aes|04|0D5E11BFDD97D2769D9B0DBFBD1BBF7ECE3F3BDBD15406660D3AF848C4B39A9ED8<---

Is there any built-in function available?

Regards


Laurent_R
Veteran / Moderator

Nov 5, 2012, 10:39 AM


Views: 3716
Re: [ianilkumar] Extracting data between arrows

Does the data between the arrows always have the same length? If yes, use the substr function.

Else, you may probably want to use a regex, something like this:


Code
my $extracted_line =  $1 if $total_line =~ /^-{3}>(.*)<-{3}$/;


Or you could also use the index function to find the position of the "<" near the end and then use the substr function to extract the interesting data.