DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Perl Script To Apply A Ruby File To All Xml Files

  • submit to reddit
        Perl script to apply a ruby file to all xml files and to prepend its output with the filename.

ls *xml | perl -ne 'chomp($f = $_);@l = readpipe("cat $f|~/src/aangifte_naar_csv.rb"); print map { "$f,$_" } (@l)' > pl_uitvoer.csv


Snippets Manager replied on Mon, 2012/05/07 - 2:04pm

You could also use xargs, if the Ruby script can be called per line.

Snippets Manager replied on Sat, 2008/10/18 - 8:28am

Hehe :) I know, it is insane, but I needed a really quick'n'dirty method

Snippets Manager replied on Thu, 2008/10/30 - 4:44pm

Please please please don't do that. Just make your Ruby script take arguments and do it all inline... this is just insane.