- Perl Basics
- Perl Home
- Perl Basic Syntax
- Perl Data Types
- Perl Variables
- Perl Scalars
- Perl Arrays
- Perl Hashes
- Perl If-Else
- Perl Loops
- Perl Operators
- Perl References
- Perl Subroutines
- Perl Formats
- Perl Date & Time
- Perl File I/O
- Perl Advanced
- Perl Directory
- Perl Regular Expressions
- Perl Special Variables
- Perl Socket Programming
- Perl Send E-mail
- Perl Object Oriented
- Perl Error Handling
- Perl CGI Programming
- Perl Database
- Perl Packages & Modules
- Perl Process Management
- Perl Test
- Perl Online Test
- Give Online Test
- All Test List
Perl Process Management
You are free to use various ways to create new process in perl. Here are the following points to keep in mind
- Every process is created using any of the mentioned methods, maintains its own virtual environment with-in %ENV special variable
- You can use $$, special variable, to get the current process ID
- You can also use $PROCESS_ID, special variable to get current process ID
- All the open handles are dup()-ed in the child-processes, so that closing any handles in one process doesn't affect others
- The function named exit() always exits just the child process which executes this function and the main process as a whole will not exit unless all the running child-processes have been exited
Perl Process Management Example
Let's take a look at the following example:
#!/usr/bin/perl @files = `ls -l`; foreach $file (@files){ print $file; } 1;
When the above perl program is executed, it lists all the files and directories present inside the current directory:
drwxr-xr-x 3 root root 4096 Sep 14 06:46 9-14 drwxr-xr-x 4 root root 4096 Sep 13 07:54 android -rw-r--r-- 1 root root 574 Sep 17 15:16 index.htm drwxr-xr-x 3 544 401 4096 Jul 6 16:49 MIME-Lite-3.01 -rw-r--r-- 1 root root 71 Sep 17 15:16 test.pl drwx------ 2 root root 4096 Sep 17 15:11 vAtrJdy
« Previous Tutorial CodesCracker Home »