Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What are the difference between Interactive and Drill Down
Reports?

Answer Posted / varun

Perl - Test

1.Write a perl script to display command line arguments
separated by new line
foreach $arg (@ARGV) {
print $arg . "\n";
}
2.Write a perl script to Store and retrieve records in a
plain text file
store
#Copying contents of one file into another file
# If another files exists, then its overwritten if not
exists then created

unless (open(INFILE, "file1.txt")) {
die ("cannot open input file file1\n");
}
unless (open(OUTFILE, ">outfile.txt")) {
die ("cannot open output file outfile\n");
}
$line = <INFILE>;
while ($line ne "") {
print OUTFILE ($line);
$line = <INFILE>;
}

retrieve

if (open(MYFILE, "file1.txt")) {
$line = <MYFILE>;
while ($line ne "") {
print ($line);
$line = <MYFILE>;
}
}

3.Illustrate the passing by reference and passing by value
with separate examples each.
$value = 10;
print " passing by value: $value \n";


$pointer = \$value;
print " Pointer Address is $pointer of value $value \n";
print " passing by reference: $$pointer \n";

4.Show use of typeglob with a example


sub generate_greeting {
my ($greeting) = @_;
sub { print "$greeting world\n";}
}
$rs = generate_greeting("hello");

&$rs();

# Instead of invoking it as &$rs(), give it your own name.
*greet = $rs;
greet(); # Equivalent to calling &$rs(). Prints "hello
world\n"

#Typeglobs are used to create alises of symbols.
# They are easy to use, they can be alised to ordinary
references. See above code

5.Describe the use of bless() in constructors
bless function is same like a fork function,that si it
creats a copy of the instance of the class and returns
the reference of that obj. its mandatory for a constructor
to have a bless function.

package Animal;

sub new{
my $class = shift;
my $self = {};
$self->{NAME} = undef;
bless($self,$class);
return $self;
}

sub eat{
return "Eats animal food\n";
}

6.Show an example of reusable object in Perl with a short script
use person;
use Employee;

my $empl = Employee->new();
$empl->name("Jason Bourn");
$empl->age(25);
$empl->salary(40);
printf "%s is age %d. Salary %d\n", $empl->name,
$empl->age,$empl->salary;

7.Write a small object oriented application to read and
write text files.


8.Write a script to store web page from a given Internet
location.

# Get and print out the headers and body of the CPAN homepage
use HTTP::Lite;
$http = new HTTP::Lite;
$req = $http->request("http://www.cpan.org/")
or die "Unable to get document: $!";
die "Request failed ($req): ".$http->status_message()
if $req ne "200";
@headers = $http->headers_array();
$body = $http->body();
foreach $header (@headers)
{
print OUTFILE("$header$CRLF");
print OUTFILE("$CRLF");
print OUTFILE("$body$CRLF");
}

# POST a query to the dejanews USENET search engine
use HTTP::Lite;
$http = new HTTP::Lite;
%vars = (
"QRY" => "perl",
"ST" => "MS",
"svcclass" => "dncurrent",
"DBS" => "2"
);
$http->prepare_post(\%vars);
$req = $http->request("http://www.deja.com/dnquery.xp")
or die "Unable to get document: $!";
print "req: $req\n";
print $http->body();

9.Illustrate a simple http auth with a working example.

10.Write a script to read and show a XML file with nodes.
#!/usr/bin/perl

# use module
use XML::Simple;

# create object
$xml = new XML::Simple;

# read XML file
$data = $xml->XMLin("data.xml");

# access XML data
print "$data->{name} is $data->{age} years old and works in
the $data->{department} section\n";

11.Describe use of ^ and $ pattern matching charectors.
beginning of string ^
end of string $


^abc
abc at the beginning of the string
abc$
abc at the end of the string
12.Write a script to print a hash with keys
#!/usr/bin/perl

print "Hash \n\n";

# DEFINE A HASH
%coins = ("Quarter", 25, "Dime", 10, "Nickel", 5);

# PRINT THE HASH
print %coins , "\n"; #See how it prints

13.Write a script to add user entered values to a array
#!/usr/bin/perl
1.$total = 0;
2.
3.@numbers=&getnumbers;
4.foreach $number (@numbers) {
5. $total += $number;
6.}
7.print ("the total is $total\n");
8.
9.sub getnumbers {
10. $line = <STDIN>;
11. $line =~ s/^\s+|\s*\n$//g;
12. @numbers = split(/\s+/, $line);
13.}
14.write a script to make sum of a numeric array elements
@array =(1,2,3,4,5);

$total=0;
foreach $array(@array){
$total+=$array;
}

print $total;
15.Describe and write foreach loop with example.

foreach $arg (@ARGV) {
print $arg . "\n";
}

Is This Answer Correct ?    1 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can I execute user exits? If yes, how?

1036


How do you display a data in a detail list?

998


What is the difference between table and template?

1028


How do you control printer functions from sapscript?

1316


What are authorization objects and what statement is used to perform an authorization check in an abap program?

1007


Suppose there is check box along with the rows. The requirement is, select the require check boxes and press a used defined button to save all these checked row data to another table. How can you do it?

2067


What are the basic components of dialog program?

1246


What is logical database? : abap hr

1045


What are the parameter types for a method?

1490


What is runtime analysis?

1148


Explain how do you move on to the next screen in interactive reporting?

1028


I have 3 transactions,where the output of one transaction is input of another and output of 2nd transaction is input of 3rd transaction.i have one flat file with all data for the 3 transaction.if the 3rd transaction failed can we rollback the remaining 2 transactions or not.Is this possible in BDC,How/

2318


What are the differences between table and structure in data dictionary?

1104


What is at exit-command:?

1002


How will you define org structure in MM?

1412