Use and Require
Both the Use and Require statements are used while importing modules.
A require statement imports functions only within their packages. The use statement imports functions with a global scope so that their functions and objects can be accessed directly.
Eg. Require module;
Var = module::method(); //method called with the module reference
Eg: use module;
Var = method(); //method can be called directly
-Use statements are interpreted and are executed during the parsing whereas the require statements are executed during run time thereby supporting dynamic selection of modules.
My and Local
A variable declared with the My statement is scoped within the current block. The variable and its value goes out of scope outside the block whereas a local statement is used to temporarily assign a value to the global variable inside the block. The variable used with local statement still has global accessibility but the value lasts only as long as the control is inside the block.
For and Foreach
The for statement has an initialization, condition check and increment expressions in its body and is used for general iterations performing operations involving a loop. The foreach statement is particularly used to iterate through arrays and runs for the length of the array.
Exec and System
Exec command is used to execute a system command directly which does not return to the calling script unless if the command specified does not exist and System command is used to run a subcommand as part of a Perl script.
i.e The exec command stops the execution of the current process and starts the execution of the new process and does not return back to the stopped process. But the system command, holds the execution of the current process, forks a new process and continues with the execution of the command specified and returns back to the process on hold to continue execution.