#!/usr/bin/perl system('touch /home/bin/plyty-db/newcd') and die "nie udał osię stworzyć pliku newcd"; system('mount /mnt/cdrom'); system('ls -R -l -1 -h -b -Q --indicator-style=none /mnt/cdrom > /home/bin/plyty-db/cd'); open(CD, '/home/bin/plyty-db/cd'); while () { if ($_ =~ /^"\//) { #kolejno każda linia z sprawdzana czy zaczyna # $predir = $_; # się od / czyli czy jest katalogiem # @fpredir = split ('"', $predir); $dir = $fpredir[1]; if ($dir =~ /^\//) { if ($dir =~ /\ /) {#test na okoliczność białych znaków# @dironebz = split (' ', $dir); $dir = join ('\ ', @dironebz); } if ($dir =~ /\(/) { # test na znak ( # @dironeonz = split (/\(/, $dir); $dir = join ('\(', @dironeonz); } if ($dirone =~ /\)/) { # test na znak ) # @dironeznz = split (/\)/, $dir); $dir = join ('\)', @dironeznz); } if ($dir =~ /\[/) { # test na znak [ # @dironeonkw = split (/\[/, $dir); $dir = join ('\[', @dironeonkw); } if ($dir =~ /\`/) { # test na znak ` # @dirapos = split (/\`/, $dir); $dir = join ('\`', @dirapos); } if ($dir =~ /'/) { # test na znak ' # @dircu = split (/'/, $dir); $dir = join ('\'', @dircu); } if ($dir =~ /&/) { # test na znak & # @dirand = split (/&/, $dir); $dir = join ('\&', @dirand); } if ($dir =~ /\|/) { # test na znak | # @dirpiol = split (/\|/, $dir); $dir = join ('\|', @dirpiol); } if ($dir =~ /\\/) { # test na znak \ # @dirbacks = split (/\\/, $dir); $dir = join ('\\', @dirbacks); } if ($dir =~ /!/) { # test na znak ! # @dirwyks = split (/!/, $dir); $dir = join ('\!', @dirwyks); } if ($dir =~ /\$/) { # test na znak $ # @dirdol = split (/\$/, $dir); $dir = join ('\$', @dirdol); } } } else { $file = $_; # to co nie zaczyna się od / if (($file =~ /^d/) or ($file =~ /^-/)) { #linie z plikami i katalogami# @lsFile = split (' ', $file, 9); #9elem to nazwa pliku z \ # @formfile = split ('"', $lsFile[8]); foreach $az (@formfile) { if ($az =~/\w/) { $dobazyd = $az; $endfile = $az; if ($endfile =~ /\ /) { #test na białe znaki# @filespace = split (/\ /, $endfile); $endfile = join ('\ ', @filespace); } if ($endfile =~ /\(/) { # test na znak ( # @fileonz = split (/\(/, $endfile); $endfile = join ('\(', @fileonz); } if ($endfile =~ /\)/) { # test na znak ) # @fileznz = split (/\)/, $endfile); $endfile = join ('\)', @fileznz); } if ($endfile =~ /\[/) { # test na znak [ # @fileonk = split (/\[/, $endfile); $endfile = join ('\[', @fileonk); } if ($endfile =~ /`/) { # test na znak ` # @fileapos = split (/`/, $endfile); $endfile = join ('\`', @fileapos); } if ($endfile =~ /'/) { # test na znak ' # @filecu = split (/'/, $endfile); $endfile = join ('\'', @filecu); } if ($endfile =~ /&/) { # test na znak & # @fileand = split (/&/, $endfile); $endfile = join ('\&', @fileand); } if ($endfile =~ /\|/) { # test na znak | # @filepiol = split (/\|/, $endfile); $endfile = join ('\|', @filepiol); } if ($endfile =~ /\\/) { # test na znak \ # @filebacks = split (/\\/, $endfile); $endfile = join ('\\', @filebacks); } if ($endfile =~ /!/) { # test na znak ! # @filewyks = split (/!/, $endfile); $endfile = join ('\!', @filewyks); } if ($endfile =~ /\$/) { # test na znak $ # @filewyks = split (/\$/, $endfile); $endfile = join ('\$', @filewyks); } $size = $lsFile[4]; $druk = "$dir/$endfile"; #$dir #print "druk $druk\n"; $typ = `file -b $druk`; if ($typ =~ /^directory/) {} else { print "$size $druk"; print "$typ\n"; $type = 'niewiem'; if ($typ =~ /mp3/i) {$type = 'audio';}# i// dopasowuje bez wzgłedu na wielkość liter elsif ($typ =~ /text/i) {$type = 'text'} elsif ($typ =~ /mpeg/i) {$type = 'video'} $dopliku = "$dir;;$type;;$size;;$dobazyd;;"; #nieudolny zabieg by zmieścic w jednej linii print "$dopliku\n"; open (NEWCD, ">>/home/bin/plyty-db/newcd"); print NEWCD "$dopliku\n"; } } } } } } &menu; sub menu { print "podaj nazwę płyty\n"; #wstawić wsprawdzanie $nazwa by nie zawierała metaznaków chomp ($nazwa = ); $jnazwa = "/home/bin/plyty-db/$nazwa"; if (-e $jnazwa) { print "płyta o tej nazwie istnieje zastąpić biezącą (by zastąpic wciśnij y)\n"; chomp ($codalej = ); if ($codalej =~ /^y/i) {system ("mv -f /home/bin/plyty-db/newcd /home/bin/plyty-db/$nazwa")} else { &menu} } else { print "$nazwa\n"; system ("mv /home/bin/plyty-db/newcd /home/bin/plyty-db/$nazwa") } system('eject'); system('rm -f /home/bin/plyty-db/newcd'); system('rm -f /home/bin/plyty-db/cd'); }