Mr_Noob <> wrote:
>What is the best way to grep into a file, only lines beginning with
>"[" and ending with "]" ?
>And then, how can I feed an array with the information contained
>between the 2 brackets, without the 2 brackets?
Just loop through the file. For each line if it m//atches the condition (no
need for grep()) then push() the substr()ing portion into the array.
Other ways:
- to check for first/last character just extract them via substr() and
compare to "[" resp. "]"
- if you inlcude then center portion in your RE for m//, then you can group
it and just push $1 into the array.
- slurp the whole file into the array, then grep() for the right lines, then
discard leding/trailing square brackets
I am sure there are many more variation.
jue
|