in reply to Re^3: Writing to File based on condition
in thread Writing to File based on condition

Thank you for the explanation, but in this example I learnt it is possible to print hash keys directly to an array without doing a for loop. I think the difference is in your example its an array you want to print to a filehandle
if( keys %old > $oldsize ) # only write if new ips added { open my $out, '>', $awsLists or die "$! opening $awsLists"; ##print directly to the file the new keys difference print $out sort keys %old; # sort not needed, but nice touch :) close $out; }
https://www.perlmonks.org/?node_id=1208878

Replies are listed 'Best First'.
Re^5: Writing to File based on condition
by shmem (Chancellor) on Feb 18, 2018 at 18:44 UTC
    print $out sort keys %old;

    Try that. As is, this would print all keys concatenated together as one string. That's fine if each key has a trailing record separator attached.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'