Dharshana Eswaran wrote:
>
> The output what i m getting is
>
> The input file contains message as follows:
>
> D0 1A 81 03 01 21 80 82 02 81 02 8D 0F 04 54 6F 6F 6C 6B 69 74 20 54 65 73
>
> Sample output:
>
> ENTER THE SEQUENCE between[1-3]:
> 2 1 1 3
>
> The output file contains:
>
> D01A8103012180820281028D0F04546F
>
> I am unable to give spaces between each entry in the output.I need the
> output in steps...
>
> Something like:
> D01A8103
> 0121
> 8082
> 0281028D0F04546F
>
> I tried printing a new line after the syswrite instruction, but i am unable
> to achieve that :-(
use warnings;
use strict;
open my $IN, '<', 'in.txt' or die "Cannot open 'in.txt' $!\n";
open my $OUT. '>', 'output.txt' or die "Cannot open 'output.txt' $!\n";
my %structure = qw( 1 A 2 B 3 C );
my %table = qw( A 4 B 8 C 32 );
( my $data = <$IN> ) =~ s/\s+//g;
print "ENTER THE SEQUENCE between[1-3]: ";
( my $regex = <STDIN> ) =~
s/[^123]*([123])[^123]*/(.{$table{$structure{$1}}})/g;
print $OUT map "$_\n", $data =~ /$regex/;
__END__
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/