in reply to Need help with loops and 3 tables

This is not a Perl problem! Use the abilities of your database (a join or subselect) to find out the usernames you want. That's what databases are actually good at, after all. :)

Rest of the problem will become a piece of cake then. Problem solved.

P.S. read about the unlink-function what jwkrahn said. No need to shell out to "rm".


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: Need help with loops and 3 tables
by jwkrahn (Abbot) on Feb 05, 2008 at 23:40 UTC

    Actually since the OP wants to remove directories the File::Path::rmtree function would probably be better then unlink.

Re^2: Need help with loops and 3 tables
by Skeeve (Parson) on Feb 05, 2008 at 23:37 UTC
    No! Don't use unlink! perldoc -f unlink will tell you why:
    unlink LIST
    unlink Deletes a list of files. Returns the number of files success-
    fully deleted.
    $cnt = unlink 'a', 'b', 'c'; unlink @goners; unlink <*.bak>;
    Note: "unlink" will not delete directories unless you are supe-
    ruser and the -U flag is supplied to Perl. Even if these con-
    ditions are met, be warned that unlinking a directory can
    inflict damage on your filesystem
    . Use "rmdir" instead.

    If LIST is omitted, uses $_.

    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

      So long as you're not running with root permissions the underlying unlink(2) should fail with EPERM (per POSIX) if you try and unlink a directory.

      $ perl -le 'mkdir "OHNOEZ"; unlink "OHNOEZ" or die "unlink: $!\n";rmdi +r "OHNOEZ"' unlink: Operation not permitted

      Your system's rm command's going to be making the same underlying unlink(2) call for the same arguments for that matter; so long as you're not running as root it's a rather spurious thing to worry about.

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.