in reply to getting next word or number after another
When you keep reformulating the problem without showing edits and starting new threads, this just confuses the issue. It makes it very tough for a guy like me who just stumbles across this thing to make heads or tails of it.
Update: When you say things like "now my problem i cant get the next word or number after john", we've lost all context about what the overall objective is because one would have to read another thread(s) to find out what the end result is that you desire. So, the responses become focused upon answering your current question which is not really what you need to know or even pertinent to what asked for in the first place!use strict; use warnings; my $string = " info John 100 - 2000 Kent"; (my @words) = $string =~ /([A-Za-z]+)/g; (my @nums) = $string =~ /(\d+)/g; print "data:",shift @words," "; #the "info" word print "uneven stack error!" if (@words != @nums); while (@words) { print "",shift @words,":",shift @nums," "; } print "\n"; # prints: "data:info John:100 Kent:2000 " <= what you said you wanted
|
|---|