on Wed, 04 Sep 2002 06:23:20 GMT, [EMAIL PROTECTED] (Anidil
Rajendran) wrote:
> expand the filename manually with substitution
>
> $filename =~ s{ ^ ~ ( [^/]* ) }
> { $1
> ? (getpwnam($1)) [7]
> : ( $ENV{HOME} || $ENV{LOGDIR}
> || (getpwuid($>)) [7]
> )
> }ex;
>
> The auther says the following can me matched
> ~user
> ~user/blah
> ~
> ~/blah
>
> Could someone make me clear how these can be matched by the
> pattern inside the parenthesis which is ( [^/]*)
The "real" pattern, after removing the whitespace allowed by using
the /x modifier is:
/^~([^/]*)/
Which means: match '~' at the beginning of the string, then match and
store in $1 any number (including none) of characters up to but not
including the first '/'.
You will have:
filename $1
~user user
~user/blah user
~ (empty string)
~/blah (empty string)
--
felix
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]