Posted: July 25, 2009 in Others

I used develop perl script in my Laptop using OpenSUSE 10.3, now i wanna try make code in Windows and now  downloading StrawberryPerl for develop in Windows environment…Happy coding !!


Welcome Back

Posted: July 14, 2009 in Others

Damn, it’s quite long time i didn’t update my perl blog. It’s caused of my activity; working, finished by bachelor, and doing some project. There’s no time to update this blog. Start from now, I will update this blog, at least one post each month.

Wilkommen !!

Unix/Linux Command Reference

Posted: May 22, 2008 in SysAdmin

ls directory listing

ls -al – formatted listing with hidden files

cd dir – change directory to dir

cd – change to home

pwd – show current directory

mkdir dir – create a directory dir

rm file – delete file

rm -r dir – delete directory dir

rm -f file – force remove file

rm -rf dir – force remove directory dir *

cp file1 file2 – copy file1 to file2

cp -r dir1 dir2 – copy dir1 to dir2; create dir2 if it

doesn’t exist

mv file1 file2 – rename or move file1 to file2

if file2 is an existing directory, moves file1 into

directory file2

ln -s file link – create symbolic link link to file

touch file – create or update file

cat > file – places standard input into file

more file – output the contents of file

head file – output the first 10 lines of file

tail file – output the last 10 lines of file

tail -f file – output the contents of file as it

grows, starting with the last 10 lines

Process Management

ps – display your currently active processes

top – display all running processes

kill pid – kill process id pid

killall proc – kill all processes named proc *

bg – lists stopped or background jobs; resume a

stopped job in the background

fg – brings the most recent job to foreground

fg n – brings job n to the foreground

File Permissions

chmod octal file – change the permissions of file

to octal, which can be found separately for user,

group, and world by adding:

4 – read (r)

2 – write (w)

1 – execute (x)


chmod 777 – read, write, execute for all

chmod 755 – rwx for owner, rx for group and world

For more options, see man chmod.


ssh user@host – connect to host as user

ssh -p port user@host – connect to host on port

port as user

ssh-copy-id user@host – add your key to host for

user to enable a keyed or passwordless login


grep pattern files – search for pattern in files

grep -r pattern dir – search recursively for

pattern in dir

command | grep pattern – search for pattern in the

output of command

locate file – find all instances of file

System Info

date – show the current date and time

cal – show this month’s calendar

uptime – show current uptime

w – display who is online

whoami – who you are logged in as

finger user – display information about user

uname -a – show kernel information

cat /proc/cpuinfo – cpu information

cat /proc/meminfo – memory information

man command – show the manual for command

df – show disk usage

du – show directory space usage

free – show memory and swap usage

whereis app show possible locations of app

which app – show which app will be run by default


tar cf file.tar files – create a tar named

file.tar containing files

tar xf file.tar – extract the files from file.tar

tar czf file.tar.gz files – create a tar with

Gzip compression

tar xzf file.tar.gz – extract a tar using Gzip

tar cjf file.tar.bz2 – create a tar with Bzip2


tar xjf file.tar.bz2 – extract a tar using Bzip2

gzip file – compresses file and renames it to


gzip -d file.gz – decompresses file.gz back to



ping host – ping host and output results

whois domain – get whois information for domain

dig domain – get DNS information for domain

dig -x host – reverse lookup host

wget file – download file

wget -c file – continue a stopped download


Install from source:



make install

dpkg -i pkg.deb – install a package (Debian)

rpm -Uvh pkg.rpm – install a package (RPM)


Ctrl+C – halts the current command

Ctrl+Z – stops the current command, resume with

fg in the foreground or bg in the background

Ctrl+D – log out of current session, similar to exit

Ctrl+W – erases one word in the current line

Ctrl+U – erases the whole line

Ctrl+R – type to bring up a recent command

!! – repeats the last command

exit – log out of current session

* use with extreme caution.

GUI Development with Perl/Tk

Posted: May 10, 2008 in Others

A few days ago, i very confused to choose the GUI builder in Perl…there’s a few choise like perl-qt, perl/tk,wxperl. And then just go to their website to compare, where’s the better GUI. Finally, I chose perl/tk for develop GUI application. Here’s the first development that’s using perl/tk. I build a console menu using perl/tk, i give my application name is “Iguana Konsole”..:D. Environment development using :

– Opensuse 10.3

– Perl v.5.8.8

– Tk modules

Here’s the screenshot :

Iguana Console

Simple SSH Authentication

Posted: May 3, 2008 in Networking

I write a simple program for SSH authentication, just simple…cause i’m just learning step by step for network programming. Nice package module from Christian Hansen.



use strict;
use warnings;
use Authen::Simple::SSH;

if ($#ARGV != 2){
print “Usage : $! host username password”;

my $host = $ARGV[0];
my $uname = $ARGV[1];
my $passwd =$ARGV[2];

my $ssh = Authen::Simple::SSH -> new (host => $host);
die “Can’t locate to target” unless $ssh;

if ($ssh->authenticate($uname,$password))
print “Authentication is sucessfull”;
else {
print “Failed to connect, username or password is wrong”;


Keep learning.

My Perl Geek Code

Posted: April 4, 2008 in obfuscate

Version: 0.01
P++>++(+)c–> (-)P6->+(+)R++M+O++MA
G A—OLJ++Ee—Ev*Eon uL+w m!

Perl is the expert system administrator’s scripting language of choice, but it is also a lot more than that. As a language designed for file and text processing, it is ideally suited to UNIX system administration, Web programming, and database programming, among dozens of other uses.

As one of the easiest programming languages to use for whipping up quick, effective code for simple tasks, Perl attracts new users easily and has become an important and popular tool for getting things done. Before jumping fully into Perl programming, though, there are a few things you should know that will make your life easier, both when writing code and when asking for help from Perl experts.

1. Perl is not an acronym

Perl is sometimes known as the Practical Extraction and Report Language, because it’s very practical, and it is very good at extracting data and creating reports using that data. It is also known humorously as the Pathologically Eclectic Rubbish Lister, for reasons that might become obvious after you’ve used it for a while. Both of these phrases are equally “official” and equally correct, but the language is not PERL. It was named Perl before either of those phrases was invented, and the language is in fact not technically an acronym at all. When speaking of the language, call it Perl, and when speaking of the parser (the interpreter/compiler), it is acceptable to call it perl, because that is how the command used to run it is spelled. One of the quickest ways to get identified as a know-nothing newbie when talking to Perl hackers is to call it PERL.

2. There is more than one way to do it

One of the main mottos of the Perl language and community is TIMTOWTDI, pronounced “Tim Toady”. This one really is an acronym, and it stands for There Is More Than One Way To Do It. It’s true of Perl on many levels, and is something important to keep in mind. While some ways to do something are often better than other ways to do the same thing, you can be sure that for pretty much everything you can do with Perl, there is more than one way to do it.

3. Use warnings and use strict

Warnings and the strict pragma are important weapons in the Perl hacker’s arsenal for debugging code. Warnings will not prevent a program from executing, but will give helpful information on how the code can be fixed up.

The strict pragma will actually prevent the code from executing if a strict approach to programming style is not used, such as lexically scoping variables. Once in a while, a program might be better off without the strict pragma, but if you’re new to Perl it will surely be a long time before you learn to recognize such situations, and until then you should just use it.

A Perl script with warnings turned on in the shebang line and the strict pragma used, on a standard UNIX system, would start like this:

#!/usr/bin/Perl -w
use strict;

Warnings can also be turned on with a use statement, like this:

use strict;
use warnings;

A pragma, in Perl, is a preprocessor directive. In other words, it’s an instruction sent to the compiler before the code is compiled for execution. Pragmas change how the compiler parses code.

4. Use taint checking

With the -T option on the shebang line of your program, you explicitly turn on taint checking. This is a security measure that checks all input for your program for “tainted” data, to help ensure that incoming data will not allow arbitrary code execution if a malicious user is trying to crack security on the system running your code. This is especially important in circumstances where you are using Perl/CGI scripts to process data from an HTML form on the Web. It can be combined with the -w option as -wT.

5. Use lexically scoped variables

You can use the my() operator to create variables using lexical scoping. In brief, this means that the scope of the variable is limited to the current context: if you declare a variable using my() inside a subroutine, the variable only exists inside that subroutine. The value of lexical scoping is that it protects different parts of modular code from one another.

For instance, if you’re using a Perl module or library without knowing exactly what the code inside it looks like, using lexical variables can help to prevent accidentally assigning new values to variables that need to remain unchanged until later. It is especially important to use lexical scoping for your variables when writing modules and libraries in Perl. For those coming to Perl from other languages, you may know of the concept of lexically scoped variables as “private variables”.

6. How to name your programs

Perl programs should have the appropriate file extension in their names. Many lower-quality Perl howtos simply use the .pl extension for everything, naming Perl scripts something like Technically, the .pl extension should be used for Perl libraries, not for executable Perl programs. For executable files, you should either use .plx or, if your operating system will allow it, no file extension at all. Perl modules, meanwhile, should use the .pm file extension. It is also considered good practice to use only alphanumeric characters and underscores in Perl script filenames, and to start those filenames with a letter (or underscore), similar to how you would start variable names.

7. How to use CPAN

The Comprehensive Perl Archive Network (CPAN) is a rich resource for finding freely available, reusable code. In particular, CPAN is where you’ll find legions of Perl modules that can be used to enhance the functionality of your programs and reduce the time you spend writing them. The options you have for using CPAN vary from one operating system and Perl parser implementation to the next, but you can always browse CPAN using your Web browser. Perl implementations generally come with at least a command-line tool for installing Perl modules from CPAN.

8. How to use Perldoc

The online documentation for Perl is extensive and comprehensive, in the form of Perldoc. With Perldoc installed on your system, you can use it to access documentation on any of the standard Perl functions, installed modules, variables, and a slew of other things — even Perldoc itself! It’s like having one of the most complete programming reference books available right at your fingertips, for free, and searchable since it’s in electronic format.

On some systems, Perldoc will be installed by default with Perl itself, and on others the process for installation should be self-evident. If you have problems getting Perldoc installed, you can always access the online Perldoc Website. Make sure you know how to use Perldoc, because it can make you a more effective Perl hacker in ways that just might surprise you.

9. Don’t reinvent the wheel

You should use subroutines, modules, and libraries often. The point is to help you write code faster and keep that code from becoming unmanageable if you need the same functionality in multiple programs, or more than once in the same program. This is accomplished by separating blocks of code from the rest of your source code using subroutines, modules, and libraries. You’re better off using a design for the wheel that already exists, rather than reinventing the wheel from scratch, most of the time. In addition, when you’re reusing code from a subroutine, module, or library, and you need to improve that code somehow, you only need to change it in one place.

The term “subroutine” in Perl means roughly the same thing as “function” in C.

10. Regular expressions are your friends

Perl’s regular expression syntax can help to make your source code look intimidating to the uninitiated, and as a result sometimes people new to Perl programming avoid regexen. This is, really, a mistake. Regular expressions add a great deal of power to the Perl programming language, often allowing the programmer to do something in three lines that might otherwise take fifty lines of code. Regular expressions are expressions made up of abbreviations for matching patterns in strings that can be used to find and manipulate smaller strings inside larger strings. It behooves the Perl hacker to learn regex syntax and learn it well.

Often Perl hackers and other programmers who use regular expressions will refer to them as “regexen” or “regexes” in the plural (”regex” singular). An alternate version of “regex” is “regexp”, though why anyone would want to add that extra letter, making it more difficult to pronounce clearly, is beyond me.

Once you’ve internalized the lessons of this list, you’re ready to really start learning Perl, and how to program with it. Some good resources for beginners (and experts, too) include Learning Perl for an excellent introductory text, the PerlMonks community for tutorials and discussion, and Ovid’s CGI Course for Perl/CGI Web programming.