"php #!/usr/bin/perl $fileName = shift; $lines = shift; print "tailing file $fileName for $lines lines... "; open FH, $fileName or die "Could not open $fileName"; while ($...
Open file, read and print until number of required lines is reached. Memory is saved by not slurping the entire file into an array. "perl $fileName = shift; $lines = shift; print ...
Hi I want to write a simple soap client in perl. if we pass the interger value as a http request. 1. Take an integer or string as command line arguments. 2. Create a http request. 3. Get the response from http. 4. Store the response in xsd schema. please help me out how to write perl soap client.
What is grep used for in perl?
"grep" is a built function which extract all elements in ARRAY, matched by regex/pattern given as argument for grep and return the resultant elements in an array.perl syntax: &nbs...
What is the difference between die and exit in perl?
There is not same it must be difference . I am sure it must difference but same action perform.but returning a value difference may be like string variable what ever may be
1) die is used to throw an exception (catchable using eval).
exit is used to exit the process.
2) die will set the error code based on $! or $? if the exception is uncaught.
exit will set the error code based on its argument.
3) die outputs a message
exit does not.
Install perl module using cpan
How to install perl module using cpan. How to include the module in a program?
I think the best option will be : type following command on command prompt
cpan App::cpanminus then you can install any module using its name using following command
cpan Module::Apache
let me know if it doesn't work
perl Makefile.PL
nmake
nmake test
nmake install
# To check successive installation
perl -e "use Twig"
Create a perl script to store the information in excel
Hello,--------------------------------------id name address1 cristine new york 2 murray redmond3 kumar Sunnyvale --------------------------------------this is 'samples.Xlsx' file.'id' string in a1, 'name' in b1, 'address' in c1 column in excel file.Create...
You can construct one hash where the the emp id as key to the hash and rest of the elements as values in the structure of array ref. "perl #! use strict; use Spreadsheet::ParseExce...
Hello,------------------------------------------- id name address 1 cristine new york 2 murray redmond 3 kumar Sunnyvale-------------------------------------------this is 'sample.Xlsx' file. (can't attach the image.)'id' string in a1,...
Keep the student id as key to a hash and the rest of the elements are the array reference.
How do you you check the return code of a command in perl
Suppose you run a program/script in perl:system("./server ....");how will you check the return code?
Perl defines predefined variable $? which gives the return code of last command executed.
$r = system("command .. e.g. search");
print"r is $rn";
Here, if $r is 0, that means command has executed successfully.
Any other value means command has failed.
In the object-oriented style you create one or more CGI objects and then use object methods to create the various elements of the page. Each CGI object starts out with the list of named parameters tha...
In object oriented PERL, the arrow -> symbol is used for creating or accessing a particular object of a class. For eg. in Perl/Tk 1. use Tk; my $main_win = MainWindow->new(); Here we u...
$arr= [1, 2,2+1 ,3+1];
print "n arr[1]=|".$arr->[1]."|".$$arr[1]."|";
How to implement stack in perl?
#! /usr/bin/perl -w$str1="Pushpendra Singh";@str=split("", $str1);@stack_array=();foreach $i (@str){ print "nt Item being pushed is : $i"; push(@stack_a...
In perl stacks are easy to be implemented. Stacks which follows LIFO (Last In First Out) data structure can be handled in perl with 'POP' and 'PUSH' keywords. POP Example:my $strT...
When do you not use perl for a project?
@ joe: isnt this for uses of perl ?
The question is for not using perl for a project but the answer is for using perl.
How to substitute a particular string in a file containing millions of records?
perl -p -i -e "s/search_string/replace_string/g" SourceFileThe -p option ensures that $_ is assigned each line of each input file in turn and that the program is executed once for each input line.The ...
perl -pi -e "s/search_string/replace_string/g" SourceFile
1. system("rm -rf","directorypath");2. A perl script can be created that'll make use of unlink , opendir,readdir,rmdir functions.#!/usr/bin/perlopendir(FD,"/home/tmp"); ---------> open tmp directory ....
Package NewModule;use Exporter; # an application by ‘use’ operator.# This Exporter package has @ISA array to look for a specific method, this array keeps track of classes it is inheriting....
@ISA -> each package has its own @ISA array. this array keep track of classes it is inheriting.
ex:
package child;
@ISA=( parentclass);
@EXPORT this array stores the subroutins to be exported from a module.
@EXPORT_OK this array stores the subroutins to be exported only on request.
Print this array, sorted in reversed case-insensitive order...
You have unsorted array of strings, like:my @arr = qw(hello world show must go on);print this array, sorted in reversed case-insensitive order.
my @arr = qw(hello World Show must go on);#close print "@arr nreverse sorted: ", join(", ", reverse sort map {lc $_} @arr), "n"; #closer print "@arr nreverse sorted:...
@arr = qw(ajit satish AJIt amartya maku);
foreach my $ele (@arr)
{
push (@new_arr, lc($ele));
}
print "n new arr= @new_arr";
@rev_arr =reverse sort(@new_arr);
Rename datastage jobs through perl
Please provide me perl scriptwhich reads the data from xcel sheet and renames the dsx file.Process followed to rename is:make a list of old and new file names in xcel sheet.Compare the old file name in the xcel sheet with dsx name.If both are equal then assign the new name to the dsx which is mentioned...
use Win32::OLE;use Win32::OLE::Enum;use Win32::OLE qw(in with);use Win32::OLE::Const 'Microsoft Excel';use Win32::OLE::Variant;use Spreadsheet::ParseExcel;use Spreadsheet::WriteExcel;use Sprea...
How to find out whether reference is pointing to a scalAR, array or hash?
You can use ref function.
With 'ref' keyword we can find the data type of the variable.
What does this symbol mean '->'
It is a infix dereference operator like in C++.
Uses of "->" Operator:###################1) Reference the method of a module.use CGI;my $cgi = new CGI ();$cgi->header();2) In Perl it is an infix dereference operator. $arr = [ ...
chomp VARIABLE chomp( LIST ) chomp This safer version of "chop" removes any trailing string that corresponds to the current value of $/ (also known as $INPUT_RECORD_SEPARATOR in...
chomp removes all special characters from end of given string