in reply to Viewing metasymbols in output?

Well, it sounds like what you want is the Symbol view (or whatever it's called) in a wordprocessor. You can write a quick Perl script to convert a text file into that. Use something like:
local $\ = ''; my $filename = "/mydir/myfile"; open FILE, "<$filename" or die "Cannot open $filename for reading\n"; my $file = <FILE>; close FILE; $file =~ s/\t/\\t/g; open FILE, ">$outfilename" or die "Cannot open $outfilename for writing\n"; print FILE $file; close FILE;
And do that substitution like for every metacharacter you want to replace.

The reason to use s/// instead of tr/// is that you are replacing in a 1:n relationship and not the 1:1 that tr requires.

------
/me wants to be the brightest bulb in the chandelier!

Vote paco for President!

Replies are listed 'Best First'.
Re: Re: Viewing metasymbols in output?
by Hofmator (Curate) on Aug 07, 2001 at 19:52 UTC

    or in one line: perl -pe 's/\t/\\t/g' infile > outfile to allow for more substitutions consider a hash like

    my %mapping = ( # or whatever you like to display "\t" => '\t', "\n" => '\n', " " => '_', ); my $pattern = qr/([@{[join '', keys %mapping]}])/; while ( <> ) { s/$pattern/$mapping{$1}/g; print "$_\n"; # you still want to start a new line }
    This works fine as long as your keys are only characters, otherwise you have to use an alternation instead of a character class.

    -- Hofmator