in reply to Regular expression

Matching what you show as literal text should do the job. You probably want to anchor the beginnning to the start of the string. A literal match like this can be done with substr and eq, too.

my $string = '/sbc/dasds/sdf/dsd/modem'; my $regex = qr!^${string}!; $_ = '/sbc/dasds/sdf/dsd/modem_50'; if (m/$regex/) { print; print "\nRegex works\n"; } if ($string eq substr $_, 0, length $string) { print; print "\nString equality works\n"; }
If you're doing this to comb modems out of a bunch of file paths, there is also glob:
my @modems = glob '/sbc/dasds/sdf/dsd/modem*';

After Compline,
Zaxo