#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11110110 use warnings; $_ = do { local $/; <DATA> }; print " pattern offset pin_num\n"; while( /\^/g ) { my $pre = $`; my ($pattern, $offset) = $pre =~ /^(\S+)\s+(\S+).*\n(.*)\z/m; my $mask = $3 =~ tr//\0/cr . "\xff"; my $column = join '', map +($_ & $mask) =~ tr/\0//dr, split /^/, $pr +e; my ($pin, $hl) = $column =~ /(...).*(.)/; printf "%6s%7s%7s%9s\n", $pattern, $offset, $pin, $hl; } __DATA__ p p p p p Pin Numbers 3 2 1 8 9 1 2 3 4 5 pattern offset scan1 2965 H L H L H ^ scan2 2200 L H H L H ^ scan3 1100 H L L L L ^ scan4 1500 L L H H H ^ scan5 2800 H H L H H ^ ^
In reply to Re: Perl script to match a regexp in the prior line and other multiple lines
by tybalt89
in thread Perl script to match a regexp in the prior line and other multiple lines
by kshitij
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |