Perl For Loop

The Perl for loop is used to loop through a block of code until a specified condition is met. The for loop statement contains three sections followed by a block of code. Below is an example.

A Simple For Loop Example

for (my $number = 1; $number <= 10; $number++) {
  print "$number ";

The first section initializes a variable

my $number = 1;

Then, the loop condition is provided. The loop will run as long as this is true.

$number <= 10;

Finally, the last section is executed at the end of each loop iteration. In our example's case, $number increments by one.


Executing this loop results in:

1 2 3 4 5 6 7 8 9 10

For Loop and Arrays

Here is an example of how the for statement can be used to loop through an array.

my @languages = ("Perl", "Python", "C", "Fortran");
my $size = @languages;
for (my $i = 0; $i <= $size; $i++) {
  print "$languages[$i]\n";

Flash Plugin on Fedora 10

The Adobe Flash Plugin, with sound support, is available on Fedora. These instructions guide you through the installation of Adobe’s Flash Plugin on Fedora 10.

Install Audio Libraries

First, install the audio libraries needed for sound support by the Flash Plugin.

su -c "yum -y install pulseaudio-libs alsa-lib alsa-plugins-pulseaudio"

Using 64-bit Firefox?

Adobe Labs has been offering a 64-bit Flash plugin since Dec 12, 2008. Be sure to first uninstall any other versions of Flash you have installed on the system. Then, download and unpack the 64-bit Flash Plugin for Linux into your Mozilla Plugins folder. For updates and details, visit the Adobe Labs Download page for Flash:

cd $HOME/.mozilla/plugins
tar -xzvf
Don't forget to restart your browser!

32-bit Users Only

Visit and click Download Now. Then select YUM for Linux and download the provided RPM (adobe-release-i386-1.0-1.noarch.rpm).

Install the downloaded RPM which installs /etc/yum.repos.d/adobe-linux-i386.repo.

su -c "rpm -ivh adobe-release-i386-1.0-1.noarch.rpm"

Check that you can access the Adobe Yum repository.

su -c "yum --disablerepo=* --enablerepo=adobe* list"

Now, install the Adobe Flash Plugin

su -c "yum install flash-plugin"

Then, add the Flash Plugin is in your $HOME/.mozilla/plugins folder.

mkdir -p $HOME/.mozilla/plugins
cd $HOME/.mozilla/plugins
ln -s /usr/lib/flash-plugin/ .

Don’t forget to restart your browser!

Bash File Loops

Some examples of iterating through files and looping through file content in Bash. For details, see the Bash man page or the Bash reference manual.

Loop Through Files

for FILE in *; do
  # do something with $FILE
  echo "File: $FILE"

For more control, use /usr/bin/file

for FILE in $(find ./ -name *.html -type f); do
  # do something with $FILE
  echo "HTML File: $FILE"

Loop Through Lines in a File

while read LINE; do
  # do something with $LINE
  echo "Line: $LINE"
done < /etc/hosts

Loop Through Words in a File

for WORD in $(cat /etc/hosts); do
  # do something with $WORD
  echo "Word: $WORD"

Loop Through Characters in a File

while read -n1 CHAR; do
  # do something with $CHAR
  echo "Character: $CHAR"
done < /etc/hosts

iTunes on Linux with Wine

iTunes for Windows XP can be run on Fedora 9 using Wine, an Open Source implementation of the Windows API on top of X and OpenGL. Please note that iTunes runs a bit slow over Wine and I have yet to test an iPhone or iPod with this configuration.

First, install all the wine packages.

sudo yum install wine*

Now, install the pulseaudio alsa plugin for sound support

sudo yum install alsa-plugins-pulseaudio*

Next, download the Windows XP iTunesSetup.exe from Apple.


Now, install iTunes using wine

/usr/bin/wine iTunesSetup.exe

You can now run iTunes manually like so:

env WINEPREFIX="$HOME/.wine" wine "C:\Program Files\iTunes\iTunes.exe"

If you get an error regarding the registry, ignore it by clicking OK.

Here is a screenshot of iTunes running on Fedora 9. Note that there is an icon for iTunes in Gnome’s Notification Area (system tray).

For more information see the iTunes application page at

Top Linux IRC Clients

Internet Relay Chat (IRC), a form of Internet chat was created by Jarkko Oikarinen in 1988. Here is a list of Linux clients that will get you connected to IRC Networks. For an extensive list of IRC clients and their features, see the Wikipedia Comparison of Internet Relay Chat clients page.

  • Irssi
    Irssi is the self proclaimed client of the future and my favorite IRC client. Irssi is a terminal based, feature-rich, highly configurable, themed environment with support for Perl scripts. The project website hosts a large variety of themes and scripts that can be used with Irssi.

  • BitchX
    BitchX is a feature-rich and highly configurable, terminal based IRC client based on ircII. BitchX supports custom scripts, which can be written in TCL.

  • ChatZilla
    ChatZilla is a cross platform, graphical IRC client written entirely in JavaScript and XUL. ChatZilla is a project and can be installed as a Firefox plugin.

  • Konversation
    Konversation is a graphical IRC client for the KDE that supports multiple identities and theme support for nick icons.

  • Pidgin
    Pidgin is a Gnome based, multi-protocol Instant Messaging client with support for IRC.. With Pidgin, you can manage your instant messaging accounts and IRC connections with one, graphical client.

  • CenterIM
    CenterIM is a terminal based, multi-protocol Instant Messaging client with support for IRC. If you want the functionality of Pidgin in a text-based console, then CenterIM is for you.

Bash Trap Control C

Do you want to catch control-c keyboard interrupts in your Bash program? Use the Bash builtin trap command to catch system signals. The following runs control_c() when a user interrupts the main() section with a Control-C (SIGINT).

# example cleanup function
  rm -f /tmp/tempfile
  return $?
# run if user hits control-c
  echo -en "\n*** Ouch! Exiting ***\n"
  exit $?
# trap keyboard interrupt (control-c)
trap control_c SIGINT
# main() loop
while true; do read x; done

Bash & (Ampersand)

The Bash & (ampersand) is a builtin control operator used to fork processes. From the Bash man page, “If a command is terminated by the control operator &, the shell executes the command in the background in a subshell”.

If logged into an interactive shell, the process is assigned a job number and the child PID is displayed. The job number below is one.

bash$ sleep 30 &
[1] 3586

Note that when a process is forked, the child PID is stored in the special variable $!

bash$ echo $!

You can terminate the job by its job number like so:

bash$ jobs
[1]+ Running sleep 30 &
bash$ kill %1
[1]+ Terminated sleep 30

Bash Calculator

For floating point math calculations in Bash, use /usr/bin/bc.
A simple calculator program might look something like this:

echo "scale=2; $@" | /usr/bin/bc -l
exit $?

Alternatively, a calculator function:

   echo "scale=2; $@" | /usr/bin/bc -l
   return $?

If you are looking for more, here are other ways to do math in Bash.