this is really trivial. try it and then try it with the possible substitutions, which by my reading of
split should all be the same
(If EXPR is omitted, splits the $_ string. If PATTERN is also omitted, splits on whitespace).
Update: keyword
also whoops! (hence i should never have thought "split $_"
#!/usr/bin/perl
use warnings;
use strict;
while (<DATA>) {
my @line = split / /; #nb. "split $_" returns many uninti
+alized values
my $bit = shift @line; # "split" returns the a variatio
+n of that,
print "|$bit| @line"; # but with no newlines
} # "split / /,$_" predictably ret
+urns the same
# as "split / /"
__DATA__
holli: s/drowning/draining/
moritz steps out of the way, and watches a nice hole in the wall
moritz: time for a counter attack...
moritz takes his +5 Samurai Sword of Perl Monk Decapitation...
moritz: ... and throws a 1. Damned, I missded
holli writes a Perl 6 module to automate aiming
moritz: s/missded/missed/
holli laughs at [moritz], then slips over a globular dice
moritz throws a discontinued perl 6 compiler at [holli]
holli smiles as he sees hist watcher elemental tearing the compiler ap
+art
moritz: why do I have to lose all the time?
holli: <c>try{ harder(); }</c> ;-)
Thanks
Kyle for noticing my stupidity
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.