I am trying to access this only parts of user input. Eg. if user inputs a file name like /file/path/test_324_3422.jpg
I want to get only test, 324 and 3422
I have been attempting this, but it does not work:
#!/usr/bin/perl
if(@ARGV != 1){
print "Error\n";
}
else{
my $input = $ARGV[0];
$input =~ /(.)_([\d]+)_([\d]+)/
print $1, "\n";
}
$1refers to your first capturing group, if you want to display the content of group 2 and 3, use$2and$3. Change your first group description to([^\/_]+)