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

With some guessing (and fixing what I think is a typo)

#!/usr/bin/perl # http://perlmonks.org/?node_id=1177327 use strict; use warnings; my $prefixlength = length '/Volumes/WD/Not Migrating/Music/'; while(<DATA>) { substr $_, 0, $prefixlength, ''; my $indent = tr#/##; print " " x $indent, "* $_"; } __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

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 21:23 UTC

    Very Very Close. The first part to trim the unwanted path is working correctly. However, everything printed without any indents(tabs) and with an asterisk.

      Are you printing to a terminal or to a web page?

        Probably very convoluted as I am still new to perl, but I output to terminal and "tee" the output to a file with docx extension. I want to open the file with word.