Another way, avoiding any sorting:
use strict; use warnings; use 5.010; my @month_names = ( qw / January February March April May June July August September October November December / ); my %month_hash; while ( my $line = <DATA> ) { $month_hash{$_} = 1 for split /[^a-z]+/i, $line; } for ( @month_names ) { say if $month_hash{$_}; } __DATA__ IBM | February 1 March 5 July 4 Oracle| January 3 March 4 April 6 May 5 RedHat | March 2 June 3 August 1
In reply to Re^3: How to print months in proper order from array
by Not_a_Number
in thread How to print months in proper order from array
by dirtdog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |