I have these few lines as an example:
03#
1#
3#
The goal is to pull the first character each line given the rest of the line as a search key. For example, if given $search_key=3# in line 1, search result shows 0. If given $search_key=#, search results should show only the 2nd and 3rd lines. Using
if (/$search_key/) ...
doesn't work 'cause it won't differentiate # and 3# when $search_key=# so all 3 lines appear. On the other hand, $search_key=3# only shows the first line, which is correct.
Before I try to use substr, I want to make sure if there are other ways to do it.
Thanks.
03#
1#
3#
The goal is to pull the first character each line given the rest of the line as a search key. For example, if given $search_key=3# in line 1, search result shows 0. If given $search_key=#, search results should show only the 2nd and 3rd lines. Using
if (/$search_key/) ...
doesn't work 'cause it won't differentiate # and 3# when $search_key=# so all 3 lines appear. On the other hand, $search_key=3# only shows the first line, which is correct.
Before I try to use substr, I want to make sure if there are other ways to do it.
Thanks.