Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Most efficient way to remove some text from a string

by poj (Abbot)
on Dec 06, 2016 at 21:26 UTC ( [id://1177335]=note: print w/replies, xml ) Need Help??


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

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

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

    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.

      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.

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1177335]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found