in reply to Most efficient way to remove some text from a string

You haven't shown the relevant parts of the code you've already written, so my advice remains pretty generic:

To trim the string, see substr.

To find the number of levels and get at the elements, then see split.

To print bullet points, see print and maybe *, or, if your terminal is unicode-aware, any of the fancy Unicode glyphs. Also see \N{}, respectively print "\N{BULLET}".

Replies are listed 'Best First'.
Re^2: Most efficient way to remove some text from a string
by adamZ88 (Beadle) on Dec 06, 2016 at 20:44 UTC

    I have very little done so far

    open(FILEREAD, "</home/zzz/Desktop/Scripting/usb/musicLibrary.txt"); while ($aPath = <FILEREAD>) {chomp ($aPath); my $file =~ s/$sPath/Totally/; print "This Path $file \n\n";} close (FILEREAD);

      This prints only the artist, album or track name

      #!perl use strict; #my $infile = '/home/zzz/Desktop/Scripting/usb/musicLibrary.txt'; #open IN,'<',$infile or die "Could not open $infile $!"; #while (<IN>){ while (<DATA>){ chomp; my @f = split '/',$_; my $tab = ' ' x (@f-6); print $tab.$f[-1]."\n"; } __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/Despabílate.m4a
      poj

        This is really, really close. I like how it prints only the artist, album, or track name. Is there a way to print this output with bullets or even better, heading styles (like in word) so that when I copy the output to a word document I could "collapse" all artist thus displaying artist only. If I expand all, artist, album and tracks will be displayed. This may be outside of the scope of this forum.