Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Mixed Data

by cmilfo (Hermit)
on Nov 09, 2001 at 09:37 UTC ( [id://124299]=note: print w/replies, xml ) Need Help??


in reply to Mixed Data

If all you have is ASCII data with binary zeros, you might try just stripping out anything that isn't printable ASCII. Something like this might work.
while($line = <INFILE>) { $line =~ s{[^ -~]}{}g; # [^ -~] matches non printable ASCII chars print "$line\n"; # your new lines are gone after the above }

Just a thought...

Replies are listed 'Best First'.
Re: Re: Mixed Data
by krazken (Scribe) on Nov 09, 2001 at 09:59 UTC
    Someone else suggested...
    while (<>) { print join ' ',split /\x00/; }
    And this does remove the binary zeros from inside of the records.
      Someone else suggested...

      That was me, but you've added a space to the join. If you want to substitute space for null, tr/\000/ /; should work (tr/// wants octal).

      In any case, there is no reason s/\x00//g; wouldn't work if split on that regex does. How about posting some more of your code so we can see what the problem really is?

      After Compline,
      Zaxo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found