Link to home
Start Free TrialLog in
Avatar of angieteh
angieteh

asked on

greping data

given some text ...

From me Wed Jun 23 14:29:10 1999
X-Sender: me@mail.mynet
X-Mailer: Windows Eudora Pro Version 3.0 (32)
Date: Wed, 23 Jun 1999 14:30:32 +0800
To: me@mynet.net
From: me
Subject: multipart message test
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="=====================_930090632==_"

How would be extract the boundry string and place it in $boundary.

thanks
Avatar of Kim Ryan
Kim Ryan
Flag of Australia image

Assuming you are OK with getting the line contents into a variable:

$line =~
  /^Content\-Type: multipart\/mixed;boundary="(.*)"$/;
$boundary = $1;
Avatar of angieteh
angieteh

ASKER

can you please explain what that does ?
i'm sure it works ...
but can you please explain what it does ... and resubmit answer to get the points.

thanks
$line =~
  /^Content\-Type: multipart\/mixed;boundary="(.*)"$/;

$boundary = $1;

The first line looks for the line "Content... The "(.*)"$ says take everything after the first " until the " at the end of the line and store it in $1 (a reserved variable)

The next line stores $1 into the $boundary variable.
ASKER CERTIFIED SOLUTION
Avatar of Kim Ryan
Kim Ryan
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
'-' does not have a special meaning inside regexps
'/' only has a special meaning inside strings quoted with /