rsriram has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I am reading through a text file and when I encounter a specific text, I need to report it in the screen along with the line number in which it is appearing. I say print $.. Is there a similar way with which I can display the column number of the instance? For example, I want to report the column and line number in which character '&' is appearing. The message has to be
Line xx Col xx: & found.
print "Line $. : & found\n";
prints the line number, similarly I need to print the column number too. Any suggestions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Displaying the column number when reading a file
by Hue-Bond (Priest) on Aug 07, 2006 at 13:01 UTC | |
|
Re: Displaying the column number when reading a file
by bart (Canon) on Aug 07, 2006 at 13:06 UTC | |
|
Re: Displaying the column number when reading a file
by gellyfish (Monsignor) on Aug 07, 2006 at 13:02 UTC | |
|
Re: Displaying the column number when reading a file
by Velaki (Chaplain) on Aug 07, 2006 at 13:04 UTC | |
|
Re: Displaying the column number when reading a file
by ww (Archbishop) on Aug 07, 2006 at 20:36 UTC |