linux poison RSS
linux poison Email
0

Perl Script - Manipulating Arrays of Arrays (Multidimensional Arrays)

Below is simple Perl scrip which demonstrate the usage of multi-dimension arrays (array of arrays)

Feel free to copy and use this code ..

Source: cat multi-dimensional_array.pl
#!/usr/bin/perl

# Multi-dimension array by reference.
$array = ["A", "B", ["1", "2", "3",  ["x", "y", "z"]]];

print "\$array->[0] == $array->[0] \n";
print "\$array->[1] == $array->[1] \n";

print "\$array->[2][1] == $array->[2][1] \n";
print "\$array->[2][2] == $array->[2][2] \n";

print "\$array->[2][3][0] == $array->[2][3][0] \n";
print "\$array->[2][3][1] == $array->[2][3][1] \n";
print "\$array->[2][3][2] == $array->[2][3][2] \n";

print " --------------------------------------- \n" ;

@array1 = (
  "A", "B",
  ["1", "2", "3",  ["x", "y", "z"]]
);

Read more
0

Perl Script: Creating pointers (References) to variable, Array and Hash

A reference is a scalar value that points to a memory location that holds some type of data. Everything in your Perl program is stored inside your computer's memory. Therefore, all of your variables, array, hash and functions are located at some memory location. References are used to hold the memory addresses.

Below is simple Perl script which demonstrate the usage of reference ...

Source: cat pointer.pl
#!/usr/bin/perl

# Creating pointer to a variable.
$var = 10;
$pointer = \$var;
print "Pointer address is: $pointer \n";
print "value store at $pointer is $$pointer \n";

print "--------------------------------\n";

# Creating pointer to an array.
@array = ("1", "2", "3", "4");
$array_pointer = \@array;
print "Address of the array in the memory: $array_pointer \n";

$len = scalar(@$array_pointer);
print "Length of the array: $len \n";

for ($i=0; $i<$len; $i++) {
  print "$$array_pointer[$i] \n";
}
Read more
0

Perl Script: Signal Handling

You can control how your program responds to signals it receives. To do this, modify the %SIG associative array. This array contains one element for each available signal, with the signal name serving as the subscript for the element.

Below is simple Perl script which demonstrate the way to handle the interrupt signal...

Source: cat signal.pl
#!/usr/bin/perl

$SIG{"INT"} = "catch_signal";
while (1){
        print "waiting for signal ... press ctl+c to catch the interrupt signal \n";
        sleep(1);
}

sub catch_signal {
        print "\n Kool, I am able to handle interrupt signal \n";
        exit();
}

Output: perl signal.pl
waiting for signal ... press ctl+c to catch the interrupt signal
waiting for signal ... press ctl+c to catch the interrupt signal
waiting for signal ... press ctl+c to catch the interrupt signal
waiting for signal ... press ctl+c to catch the interrupt signal
waiting for signal ... press ctl+c to catch the interrupt signal
^C
 Kool, I am able to handle interrupt signal


Read more
0

Perl Script: Read the Environment Variables

The %ENV associative array lists the environment variables defined for a program and their values. The environment variables are the array subscripts, and the values of the variables are the values of the array elements.

Source: cat env_variable.pl
#!/usr/bin/perl

$term = $ENV{"TERM"};
print "Terminal you are using: $term \n";

$desktop = $ENV{"DESKTOP_SESSION"};
print "Desktop you are using: $desktop \n";

$lang = $ENV{"LANGUAGE"};
print "Lang you are using: $lang \n";

Output: perl env_variable.pl
Terminal you are using: xterm
Desktop you are using: kde-plasma
Lang you are using: en_US:


Read more
0

Free eBook - Website Security Threat Report

"Website Security Threat Report"

Updates from Symantec's Internet Security Threat Report.
The Internet Security Threat Report provides an overview and analysis of the year in global threat activity. The report is based on data from the Global Intelligence Network, which Symantec's analysts use to identify, analyze, and provide commentary on emerging trends in attacks, malicious code activity, phishing, and spam.

This shortened version of the report - the Website Security Threat Report - has been created to specifically focus on website security issues.

Download your free copy of Website Security Threat Report - here


Read more
0

Database tool for Developers and Database Administrators - DBeaver

DBeaver is free universal database tool for developers and database administrators.

 * It is freeware.
 * It is multiplatform.
 * It is based on opensource framework and allows writing of various extensions (plugins).
 * It supports any database having a JDBC driver.
 * It may handle any external datasource which may or may not have a JDBC driver.
 * There is a set of plugins for certain databases (MySQL and Oracle in version 1.x) and different database management utilities (e.g. ERD).

Supported databases:
MySQL, Oracle, PostgreSQL, IBM DB2, Microsoft SQL Server, Sybase, ODBC, Java DB (Derby), Firebird (Interbase), HSQLDB, SQLite, Mimer, H2, IBM Informix, SAP MAX DB, Cache, Ingres, Linter, Teradata, Any JDBC compliant data source

Read more
0

Open Source Host-based Intrusion Detection System - OSSEC

OSSEC is an Open Source Host-based Intrusion Detection System that performs log analysis, file integrity checking, policy monitoring, rootkit detection, real-time alerting and active response.

It runs on most operating systems, including Linux, MacOS, Solaris, HP-UX, AIX and Windows.

OSSEC Features:
OSSEC is a full platform to monitor and control your systems. It mixes together all the aspects of HIDS (host-based intrusion detection), log monitoring and SIM/SIEM together in a simple, powerful and open source solution.

 * Compliance Requirements
 * Multi platform
 * Real-time and Configurable Alerts
 * Integration with current infrastructure
 * Centralized management
 * Agent and agentless monitoring
 * File Integrity checking
 * Log Monitoring
 * Rootkit detection
 * Active response

Read more
1

Free eBook - Citrix NetScaler - A Foundation for Next-Generation Datacenter Security

"Citrix NetScaler - A Foundation for Next-Generation Datacenter Security"


Today's regulatory requirements and evolving network architectures can make data-center security feel like a moving target.

This technical paper is designed to help you build a flexible, powerful security solution that reduces costs by leveraging your existing load balancing and ADC infrastructure.

Application Security - with web app firewall security, Data Loss Protection (DLP) and app-layer Denial of Service (DoS) defenses

Network/Infrastructure Security - including high-performance SSL, DNS security and multiple network-level attack protections

Identity and Access Management - for flexible application access control based on strong user authentication, app authorization and detailed auditing

Management - seamless integration with leading third-party products to extend reporting, analytics, vulnerability assessment capabilities

Download your free copy of - Citrix NetScaler - A Foundation for Next-Generation Datacenter Security - here


Read more
0

Free eBook - HackerProof: Your Guide to PC Security

"HackerProof: Your Guide to PC Security"

This 53 page guide provides an objective, detailed, but easily understood walk through of PC security.

The terms "PC security" or "computer security" are vague in the extreme. They tell you very little, like most general terms. This is because PC security is an incredibly diverse field. On the one hand you have professional and academic researchers who carefully try to find and fix security issues across a broad range of devices. On the other hand, there is also a community of inventive computer nerds who are technically amateurs (in the literal sense of the word – they're unpaid and unsupported by any recognized institution or company) but are highly skilled and capable of providing useful input of their own.

PC security is linked to computer security as a whole, including issues like network security and Internet security. The vast majority of the threats that may attack your computer are able to survive only because of the Internet and, in some cases, the survival of a security threat is directly linked to a security flaw in some high-end piece of server hardware. However, the average PC user has no control over this.

By the end of this guide you will know exactly what PC security means and, more importantly, what you need to do to keep your PC secure. Also with this free guide you will also receive daily updates on new cool websites and programs in your email for free courtesy of MakeUseOf.

Download your free copy of "HackerProof: Your Guide to PC Security" - here


Read more
0

Perl Script: Input Line/record Separator examples

The input line/record separator ($/) is set to newline by default. Works like awk's RS variable, including treating blank lines as delimiters if set to the null string. You may set it to a multi-character string to match a multi-character delimiter, or can be set to the numeric value.

Below is simple perl script which demonstrate the usage of input record separator, feel free to copy and use this script.

Input File: cat testfile.txt
google:yahoo:microsoft:apple:oracle:hp:dell:toshiba:sun:redhat

Source: cat separator.pl
#!/usr/bin/perl

$FILE = "testfile.txt";
open (INFILE, $FILE) or die ("Not able to open the file");
$/ = ":";
while ($record = <INFILE>) {
        print "$record \n";
}

Read more
0

Convert your media files to all the popular formats - Format Junkie

Format Junkie is an Graphical User Interface user-friendly application with lots of options, which can convert your media files to all the popular formats! Unity integration has been bear in mind.

Specifically, it has the following features:

a) Audio: Conversion between the audio formats: mp3, mp2, wav, ogg, wma, flac, m4r, m4a and aac
b) Video: Conversion between the video formats: avi, ogv, vob, mp4, vob, flv, 3gp, mpg, mkv, wmv
c) Image: Conversion between the image formats: jpg, png, ico, bmp, svg, tif, pcx, pdf, tga, pnm
d) Iso|Cso Create an iso with selected files, convert iso to cso and vice versa.
e) Advanced Encode subtitles to an avi file.

Read more
0

Free eBook - Build and Deploy Application using Open-Source Products

"SOA and WS-BPEL: Free 316 Page eBook"

Build and deploy your own service-oriented application using open-source products PHP and ActiveBPEL engine, as described in this easy-to-follow tutorial eBook.

Web services, while representing independent units of application logic, of course, can be used as stand-alone applications fulfilling requests from different service requestors. However, the real power of web services lies in the fact that you can bind them within service compositions, applying the principles and concepts of Service-Oriented Architecture. Ideally, web services should be designed to be loosely coupled so that they can potentially be reused in various SOA solutions and used for a wide range of service requestors.

As the name implies, the main idea behind this eBook is to demonstrate how you can implement Service-Oriented Solutions using PHP and ActiveBPEL Designer—free software products allowing you to effectively distribute service processing between the web/PHP server and ActiveBPEL orchestration engine. When it comes to building data-centric services, the eBook explains how to use MySQL or Oracle Database XE, the most popular free databases.

This practical eBook explains in extensive detail how to build Web Services with PHP and then utilize them within WS-BPEL orchestrations deployed to the ActiveBPEL engine.

Download your free copy of "SOA and WS-BPEL" - here


Read more
Related Posts with Thumbnails