If string equals regex (Perl) - Need Quick help.
#1

I’m trying to use regular expression to match return text from SQL Plus,

Код:
ITEM   COST
-----  ------
SHOES  $10.99	
COAT   $24.95
I want to skip the ITEM line and also the hyphen line. The number of hyphens will vary depending on the values returned by the SQL script.

I can break the lines into words with:

Код:
my @wordsOnLine = split (/\s+/, $line);
This test works fine for skipping the ITEM line

Код:
if ($wordsOnLine[0] eq "ITEM") {next;}
But I want to use regular expressions so I can match the hypen line of any length. These are the lines I used, and neither one of the if statements work to skip the lines:

Код:
if ($wordsOnLine[0] =~ "/^ITEM$/") {next;}
if ($wordsOnLine[0] =~ "/^-+$/") {next;}
How do I write a perl if statement to completely match a regular expression?

I Am new at perl, so please bear me.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)