Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: Re: Cropping the output of the pattern matcher

by hopes (Friar)
on Sep 24, 2001 at 05:14 UTC ( [id://114230]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Cropping the output of the pattern matcher
in thread Cropping the output of the pattern matcher

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
Hopes

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://114230]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2025-03-24 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (65 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.