Skip to main content

What I did with Perl

Perl

What all features of Perl have I used?

\t Open
è Mutt/sendmail – for sending mail
è DBI
è When u declare a variable with @ at the start, it is an array.
Within an array, you can assign values like C/C++ -
Arr[0] = 1; Arr[1] = 2;
è You declare a variable when it starts with $
è Foreach – is for iteration
è For loop is exactly same as C++
è When you want to use a particular feature of perl, you say ‘use DBI’ and then you can use it.
è The function definition starts with ‘sub ’
è Each line in perl ends with a ‘;’
è If you do $MODE = ; the script will wait for user’s input, and once input is provided, that value will be assigned to MODE variable.
è Split function of perl strings is same as strtoken of strings.
è Foreach can be used as below –
foreach my $val (@temp_raw_value)
è Two strings can be concatenated as –
$String = $str1.$str2
è ‘Else if’ is like this – ‘elsif’
è and && are similar to C/C++
è If in a ‘if’ block, you want to do string comparison – following are the operators –
Eq, ne, gt, lt etc. Eg - if($DAY eq "Mon")
è

How about DB connectivity?
DBI is used.
Following different DBI methods are available to use –
use DBI;
my $db= DBI->connect("dbi:Oracle:dw", "igor", "igortom")
die( $DBI::errstr . "\n" );;
my $sql = “some query”
my $sth = $db->prepare($sql);

th->execute();
my $RESULT;
$sth->bind_columns(undef, \$RESULT);
$sth->fetch();
$sth->finish();
$db->disconnect();
return $RESULT;

What goals I achieved using Perl?
The script took few parameters from user like start date and end date, and generate some monetory statistics for that duration. Internally the script fired sql queries and worked on the results to provide stats. Once the stat is available, the mail is composed from those stats, and sent to the DL.

Why Perl and why not shell?
Shell is shell specific
Perl is platform independent

How do I call C++/Java APIs from Perl and vice versa?

What is mod_perl?

Comments

Popular posts from this blog

FIX protocol interview questions : Part 1 - Admin/Session

Well, I just felt a need that key FAQs in FIX be documented, so that can be used for a variety of purposes, primarily during interviews to gauge a candidate. I have tried to be correct to the max, but do not guarantee it. This is what is best to my knowledge, and its good to cross check things with the FIX site and documentation available there. 1. What is buy side and what is sell side ? Sell side is the one who earns brokerage. Buy side is the one who pays brokerage. buy side (institutions) sell side (brokers/dealers) 2. What is the latest FIX version in market now? Its FIX 5.0 SP2. Something called FIXT.1.1 is also coming. 3. What is FIXML? FIXML is a structured, validated Extensible Markup Language (XML) derived grammar that is encapsulated within the standard FIX message. This format leaves the FIX session handling intact and minimizes the impact to existing implementations. As an XML-derived language, FIXML messages can be validated by standard parsers and take advantage of a fle...

what is a core dump

 A core dump (or core file ) is a file that captures the memory contents of a running process at a particular point in time, typically when the process crashes or encounters a serious error, such as a segmentation fault or illegal instruction. What is a core dump? It is essentially a snapshot of a process’s memory, including the call stack, memory allocations, and the state of the program at the time of the crash. It helps developers analyze the cause of a crash by examining the state of the program when the error occurred. Why does a core dump occur? A core dump typically happens when a process encounters a fatal error that causes it to terminate unexpectedly. This might include: Segmentation faults (segfaults): Trying to access memory that the process is not allowed to. Illegal instructions: Executing invalid machine instructions. Memory access violations: Trying to access memory in a way that is not allowed (e.g., reading from or writing to protected memory). Un...

std::unordered_map problems

 The std::unordered_map in C++ is a powerful container that provides fast access to key-value pairs with average constant-time complexity ( O(1) ) for lookups, inserts, and deletions. However, like any data structure, it has its potential issues, trade-offs, and limitations. Here are some common problems and limitations associated with std::unordered_map : 1. Unpredictable Iteration Order Problem: The order of elements in an unordered_map is not guaranteed. It depends on the internal hash table implementation and the distribution of hash values. Impact: This makes std::unordered_map unsuitable for use cases where the order of elements matters, such as when you need to traverse the elements in a specific order. Example: cpp Copy std::unordered_map< int , std::string> map; map[ 1 ] = "one" ; map[ 2 ] = "two" ; map[ 3 ] = "three" ; // The order in which elements are iterated is not guaranteed for ( auto & entry : map) { std::cout ...