Hi, I am trying to scrape some info from a large text file that has records separated by double carriage returns.

I'm basically trying to capture: 1. The ticket number: (for example, ACCOUNT-09782)
2. The CreatedDate field and value mentioned in the Remedy Case Data section (not the Remedy Account data section that appears earlier in the record).
3. The ClosedDate field and value mentioned in the Remedy Case Data section

I was thinking something along the lines of :

$/ = "\n\n"; while (<DATA>) { chomp; my $line = $_; $line =~/(ACCOUNT-\d{5}).*Remedy Case data.*(ClosedDate.*)\\.*(Created +Date.*)\\/; my $account = $1; my $closed = $2; my $created = $3; . . . }
Any tips much appreciated!
__DATA__ ACCOUNT-09782 comment \ Remedy Account data: \ IsDeleted = No\ Name = Singtel PMC\ Type = Existing Account\ Industry = Network Operator\ OwnerId = Foo Foobar (foo@whatever.com)\ CreatedDate = 2007-02-21 23:59:56\ \ Remedy Account Contact Role data: \ None found\ \ Remedy Case data: \ CaseNumber = 00013383\ ContactId = Sharon Tesla\ AccountId = Blah blah\ Type = Problem\ Status = Closed\ Reason = User create/change/delete from system\ IsVisibleInSelfService = 1\ Subject = Setup Login Credentials / Lando Franklin\ Priority = Medium\ Description = Please set up Lando Franklin with login credentials. Yo +u may mirror my profile. Her email address is 2326265@whatever.com. + Thank\ you!!!\ IsClosed = 1\ ClosedDate = 2007-10-26 16:31:53\ Actual Work Time = 1.00\ CreatedDate = 2007-10-23 21:10:10\ CreatedById = 00500000006onM1AAI\ Environment__c = Production\

In reply to using regex with records by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.