Willam Torrez Corea: > Can I mix bash with perl in a program? Yes, both ways; $ perl -e 'print "Hello World!\n"' Hello World! $ cat ls.pl #!/usr/bin/perl -w use strict;
print `ls @ARGV` $ ./aa -r -t -l /usr | tail -4 drwxr-xr-x 35 root root 8192 Apr 20 21:24 lib drwxr-xr-x 2 root root 118784 Apr 25 19:52 bin drwxr-xr-x 548 root root 40960 Apr 25 19:52 include drwxr-xr-x 197 root root 172032 Apr 25 19:52 lib64 $ > I want to create a program in Perl to execute the bash command. > > *Basic Bash commands (echo, read, etc.)* echo -> print() read -> read() or readline() etc. -> get a perl book or read an online tutorial > - cd : Change the directory to a different location. You can do that but that only affects the current shell, so `cd /usr/local`; won't help you, use chdir() in perl instead. For the same reason this doen't work either: $ pwd /Net $ perl -e 'chdir("/usr/local");' $ pwd /Net $ > - ls : List the contents of the current directory. either: @list = `ls -1 /usr/local`; $list = `ls -1 /usr/local`; you can also use opendir(); readdir(), there is an example in man perlfunc under readdir. > - mkdir : Create a new directory. man perlfunc is your friend. > - touch : Create a new file. `touch zzz` see example in man perlfunc under utime > - rm : Remove a file or directory. As in c, use unlink(), man perlfunc > - cp : Copy a file or directory. `cp xxxx`; > - mv : Move or rename a file or directory. As in c, use rename(), man perlfunc > The program must update the package manager Ask on one of the debian mailing lists. Regards, /Karl Hammar -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/