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

Once the data has been successfully parsed from your flat input file you can output it in any applicable hierarchical format (JSON, XML, whatever). There are many standalone data viewers for such formats which will fulfil your requirement to expand/collapse parts of the tree. I doubt that MS Word (being your choice) is one such viewer but I have not used it for a couple of decades so perhaps it has improved since.

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

Replies are listed 'Best First'.
Re^6: Most efficient way to remove some text from a string
by adamZ88 (Beadle) on Dec 07, 2016 at 19:18 UTC

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

      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+$/)