Over a million developers have joined DZone.

Perl / XML / Pattern Match

DZone's Guide to

Perl / XML / Pattern Match

· ·
Free Resource
This code parses through the games.xml file generated by EMUCenter and changes Genre to Letter, also taking the first letter of the Title property and adding it to the Letter property.  This allows sorting by letter in the EMUCenter interface. Two things, Change the metadata entry from Genre to Letter and remove the trailing  at the very end of the file.

my $holdTerminator = $/;
undef $/;

if (open(FILE, '
$/ = $holdTerminator;

@array = split /\<\/game\>/, $file;
open(FILE1, '>c:\newgames.xml');

foreach $line (@array){
	$line =~
	print FILE1 $line;
	print FILE1 '';



Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}