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

^C^D^V^V^A os08 34917 080806 R S 0808050150 00006157^B{T} Please tell me how to remove all the text till {T}.

Replies are listed 'Best First'.
Re: remove content
by ELISHEVA (Prior) on Aug 31, 2009 at 05:50 UTC

    Perl programmers normally use regular expressions to solve such a problem. A reasonably good tutorial is available at perlretut. You'll also want to take a look at the substitution operator, s/// discussed in perlop (look for the string s/PATTERN/REPLACEMENT/)

    Best, beth

Re: remove content
by ikegami (Patriarch) on Aug 31, 2009 at 14:10 UTC
Re: remove content
by Sewi (Friar) on Aug 31, 2009 at 05:56 UTC
    Please look at the comments on your previous questions and you'll find the answer here: http://www.perlmonks.org/?node_id=791003
    For anything else, I could only second ELISHEVA's comment.
Re: remove content
by AnomalousMonk (Archbishop) on Aug 31, 2009 at 05:49 UTC
    >perl -wMstrict -le "my $s = '^C^D^V^V^A os08 34917 080806 R S 0808050150 00006157^B{T}'; print $s; $s =~ s{ .*? (?= {T}) }{}xms; print $s; " ^C^D^V^V^A os08 34917 080806 R S 0808050150 00006157^B{T} {T}
Re: remove content
by Marshall (Canon) on Aug 31, 2009 at 07:27 UTC
    So, I guess you want something like this?:
    ^C^D^V^V^A^B{T}
    That would be removal of plain "printable" text before {T}.
    {T} would be the removal of all the text until {T}, which is of course just {T}. ^C,^V, etc are text characters.

    Your question is nonsense in the context of a "text file".
    I suspect that you are looking at a binary file instead of a text file.

Re: remove content
by bichonfrise74 (Vicar) on Aug 31, 2009 at 18:52 UTC
    This should do it for you.
    #!/usr/bin/perl use strict; my $str = q{^C^D^V^V^A os08 34917 080806 R S 0808050150 00006157^B{T}} +; print $` if ( $str =~ /\{T\}/ );