The code I wrote is as below :
#!/usr/bin/perl my @input = ( \"a.txt\" , \"b.txt\" , \"c.txt\" ) ; my @output = map { $_ =~ s/\\..*$// } @input ; print @o
Your code sample is missing an s in the match operator. Other than that, it worked fine for me:
s
$, = "\n"; my @input = ( "a.txt" , "b.txt" , "c.txt" ); my @output = grep { $_ =~ s/\..*$// } @input; print @output;
Output is:
a b c