#!/tool/bin/perl -w use strict; my $test_filename = "/user1/lazy_match_test.txt"; my $match = ""; open(TEST_FILE, $test_filename) || die("ERROR: unable to open $test_filename for read, exiting...\n"); while () { if ($_ =~ /\/(.+?)$/) { $match = $1; } } close(TEST_FILE); printf("matched $match\n"); #### /foo/bar/baz/bat #### if ($_ =~ /\/(.+)?$/)