Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assinging a veriable from a specific position 1

Status
Not open for further replies.

biobrain

MIS
Jun 21, 2007
90
GB
Dear All,

I have a data like this in different files

File 1
A B C D E F G H I G H - J
A B C D E - F G H K L M N J

File 2
L M N P Q R L S T V G H I
M N O P Q R M N T Y G H I

Now I want a expression by which I can store a particular position in a variable i.e Position No. 9 in file one correspond to E in both lines

And Position No. 9 in File 2 is P in both lines as this file have an empty column

I now I can easily extract a column by using

my ($M, $N, $P) = @data[6,7,8];

for column number 6 7 and 8 etc. But here I want

my $variable = position number 9 in data file (does not matter what is at this position, i.e number, letter or space)
 
biobrain,

Not sure if i have understood what you are trying to do..?Just curious why are you doing this?

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Well I have to process many files and my data is always stored in the position number 9

While in many files this position could be a empty column i.e only space.
 
Just read the line into a variable and then use "substr" to get the 9th character.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top