in reply to Re^2: Convert a string into a hash
in thread Convert a string into a hash

Ooops, mess up and double post...sorry.... This is a straight-forward implementation.
Post again if I didn't get it right....
#!/usr/bin/perl -w use strict; my $tokens = "32,15,4,72,13,28,14"; my @tokens = split (/,/, $tokens); my $list = "4,13,15"; my @list = split (/,/,$list); my %list = map {$_ => 1}@list; my @ordered_nums = grep{$list{$_}}@tokens; print "@ordered_nums\n"; __END__ PRINTS: 15 4 13
Update: I would perhaps replace "list" with "list_order". Matter of choice.