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
| [reply] [d/l] [select] |
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. | [reply] |
>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}
| [reply] [d/l] |
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. | [reply] |
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\}/ );
| [reply] [d/l] |