If you are trying to separate the basename from the file extension, it would be better to check if your regex match succeded:
> cat 701529.pl #!/usr/bin/env perl use strict; use warnings; my $file = shift; print "file : $file\n"; my $fname; if ($file =~ m/(\w+)\..*/) { $fname = $1; } else { die "Bad filename\n"; } print "fname : $fname\n"; > > ./701529.pl ./myfile.txt file : ./myfile.txt fname : myfile >
Please also include your file contents data inside code tags (see Writeup Formatting Tips).
In reply to Re: RegExp eating my $1
by toolic
in thread RegExp eating my $1 - FIXED!
by thekestrel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |