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

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

Perl: Setting Up a UDP Client

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

Perl: Creating a temporary file

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

use DBI;
use strict;
my $db_connect = DBI->connect('dbi:mysql:MyDatabase',
								 { PrintError =

Perl: reverse Hash

my% myHash = ("Germany" => "Berlin"
     "England" => "London"
     "France" => 'Paris');
foreach $contry (sort keys %myHash)

Perl: listing available database Drivers

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;
  print "Press keys , Ctrl-C to exit.n";
  while (1)
      $myKey = ReadKey(0);

Perl: Binary, octal, and hexadecimal conversion

$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");
print FILEHANDLE "Welcom to perl.tubedir.com";

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

#! /usr/local/bin/perl
chmod(0400, $file_1);  
chmod(0200, $file_1);  
chmod(0001, $file_1);

Perl: How to check end

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