in reply to Regex negative lookahead

You're providing a lookahead without anything to match before it. A negative match like provided by NetWallah is quite useful when you're wanting to make a decision based on what doesn't match. A lookahead is for when you do want to match something, based in part on what is or isn't next to it, without matching what's in the lookahead.

As an example, let's say you did want to match the Perl files but not other files, but that you don't want to print the '.pl' part of the filename.

sub list_perl_files_without_extension { opendir my $dir, '.' or die "Could not open current directory"; while ( my $file = readdir $dir ) { print "$&\n" if $file =~ m/.*(?=\.pl)/; } closedir $dir; }