#!/usr/bin/perl use warnings; use English '-no_match_vars'; use strict; use Carp; use Data::Dumper; my %rawdata; my $l = 0 ; open my $RW , '<', 'etc/cronjobs/test' or croak $ERRNO; while ( my $r = <$RW> ) { chomp $r; if ( $r =~ /^[\s|\t]*[#]{1,}/smx ) { next ; } if ( $r eq q{} ) { next ; } # remove space at the end $r =~ s/\s+$//gsmx ; $r =~ s/\t+$//gsmx ; if ( $r =~ /^PATH/smx ) { next; } if ( $r =~ /^MAILTO/smx ) { next; } if ( $r =~ /^SHELL/smx ) { next; } if ( $r =~ /[,]\s*?[{]/smx .. $r =~ /[}]\s*[;]\s*$/smx ) { push @{$rawdata{$l}},$r; if ( $OLD_PERL_VERSION > '5.026001' ) { next; } } $l++; if ( $r !~ /[,]\s*[{].+[}][;]$/smx ) { push @{$rawdata{$l}},$r; $l++; } } close $RW or carp $ERRNO; print Dumper %rawdata;