Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Record Separator affecting Regex

by dingus (Friar)
on Nov 08, 2002 at 07:42 UTC ( #211365=note: print w/ replies, xml ) Need Help??


in reply to Record Separator affecting Regex

... This should be darn simple, but I can't make it work. It's quite a simple concept: make the record separator ";\n" and filter-out all lines that start with a # -- comments.

First off: Are you sure the current record selector is '\n'. If this is running on a windows machine it is '\r\n' (or do I mean '\n\r'? who cares). In any case the safe way to get the new descriptor is to do (with local if required)

$/= ';'.$/
But actually I think you shoud be not monkeying with $/: at all and just skipping over # lines as you read them in, i.e.
while (my $line = <DATA> ){ next if ($line =~ s/^#/); # skip comment lines print "Query: $line\n"; }

Dingus


Enter any 47-digit prime number to continue.


Comment on Re: Record Separator affecting Regex
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://211365]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2015-07-31 03:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls