[solved]Perl: Printing line numbers to matched strings and hashes.
Florida State University, Tallahassee, FL, USA, Dr. Whalley, COP4342 Unix Tools.
This program takes much of my previous assignment but adds the functionality of printing the concatenated line numbers found within the input.
Sample input from <> operator:
Hello World
This is hello
a sample program
this program.
The output from above should be:
hello: 2 times, lines 1, 2
world: 1 times, lines 1
this: 2 times, lines 2, 4
sample: 1 times, lines 3
program: 2 times, lines 3, 4
is: 1 times, lines: 2
Due to this being a current assignment I cannot submit all of my code for obvious reasons. I have the hash count for the instances correct. I'm having issues with finding and printing the lines (concatenated together, etc).
Any hints greatly appreciated. I know it's not difficult but I'm not focusing enough because I've spent hours changing it.
You read in the lines, one after the other, in "$tempL", right? Now, if you have a counter which increases every time you start work on a new line, it would contain the line number, yes?
You only need to store this number every time you increase the counter in these lines:
You read in the lines, one after the other, in "$tempL", right? Now, if you have a counter which increases every time you start work on a new line, it would contain the line number, yes?
You only need to store this number every time you increase the counter in these lines:
and
I hope this helps.
bakunin
Thanks for the reply. I made some progress with creating another hash and using the value from the %occurCount hash as the key to the new %lineConcat hash. However, my output is still interesting. Any ideas?
Here's my input and output from command line:
Here's the updated code: ---------- Post updated at 08:19 PM ---------- Previous update was at 01:14 PM ----------
hi All ,
I am having a large file with lots of modules as shown below
###############################################
module KKK
kksd
kskks
jsn;lsm
jsnlsn;
Ring
jjsjsj
kskmsm
jjs
endmodule
module llll
1kksd11
k232skks
j33sn;l55sm (6 Replies)
Hi
I have no experience in Unix so any help would be appreciated
I have the flowing text
235543
123
45654
199
225
578
45654
199
225
I need to find this sequence from A file
45654
199
225 (22 Replies)
Florida State University, Tallahassee, FL USA, Dr. Whalley, COP4342
1. The problem statement, all variables and given/known data:
Create a lex specification file that reads a C source program that ignores keywords and collects all identifiers (regular variable names) and also displays the line... (3 Replies)
Hi,
I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this:
Name =A
xxxxxx
yyyyyy
zzzzzz
aaaaaa
bbbbbb
Value = 57
This is necessary because in a file there are written more lines which... (6 Replies)
hi dudes, I nee you kind assistance, I have to find the matched numbers from 2 text files and output of matched numbers should be in another text file..
I do have text files like this , for example
File 1
787
665*5-p
5454
545-p
445-p
5454*-p
File 2
5455
787
445-p
4356
2445
144
... (3 Replies)
I got multiple of documents in which i have to extract a line coming after a ID..The scenario is
Customer ID: none
VT : 002/89
Customer ID: Yes
VT: 001/89
Customer ID: none
VT: 006/85
Customer ID: Yes
VT: 003/56
I have to extract the id which is coming after YES..The output... (7 Replies)
Hi there
I have a hash of hashes made up of the following data
bge0|100|half|10.36.100.21
bge1|1000|full|10.36.100.22
bge2|1000|full|10.36.100.23
which when i turn into a hash, would look like this inside the system
bge0 ->
nic_speed -> 100
nic_duplex -> half
... (6 Replies)
Hi,
I am stuck at this problem where part of my code would store all the websites that has been accessed by a user. I pull these values from a log file. I want to create a HASH of HASHES ? (Please correct me if this is not the right approach) where I would store all the hits to website with... (4 Replies)
I know this must be really easy, but i can't get it to work
I've got a perl script, with a file.
I want to print an empty line, and the following doesn't seem to work:
print nameoffile "\n"
thanks for your help!! (3 Replies)
Maybe this question is out there, but I searched and didnt see it.
To print my files I use
more filename | lpr -Pprinter
I would like to print my scripts with line numbers.
How do I do this? (2 Replies)