in reply to one line to check for common list values

#!/usr/bin/perl use strict; use warnings; # This script should check what elements are common between two lists # 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@values +ToMatch\n"; # Match the common values (three ways) my @result = "@input\n@valuesToMatch" =~ /\b(\d+)\b(?=.*\n.*\b\1\b)/g; print "---------------The matching numbers are:---------------\n@resul +t\n" ; @result = grep +{map { $_, 1 } @valuesToMatch}->{$_}, @input; print "---------------The matching numbers are:---------------\n@resul +t\n" ; @result = grep "@valuesToMatch" =~ /\b$_\b/, @input; print "---------------The matching numbers are:---------------\n@resul +t\n" ;