Programs Write The Output Here Observation

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1

1. Key in the following programs and fill in the table.



Programs Write the output here Observation
Program 1
#!/usr/bin/env perl
use warnings;
use strict;
my $firstname = "hari\n";
my $lastname = "prasad\n";
print "my first name is $firstname $lastname\n";
Program 2
#!/usr/bin/env perl
use warnings;
use strict;
my $firstname = "Hariprasad\n";
my $lastname = "Maramraj\n";
chomp($firstname);
print "my first name is $firstname $lastname\n";


Programs Write the output here Observation
Program 1
#!/usr/bin/env perl
use warnings;
use strict;
my $firstname = "Hariprasad";
print my first name is $firstname\n;
Program 2
#!/usr/bin/env perl
use warnings;
use strict;
my $firstname = "hariprasad";
print "my first name is $firstname\n";



2

Programs Write the output here Observation
Program 1
#!/usr/bin/env perl
use warnings;
use strict;
my $firstname = "Hariprasad";
my $lastname = "Maramraj";
my $profession = teaching;
print "my name is $firstname $lastname\n";
Program 2
#!/usr/bin/env perl
use warnings;
use strict;
my ($firstname,$lastname, $profession) = qw(Hariprasad
Maramraj teaching);
print "my name is $firstname. $lastname \n";




Programs Write the output here Observation
Program 1
#!/usr/bin/env perl
use warnings;
use strict;
my $fullname = 'hari' 'prasad';
print $fullname;
Program 2
#!/usr/bin/env perl
use warnings;
use strict;
my $fullname = 'hari'.'prasad';
print $fullname;



3

Question
Try using a full stop (.) between two variables and see if it concatenates the values.

Programs Write the output here Observation
Program 1
#!/usr/bin/env perl
use warnings;
use strict;
my $nameh = "Hariprasad" x 10;
print $nameh;

Program 2
#!/usr/bin/env perl
use warnings;
use strict;
my $chunk = substr('the rain in Hyderabad', 9, 2);
print "chunk is '$chunk'";

Program 3
#!/usr/bin/env perl
use warnings;
use strict;
my $string = 'the rain in Hyderabad';
substr($string, 9, 2) = 'beyond';
print "string is '$string'";



2. Write a program to replace every 5
th
word with a **** in the following text.
The workshop aims to provide an in-depth technical foundation to the design and implementation of National Knowledge Network. In Particular, the
workshop will provide participants with the knowledge and resources required to analyze, plan, design, and implement NKN within their organizations
infrastructure.

You might also like