in reply to Matching a string that you do not have any really good information about

Just using the first set of paths, here's a solution:

use strict; my @types = ( qr!^/[hH]ome/([^/]+)!, qr!^/Users/people/([^/]+)!, qr!^/export/home/([^/]+)! ); while (my $path = <DATA>) { my ($user) = map { $path =~ $_ ? $1 : () } @types; print $user, $/; } __DATA__ /home/user1/public_html/cgi-bin/dir /Users/people/user2/html/cgi-bin/directory /Home/user3/public/cgi-bin/place /export/home/user4/www/cgi-bin/dir
  • Comment on Re: Matching a string that you do not have any really good information about
  • Download Code