vendredi 8 avril 2016

Searching a string in perl for x number of occurrences of a character in a IF statement

I'm trying to use perl to find the number of periods on a line and if it contains the number I have defined then to group portions of a line together.

Here is what I have so far

        if (($lines [0] =~ /./) ==3){
            $lines [3] = $lines [0][3..-1]
                if ($lines [2] =~ /'get'/);
                    print Output "qa;$lines[2];get\n"

I feel like I'm close buy not close enough.

Here is a sample of the text file I am reading from, but what I have is not matching.

...State  [ ]
.....County  [ ]
.......City  [ get set clear ]
.......ZIP  [ get detail ]

The goal is for the output to look something like this when I'm done. I really only want get commands right now.

qa;State;County;City get

But I can't seem to get it to match the periods. Any help would be awesome.

Aucun commentaire:

Enregistrer un commentaire