I wrote a quick and dirty script to play mp3's from a html index. I parses the file and cuts out the mp3's and if they match a pattern it plays them. However when matching the pattern perl complains that Use of uninitialized value in concatenation (.) at play.pl line 10, <INPUT> line 23. I think it is interpreting the . (as in .mp3) as the concat operator and is bombing out. I got around this as you can see by escaping the . but what's the correct way to fix this problem?
p> Diarmuiduse strict; $SIG{INT} = 'IGNORE'; open(INPUT,"index.html") || die "Cant open index.html\n"; while(<INPUT>){ if(/^<a href=\"(.*)\">/){ my $mp3 = $1; $mp3 =~ s/\./\\\./g; if ($mp3 =~ /$ARGV[0]/i){ $mp3 =~ s/\\\./\./g; (my $print_mp3 = $mp3) =~ s/%20/ /g; print "Now Playing $print_mp3\n"; `mpg123 -p none -b 500 -q $mp3`; } } } close INPUT;
In reply to The right way to avoid an error by diarmuid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |