in reply to arrays and strings
#!/usr/bin/perl use strict; use warnings; my @numbers = (1, 2, 2, 3, 3); my @strings = qw(hello green grass rainbow pretty); my @check = (1, 2, 3, 4); my @con; for (0 .. $#numbers) { push @{$con[$numbers[$_]]}, $strings[$_]; } for (@check) { if ($con[$_]) { print @{$con[$_]}; } else { print 'xxxxxxxxx'; } print "\n"; } __DATA__ hello greengrass rainbowpretty xxxxxxxxx
|
|---|