Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hey zee3b, I figured I'd respond to your PM here so I'd have more room.
Hey, thanks a lot for the help. That really worked and was exactly what I was looking for. When you get a few mins, can you please explain how the code works for my understanding. Thanks!
# Read through file/data one line at a time. while (<DATA>) { # Remove newline from end of line (actually not necessary for your + input). chomp; # If a line ends with '{', use a regular expression (REGEX) to cap +ture # the relevant portion by having that portion surrounded by parent +heses. # Push the captured string (contained within the variable '$1', si +nce it # is the first captured string) onto the end of the array '@curren +t command'. # This REGEX matches: # the beginning of the line: ^ # 0 or more spaces: \s* # 1 or more of anything (captured because it is in parentheses +): (.+) # 1 space followed by 1 {: \s{ # the end of the line: $ push @current_command, $1 if /^\s*(.+)\s{$/; # If a line ends with ';', use a REGEX to capture the relevant por +tion, # then print out the contents of the array followed by the string +you # just captured and assigned to '$last_term'. if (/^\s*(.+);$/) { my $last_term = $1; say "set @current_command $last_term"; } # If a line ends with '}', that means we are moving up a level, so + you # remove the last element of the array '@current_command'. pop @current_command if /}$/; }

In reply to Re^3: Perl Sorting Help by frozenwithjoy
in thread needed help by zee3b

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, 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, 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.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (2)
    As of 2018-09-23 12:28 GMT
    Find Nodes?
      Voting Booth?
      Eventually, "covfefe" will come to mean:

      Results (191 votes). Check out past polls.

      • (Sep 10, 2018 at 22:53 UTC) Welcome new users!