I see no permutation or recursion in your example; In what way would this code be insufficient? :
Output:#!/usr/bin/perl use strict; use warnings; while (<DATA>) { chomp; my @fields = split /\s+/; # Change to /\t/ for production? # You can walk the array like this: print "\t$fields[0]\n"; for my $i ( 1 .. $#fields ) { print "$fields[$i-1]\t$fields[$i]\n"; } # Or like this: # my $last_field = ''; # for my $field (@fields) { # print "$last_field\t$field\n"; # $last_field = $field; # } print "\n"; } __DATA__ A B C D E Foo Bar Baz Senior Junior TheThird
A A B B C C D D E Foo Foo Bar Bar Baz Senior Senior Junior Junior TheThird
In reply to Re: converting generation format to parent child format (recursive)
by Util
in thread converting generation format to parent child format (recursive)
by sroux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |