#!/usr/bin/perl print "{"; print " \"data\":\n\t[\n"; my $filename = '/opt/scripts/fester_monitor.sh'; open(my $fh, '<:encoding(UTF-8)', $filename) or die "Could not open file '$filename' $!"; while (my $row = <$fh>) { chomp($row); for($row) { s/^cd.*//; s/^#.*//; ($festerinstance) = m/(fester(\d+))/; print ",\n"; $return = "\t{ \"{#FESTERINSTANCE}\":\"$festerinstance\"}" unless /(^\s*$|^\,$)/; print $return; } } print "\t]\n"; print "}\n";