Showing posts with label Perl-Expect. Show all posts
Showing posts with label Perl-Expect. Show all posts

Thursday, October 22, 2009

Install TC Expect on Ubuntu

I have an Ubuntu machine, and want to install Expect on this machine using apt-get.
However, the current version of TCL doesn't have Expect. Therefore, I have to remove tcl8.3 first prior to install expect

Here are the steps
# apt-get remove tcl8.3
# apt-get install tcl
# apt-get install expect

Missing Expect on ActiveTCL

Previously, Expect is included on ActiveTCL installation. But regarding to the size of the installer, the new version doesn't have Expect included on the installer.
We need to redownload Expect and install it.

Here is the command to do that:
teacup install Expect

Saturday, March 1, 2008

Multidimensional array in perl

I have several arrays from results of reading and parsing each line from the input. Since Perl doesn't really have a multidimensional array, I need to find out the trick to handle this problem.

Found the page below after digging on google:
http://www.unix.org.ua/orelly/perl/prog3/ch09_01.htm

Then I test it with simple code, as below:


#!/usr/bin/perl
# to test reading a file, split it, then put it into array

use strict;
use warnings;

my $ref_line;
my @lines;

open FH,"testfile.txt";
while () {
push @lines, [split(" ",$_)];
}

for $ref_line (@lines) {
print "@$ref_line[7]\n";
}

The result looks OK to me. Now it's the time to write the code into my project.