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
derobert shows you a correct way of mapping @input
to @output
.
I would, however, recommend using File::Basename:
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename;
my @input = qw( a.1.txt b.txt c.txt );
my @output = map { scalar fileparse($_, qr/\.[^.]*/) } @input ;
use Data::Dumper;
print Dumper \@output;
Output:
C:\Temp> h $VAR1 = [ 'a.1', 'b', 'c' ];