Cybercosis has asked for the wisdom of the Perl Monks concerning the following question:

I need to find the record seperator in a very badly done database file. I know the character (a rarely used 012 hex) but I'm not certain how to find it. Any ideas? ~Cybercosis

Replies are listed 'Best First'.
Re: Hex delimiter
by zodiac (Beadle) on Apr 14, 2000 at 11:00 UTC
    local $/="\x12"; # set the inputrecord seperator to \x12 foreach(<>){ # do something with record in $_ }
Re: Hex delimiter
by chromatic (Archbishop) on Apr 14, 2000 at 06:05 UTC
    A backslashed x followed by one or two hex digits will match it: my @records = split(/\x12/, $input); You can also use that in a regex.
Re: Hex delimiter
by btrott (Parson) on Apr 14, 2000 at 06:08 UTC
    Use \x12.

    You can use \x12 in a regular expression, so just split up your database file on \x12. For example, say your database dump is all in $dump:

    my $dump = "foo\x12bar"; for my $record (split /\x12/, $dump) { # process record }