diarmuid has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: The right way to avoid an error
by DrZaius (Monk) on May 18, 2001 at 20:38 UTC | |
|
Re: The right way to avoid an error
by arturo (Vicar) on May 18, 2001 at 20:55 UTC | |
|
Re: The right way to avoid an error
by Asim (Hermit) on May 18, 2001 at 20:39 UTC | |
|
Re: The right way to avoid an error
by sierrathedog04 (Hermit) on May 18, 2001 at 23:39 UTC | |
|
Re: The right way to avoid an error
by AidanLee (Chaplain) on May 18, 2001 at 20:51 UTC | |
by diarmuid (Beadle) on May 18, 2001 at 21:17 UTC | |
|
Re: The right way to avoid an error
by AidanLee (Chaplain) on May 18, 2001 at 20:53 UTC |