Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I believe this is more simple than all of your examples but everybody has their idea of simple.
#!/usr/bin/perl -w chomp($msisdn = <STDIN>); $/ = ""; # read paragraphs @lines = split(/\n/, $_); if (@lines == 1) # A Heading { $lastHeading = $lines[0] next; } if ($lines[1] =~ "mSTerminating") { print("$lines[4]\n") if($lines[4] =~ "recordSequenceNumber"); } }
I know "lastHeading" isn't defined yet along with "msisdn" but this worked! It delimits what is printed by the subheading. I can also add in more delmiters because for the phone number line even though that one moves around I'll just tell it to match the phone number delimited by the subheading off of $_ so I don't have to worry.

So if the script finds subheading "mSTerminating" and if it finds a match for "recordSequenceNumber" then it prints line 4. See I found out in my datablocks that "recordSequenceNumber" is in lines4, 5, or 8 so I just say
print line4 if "recordSequenceNumber" is matched on line4
print line8 if "recordSequenceNumber" is matched on line8

Of course this is in it's very prelim form I just wanted to show ya that I found an easy way.

The Brassmon_k

In reply to Re: Keep It Simple, S***** by brassmon_k
in thread Non-fixed data in record by brassmon_k

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-25 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found