use strict; # returns list of CD/DVD mountpoints or empty list sub scan_cddvd { my @drives = (); my $mtabfile = "/etc/mtab"; open my $mtfh, "<", $mtabfile or die "cannot open $mtabfile - $!"; while( <$mtfh> ){ my ($dev, $mountpoint, $fstype, $options) = split /\s+/; next unless $fstype =~ /udf|iso\d+/ && $options =~ /ro\b/; #ro: the /ro/-test above should skip CDRW too $mountpoint =~ s/\\(0\d+)/chr(oct($1))/eg; # resolve oct chars push @drives, $mountpoint; } close $mtfh; return @drives; } print "o <", join(">\no <", scan_cddvd), ">\n";