in reply to Re^5: Most efficient way to remove some text from a string
in thread Most efficient way to remove some text from a string

I had not thought about XML!!!! Thank you!

  • Comment on Re^6: Most efficient way to remove some text from a string

Replies are listed 'Best First'.
Re^7: Most efficient way to remove some text from a string
by poj (Abbot) on Dec 07, 2016 at 20:56 UTC

    XML ? something like this perhaps. Open the output file with a browser to get text folding.

    #!perl use strict; use XML::Simple; #my $infile = '/home/zzz/Desktop/Scripting/usb/musicLibrary.txt'; #open IN,'<',$infile or die "Could not open $infile $!"; #while (<IN>){ my %hash=(); while (<DATA>){ chomp; if (/\.m4a$/){ my @f = split '/',$_; push @{ $hash{'artist'}{$f[-3]}{'album'}{$f[-2]}{'track'}},$f[-1]; } } open OUT,'>','report.xml' or die "$!"; print OUT XMLout(\%hash,RootName=>'records'); __DATA__ /Volumes/WD/Not Migrating/Music/Ana Tijoux /Volumes/WD/Not Migrating/Music/Ana Tijoux/Luchin /Volumes/WD/Not Migrating/Music/Ana Tijoux/Luchin/Luchin.m4a /Volumes/WD/Not Migrating/Music/Ana Tijoux/Kaos/ /Volumes/WD/Not Migrating/Music/Ana Tijoux/Kaos/Intro.m4a /Volumes/WD/Not Migrating/Music/Ana Tijoux/Kaos/Gol.m4a /Volumes/WD/Not Migrating/Music/Ana Tijoux/Kaos/Track3.m4a /Volumes/WD/Not Migrating/Music/Ana Tijoux/Kaos/Track4.m4a

    Be aware of the STATUS of XML::Simple and the CAVEATS within

    poj

      Thank you Poj. Would the regex to match different file types be (/\.\w+$/)