Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
It seems as the delimiters were deleted, but the print is a little tricky

First, you had the string:
my $line = "a whole lotta shakin >pattern here< goin on";

and you did
my @bits_and_pieces = split /></, $line;

What did it make?
This code "splits" the string, searching '><' as delimiter. Because of '><' is not matched in the string, in @bits_and_pieces you will have only one element, and it would be
'a whole lotta shakin >pattern here< goin on'
(all the string)

In the other hand, you did this
my $line = "a whole lotta shakin ><pattern here>< goin on"; my @bits_and_pieces = split /></, $line;

Then, perl searches '><' in the string and splits it into an array.
So @bits_and_pieces would be now
('a whole lotta shakin ','pattern here',' goin on')

If you print @bits_and_pieces with
print @bits_and_pieces;
is printed
'a whole lotta shakin pattern here goin on'
as if the delimiters '><' where removed from the array.

Hope this help

In reply to Re: Re: Re: Cropping the output of the pattern matcher by hopes
in thread Cropping the output of the pattern matcher by jerrygarciuh

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.