Iteration on line number using perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Iteration on line number using perl
# 1  
Old 08-08-2008
Iteration on line number using perl

hi freinds,
I am writing a script using perl
My input file will be looking like this
OSILANConnectorTypeDetected RO 11713000
OSILANSignalTypeOverride RW 11610000
OSILANSignalTypeDetected RO 11620000
OSILANSignalTypeAdaptive RW 11630000

Now i need the control go to 1st line 3rd field value and using that value do some operations.Then it should iterate to 2nd line and take 3 rd field value and using that value perform same opertions then 3rd line ..4th line..
please anyone help on this
# 2  
Old 08-08-2008
In other words, "how do I do something on the third field for each input line in Perl"?

Code:
perl -lane 'print "This is the third field: ", $F[2]' inputfile

# 3  
Old 08-08-2008
what happend to the help you were provided on another forum 2 days ago?

perl syntax for using awk - Perl Forum

Note eras code is essentially the same I posted for you on the other forum, then you changed the requirements, and then you abandoned that thread and restarted it here.
# 4  
Old 08-08-2008
Sounds more like the OP should pre-sort the data to get it in the correct order so jumping around, random access style, is not required. IMO.

Kevin - he may be trying to avoid you... Smilie
# 5  
Old 08-08-2008
Quote:
Originally Posted by jim mcnamara
Sounds more like the OP should pre-sort the data to get it in the correct order so jumping around, random access style, is not required. IMO.

Kevin - he may be trying to avoid you... Smilie
Could be. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Iteration in perl

How to iterate the contents in below file using PERL? url.txt (2 Replies)
Discussion started by: vel4ever
2 Replies

2. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

3. Shell Programming and Scripting

Cut from specific line number to a line number

Hi All, I've a file like this.. Sheet1 a,1 a,2 a,3 a,4 a,5 Sheet2 a,6 a,7 a,8 a,9 a,10 Sheet3 a,11 a,12 a,13 (7 Replies)
Discussion started by: manab86
7 Replies

4. Programming

Perl OLE Selection property iteration in cycle

Hi gurus, i am trying to write simple perl script using win32 ole which will iterate over all M$ word paragraphs (any text that ends with a hard return) and print only those paragraphs that matches the specified condition. The problem is that I need to access font size property. It seems to me that... (0 Replies)
Discussion started by: wakatana
0 Replies

5. Shell Programming and Scripting

Perl : print the sequence number without missing number

Dear Perl users, I need your help to solve my problem below. I want to print the sequence number without missing number within the range. E.g. my sequence number : 1 2 3 4 5 6 7 8 11 12 13 14 my desired output: 1 -8 , 11-14 my code below but still problem with the result: 1 - 14 1 -... (2 Replies)
Discussion started by: mandai
2 Replies

6. Shell Programming and Scripting

Write $line number into textfile and read from line number

Hello everyone, I don't really know anything about scripting, but I have to manage to make this script, out of necessity. #!/bin/bash while read -r line; do #I'm reading from a big wordlist instructions using $line done Is there a way to automatically write the $line number the script... (4 Replies)
Discussion started by: bobylapointe
4 Replies

7. UNIX for Dummies Questions & Answers

How to read contents of a file from a given line number upto line number again specified by user

Hello Everyone. I am trying to display contains of a file from a specific line to a specific line(let say, from line number 3 to line number 5). For this I got the shell script as shown below: if ; then if ; then tail +$1 $3 | head -n $2 else ... (5 Replies)
Discussion started by: grc
5 Replies

8. Shell Programming and Scripting

how to get the data from line number 1 to line number 100 of a file

Hi Everybody, I am trying to write a script that will get some perticuler data from a file and redirect to a file. My Question is, I have a Very huge file,In that file I have my required data is started from 25th line and it will ends in 100th line. I know the line numbers, I need to get all... (9 Replies)
Discussion started by: Anji
9 Replies

9. Shell Programming and Scripting

Adding a columnfrom a specifit line number to a specific line number

Hi, I have a huge file & I want to add a specific text in column. But I want to add this text from a specific line number to a specific line number & another text in to another range of line numbers. To be more specific: lets say my file has 1000 lines & 4 Columns. I want to add text "Hello"... (2 Replies)
Discussion started by: Ezy
2 Replies

10. Shell Programming and Scripting

Appending line number to each line and getting total number of lines

Hello, I need help in appending the line number of each line to the file and also to get the total number of lines. Can somebody please help me. I have a file say: abc def ccc ddd ffff The output should be: Instance1=abc Instance2=def Instance3=ccc Instance4=ddd Instance5=ffff ... (2 Replies)
Discussion started by: chiru_h
2 Replies
Login or Register to Ask a Question