in reply to find CD drive letter

This is pretty much nonsense.

For the perl part of the question, how do you know the computer on which your program is being installed will even have Perl?

However, assuming it does, you can "put the result in a variable. for example system(dir);" with a simple assignment, like this:

perl -e "my $dir=system(dir);print $dir

update2: Wrong! See BrowserUK's below for clarification.

But that's not going to get you the drive letter of the CD; it's going to get you the directory of the Drive:\path\from\which\you\run\the\script.

So, it makes more sense (IMO), to use autorun and/or direct the user installing the program to provide the CD's drive letter.

Update: Above lists contents (-d && -D) on W2k (plus the errno, as jwkrahn points out); on *nix, perl -e 'my $dir=system(ls);print $dir;' does likewise. Add "\n" at the end if you want the errno on a line above the next prompt.

Again, WRONG; as in update2. The only thing assigned to $dir is the errno, "0" in these cases; the print $dir does NOT do what I asserted.

Replies are listed 'Best First'.
Re^2: find CD drive letter
by jwkrahn (Abbot) on Jan 03, 2010 at 04:15 UTC
    my $dir=system(dir);

    system returns an error number, not a text string from the command run.

      As stated update: following is accurate as to output, but NOT as to the process. See jwkrahn's (above) and BrowserUK's (below).
      on w2k w/ perl, v5.8.8 built for MSWin32-x86-multi-thread (with 33 registered patches) ... Binary build 819 [267479] provided by ActiveState....

      C:\Documents and Settings\ww>perl -e "my $dir=system(dir);print $dir Volume in drive C has no label. Volume Serial Number is 704A-B003 Directory of C:\Documents and Settings\ww 01/03/2010 06:29a <DIR> . 01/03/2010 06:29a <DIR> .. 07/16/2007 06:03a 107 .bps 12/29/2009 07:46p <DIR> .gimp-2.6 08/13/2007 11:40a <DIR> .housecall6.6 12/23/2009 10:55a 1,480 .recently-used.xbel 11/14/2009 10:44a <DIR> .thumbnails ... #more files and dirs 02/16/2008 11:37a <DIR> Start Menu 06/29/2007 10:15p 145 t.net-1.bps 06/29/2007 10:13p 145 t.net.bps 20 File(s) 8,026,977 bytes 10 Dir(s) 6,957,117,440 bytes free 0 C:\Documents and Settings\ww>

        The only bit of that output that came from the perl print statement was the final 0. If you doubt it, omit the print and re-run it.