Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Perl: Reversing a text by Word

$text="Welcom to www.tubedir.com";
print("Before :n",$text,"
");
@myWords    = split(" ", $text);
#start reversing
$reversedWords   = join(" ", rever

Perl: concatenate a number and a string

$text = "Perl version ";
$value = 6.0;
$concat =$text . $value ;
print "I use  $concat";

Perl: Bitwise and Bit Shift Operators

#!/usr/bin/perl
$bin=8;              # 1000
$number = $bin > 1; # right shift
print $number,"n";

Perl: Setting Up a UDP Client

#!/bin/perl -tw
my $remote_host="127.0.0.1";     
my $remote_port=80;               
my $protocol="udp";              
use Socket qw(AF_INET SOCK_DGR

Perl: Creating a temporary file

#!/usr/bin/perl
use File::Temp qw(tempfile);
# Create temporary file
($fh, $fileName) = tempfile( );

Perl: How to create a chart in MS Excel

#!/usr/bin/perl -w
use Win32::OLE;
use Win32::OLE::Const 
use strict;
my $xls_app = Win32::OLE->new( 'Excel.Application' )
	or die "Unable to access

Perl: How to Connect to mysql

#!/perl/bin
use DBI;
use strict;
my $db_connect = DBI->connect('dbi:mysql:MyDatabase',
								'username',
								'password',
								 { PrintError =

Perl: reverse Hash

#!/usr/local/bin/perl
my% myHash = ("Germany" => "Berlin"
     "England" => "London"
     "France" => 'Paris');
foreach $contry (sort keys %myHash)
{

Perl: listing available database Drivers

#!/usr/bin/perl
use strict;
use DBI;
my @drivers = DBI->available_drivers();
print "Installed Drivers:";
foreach my $db_driver (@drivers)
{
  print "$

Perl: Create a UDP server

#!/usr/bin/perl -w
  use strict;
  use IO::Socket;
  my ($sock,   # Socket
      $serv_msg, # server message
      $clt_msg, # client message

Perl: Reading Single Characters from the standard input

#!/usr/bin/perl -w
  use Term::ReadKey;
  ReadMode('cbreak');
  print "Press keys , Ctrl-C to exit.n";
  while (1)
  {
      $myKey = ReadKey(0);

Perl: Binary, octal, and hexadecimal conversion

#!/usr/bin/perl
$hexadecimal="0x2e"   ;
$value = hex($hexadecimal);         #47
print $value,"n";
$octal= "056";
$value = oct($octal);

Perl: Treating files in binary mode

open (FILEHANDLE, ">c:/test.txt")
    or croak ("Opening Failed");
binmode FILEHANDLE;
print FILEHANDLE "Welcom to perl.tubedir.com";
close (FILEHAND

Perl: How to modify the read, write, and execute permissions on a file.

#! /usr/local/bin/perl
$file_1="c:/test.txt";
chmod(0400, $file_1);  
chmod(0200, $file_1);  
chmod(0001, $file_1);

Perl: How to check end

#!/usr/bin/perl -w
print "Enter text: ";
$line=;                        
foreach $elem ($line) {
    if ($elem =~ /perl$/)
    {
        print "	Perl