The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-26-2009
wxornot wxornot is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 33
grabbing specific column perl

Alright,

I'm new to Perl so be gentle. Given the following script:
----
open(file, "<file.txt");

@lines = <file>;
close(file);

$var = print $lines[18];
----

So I'm printing line 18 of the file "file.txt". I now want the 5th column, minus the forward slash. The line looks like this:

TUV 1/ 3.2/ 4.5/ 3.1/

I tried doing:

print $var | perl -pae '$_="$F[5]\n"';, but i get garbage.

thanks in advance.