Please type out and post No pictures, please. Write a Perl script to calculate t
ID: 3749127 • Letter: P
Question
Please type out and post No pictures, please. Write a Perl script to calculate the following.
5. Write a script to check all command arguments. Display the argument one by one (use a for loop). If there is no argument provided, remind users about the mistake. 6. Create x empty files in a given directory (x is a number), following a naming format like this: myfile1, myfile2, etc. Ask the user to enter the first part file name and the number of files he/she wants to create. Hint: you may use the "touch command to quickly create empty files.Explanation / Answer
5) Script-1
$num_args = $#ARGV + 1;
if($num_args==0)
{
print "No command line arguments found! "
}
else{
for (my $i=0; $i <= $num_args; $i++) {
print "$ARGV[$i] ";
}
}
6) Script-2
print "Please enter part file name:";
$file_name = <>;
print "Please enter number of files:";
$number = <>;
for( my $i=1;$i<=$number;$i++)
{
my $file = $file_name . $i;
open my $FH, ">", $file;
close $FH;
}
#All the best