#!/usr/bin/env perl # This script should check what elements are common between two lists use strict; use warnings; # Lists of random numbers my @input=map {int(rand($_))} (1..100); my @valuesToMatch=map {int(rand($_))} (1..100); print "-----list 1 is:-----\n@input\n-----and list 2 is:-----\n@valuesToMatch\n"; # Match the common values my $matchString = sprintf "\\b%s", join("\\b\|\\b",@valuesToMatch); my @result = join(" ", @input) =~ /$matchString/g; # Return result print "---------------The matching numbers are:---------------\n@result\n" ;