home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

A.13 Chapter 14, Process Management

  1. Here's one way to do it:

    my ($src, $trg) = @ARGV;
    die "$src isn't a directory" unless -d $src;
    die "$trg isn't a directory" unless -d $trg;
    `xcopy /s /e $src $trg`;

    We check to make sure both arguments are really directories, then we invoke xcopy to do the dirty work. We could have also used:

    system("xcopy /s /e $src $trg");
  2. Here's one way to do it:

    @hosts = `net view`;
    foreach (@hosts) {
      next unless m#\\\\#;
      chop;
      s/^(\S+).*/$1/;
      push @sorted, $_;
    }
    print join("\n", sort @sorted);

    We run the command net view and capture the output as a list of lines. We then go through each line looking for hostnames (they start with \\), chop off newlines and comments, and add the matches to another list. We then sort the second list and print it.


Previous: A.12 Chapter 13, File and Directory Manipulation Learning Perl on Win32 Systems Next: A.14 Chapter 15, Other Data Transformation
A.12 Chapter 13, File and Directory Manipulation Book Index A.14 Chapter 15, Other Data Transformation











??????????????@Mail.ru