CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
split;

 



lord_hairball
stranger

Feb 21, 2002, 9:06 AM

Post #1 of 2 (238 views)
split; Can't Post

is there an easy way to split a line of data and it treat successive blanks as one blank?



example:



inputline<blank><blank>someinfo<blank>somemore<blank><blank><blank>somemore input



i would like to split this with the following results:

@elements[0] = inputline @elements[1] = someinfo @elements[2] = somemore, etc.

thanks in advance,



chris


fashimpaur
User / Moderator

Feb 21, 2002, 9:17 AM

Post #2 of 2 (237 views)
Re: [lord_hairball] split; [In reply to] Can't Post

sure something like:

[perl]

$input = "inputline someinfo somemore somemore input";
@elements = split(/\s+/, $input);

# $element[0] contains 'inputline'
# $element[1] contains 'someinfo'
# $element[2] contains 'somemore'
# $element[3] contains 'somemore'
# $element[4] contains 'input'

[/perl]

HTH,
Dennis

$a="c323745335d3221214b364d545".
"a362532582521254c3640504c3729".
"2f493759214b3635554c3040606a0",
print unpack"u*",pack "h*",$a,"\n\n";

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives