Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple split

Status
Not open for further replies.
Code:
use strict;
use warnings;

my @stuff;

while (<>) {
   chomp;
   push @stuff, split(/\s+/, $_);
}

print join("\n", @stuff);

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::PerlDesignPatterns)[/small]
 
The default split will do that (omitting leading null fields), so you could shorten that to:
Code:
while (<>) {
   chomp;
   push @stuff, split;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top