Suppose I have the following in a text file "fbb_test":
/foo/bar/baz
Now suppose I have the following script:
#!/tool/bin/perl -w
use strict;
my $file = "/tmp/fbb_test";
open(FILE, $file) || die("ERROR: Unable to open $file for read, exitin
+g...\n");
while (<FILE>)
{
chomp($_);
if ($_ =~ /\/(.+?)$/)
{
printf("captured $1\n");
}
}
close(FILE);
The script is returning "captured foo/bar/baz". Given that I specified the non-greedy operator (?), I would have expected the result to be "baz", as the non-greedy operator would have matched as few characters as possible between a forward slash and the end of the line. What am I missing here?