The (?! regex) is called a zero-width negative look-ahead assertion
which in this case says if the first character of the search is NOT a / then
you have a relative directory name. With this type of test, there is no
association of a hit to $1, $2, etc.

        You could just as easily done:
          if ( ! /^\// ) {
             which says if the search variable(in this case $_) does not
start with a / then you have a relative path name.

        I am assuming since it does work it is a Unix type environment vs
Windows.

Wags ;)

-----Original Message-----
From: etienne vermaas [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 21, 2002 09:27
To: [EMAIL PROTECTED]
Subject: relative dir match question


Hi all,

A check to see if a pathname is "relative" or complete in some of the shell 
scripts works (seems to work)
but I am not clear about the ?! part in the expresion, and also it seems 
that they do go together, because leaving either the ? or the ! out screw up

the results.
I'll appreciat your help in getting to understand this

thanks.

$ perl -n -e '
chomp;
if (m/^(?!\/)/) {
  print;
  print " is a relative dir ..\n"
} else {
  print;
  print " is a full dir\n"
} ' < in.txt
/tmp is a full dir
.../example is a relative dir ..
..../dir/example is a relative dir ..
$
$
$ cat in.txt
/tmp
.../example
..../dir/example
$
$




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to