#!/usr/bin/perl use strict; use warnings; my $prev_col; my $counter; while ( <DATA> ) { chomp; my ($col, $rest) = $_ =~ /^([^\s]+)(\s.*)$/; if ( ! defined $prev_col || $col ne $prev_col ) { $counter++; $prev_col = $col; } print "$col $counter$rest\n"; } __DATA__ aa one two three aa four five six xy z xy a xy b cc asdfasdf
Cheers - L~R
In reply to Re: incrementing a column
by Limbic~Region
in thread incrementing a column
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |