Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Hex delimiter

by Cybercosis (Monk)
on Apr 14, 2000 at 05:52 UTC ( [id://7583]=perlquestion: print w/replies, xml ) Need Help??

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 }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://7583]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-24 00:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found