How to use pointer concepts in Perl? For example I have a line and want to search for the given string any where in the that line by positioning using the pointer. Kindly suggest me.
So I have 2 files with a key it like in 1st file I have data as in following columns with value in it as…
ID|Rating_Provider|Time|QualityRating z6Y1kWFT99|S&P_LONG|20110120 12:00:00 AM|NR z6Y1kWFT99|MOODY'S_LONG|20101101 12:00:00 AM|NR
and in 2nd file I have data as in following columns in it as…
ID|BBCMPSEC|QualityRating_S&P_LONG|Time_S&P_LONG|QualityRating_MOODY'S_LONG|Time_MOODY'S_LONG
Now finally I need to see the data as…
ID|BBCMPSEC|QualityRating_S&P_LONG|Time_S&P_LONG|QualityRating_MOODY'S_LONG|Time_MOODY'S_LONG z6Y1kWFT99|xxx|NR|20110120 12:00:00 AM.
ETA: Based on your comments, I would say that you’d be best off using Text::CSV. Take a look at the documentation, it is quite helpful. Basically, you would do something like:
Old answer
“pointers” are not used in perl. I assume you mean the position of the match. There are several ways. You can use
indexif you do not need any regexes:If you do need a regex, perhaps for some more complicated matches, you can use the predefined variable
@-, which stores the position where your match begins:However, I suggest you tell us what it is you are trying to do. Using string offsets is not the best perl tool in the box, and I suspect there are much better ways of solving your problem.