Hi, I am trying to modify my iTunes Playlist and I want to prepend every playlist name with a specific pseudonym ...
I wrote a perl script using Perl::Tie module. Unfortunately, it doesnt write the contents of my array to the file after it is done processing each and every line in the file ... I am attaching the script and the playlist file ... Any hint how to finally untie and dump the modified contents to the same input file i.e. the playlist file ... Thanks in advance.. --Sonal Please find the script here: #!/usr/bin/perl -w use strict; use warnings; use Tie::File; my $ITUNES_FILE_PATH = "/cygdrive/d/MyDocuments/My Music/iTunes"; my $ITUNES_LIBRARY_FILE_NAME = "iTunes Music Library1.txt"; my $ITUNES_LIBRARY_FILE = "$ITUNES_FILE_PATH/ $ITUNES_LIBRARY_FILE_NAME"; my $PREPEND_PLAYLIST_KEY = "OEL: "; print "$ITUNES_LIBRARY_FILE\n"; tie my @lines, 'Tie::File', $ITUNES_LIBRARY_FILE_NAME or die "Can't tie $ITUNES_LIBRARY_FILE $!"; for my $i (0..$#lines) { if ( $lines[$i] =~ /::/ ) { my $matched_line = $lines[$i]; #print "$matched_line\n"; my @charArray = split(//, $matched_line); # split with null pattern will split on everything. # so in this case it will be an array of characters #print "$#charArray\n"; #print "$charArray[26]\n"; #print "$charArray[$#charArray-10]$charArray[$#charArray-11]\n"; #Use this splice example to insert #my @browser = ("NS", "IE", "Opera"); #splice @browser, 0, 0, 'Mosaic'; #print "@browser\n"; splice(@charArray, $#charArray-11, 2); splice @charArray, 26, 0, $PREPEND_PLAYLIST_KEY; print "@charArray\n"; } } untie @lines; #close $ITUNES_LIBRARY_FILE; Please find the file I am trying to modify here: </dict> <key>Name</key><string>Sushma Darshan 08::</string> <key>Playlist ID</key><integer>61636</integer> <key>Playlist Persistent ID</key><string>9C1DDB98AD8E3878</string> <key>All Items</key><true/> <key>Playlist Items</key> <array> <dict> <key>Track ID</key><integer>16874</integer> </array> </dict> </dict> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/