On Wed, Jun 18, 2008 at 22:52, Eng. Fadhl Al_Akwaa
<[EMAIL PROTECTED]> wrote:
>
>
> Dear Sir
> I am beginner with perl and I read many things to do what I want.
> I have a text file  and I want  to extract the column inside the text. the 
> problem is that the lines is not length equal.
> please how could I do it.
> Regards
> Fadhl M. Al-Akwaa  Biomedical Engineering, PhD Student


If  your data has a column separator that does not occur inside of the
fields it can be is as simple as:

#!/usr/bin/perl

use strict;
use warnings;

my $separator = " ";

while (<>) {
    my @fields = split $separator;
    print "$fields[3]\n"; #print the fourth field
}

You can then run it like this:

perl example_script.pl file_to_extract_field_from.txt

You might find the following documentation useful:

http://perldoc.perl.org/functions/split.html
http://perldoc.perl.org/perlsyn.html
http://perldoc.perl.org/perlfunc.html
http://perldoc.perl.org/perlop.html
http://perldoc.perl.org/perlretut.html
http://perldoc.perl.org/perlre.html

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to