in reply to Check If 2 Arrays Match
If you just use @two in the regex match, it will expand to the entire array, ie, you are asking if the filename matches the entire list of filenames, not one of them. Eg.#!/usr/bin/perl -w use strict; my @ray = qw(one two three); my @two = qw(two next four); foreach my $x (@ray) { foreach my $y (@two) { print $x if ($x eq $y); } }
which no file will have that name. In this situation methinks it matters not so much, but "eq" will only match exactly, whereas =~ will match if the pattern is a substring.if ($ID=~ m/one.txt two.txt three.txt/)
|
|---|