Program printing all possible combinations of TCP flags

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Main function of this program is/was to generate a list of C string
literals used to populate an array which can be used to map the
numerical value of the flags field in a TCP header to a string
containing an uppercase letter (Fin, Syn, Rst, Psh, Ack, Urg) for each
set flag. Since it is kind-of cute an the algorithm is (IMHO) not
completely trivial/ obvious anymore, I thought I'd just post it here:

NB: This is fairly fast at the expense of possibly consuming huge
amounts of memory.


my @flags = qw(F S R P A U);

    my @all;

    push(@all, '');

    for my $f (@flags) {
    push(@all, map { $_.$f; } @all);
    printf("\"%s\",\n", $_) for (@all);

Site Timeline