J
Josef Moellers
Hi,
I am trying to escape spaces but apparently get into a naming conflict:
#! /usr/bin/perl
use warnings;
use strict;
open(OGG, "ogginfo \"$ARGV[0]\" |") or die "$0: cannot open $ARGV[0]\n";
while (<OGG>) {
last if /^User comments section follows/;
}
while (<OGG>) {
chomp;
if (/^\s+title=(.*)/) {
my $title = $1;
$title =~ s/\s/\\$1/g;
print " --tt $title";
next;
}
if (/^\s+artist=(.*)/) {
my $artist = $1;
$artist =~ s/\s/\\$1/g;
print " --ta $artist";
next;
}
}
close OGG;
exit 0;
If the artist or title name contains spaces, I get the error message
Use of uninitialized value in concatenation (.) or string at ./xinfo
line 14, <OGG> line 14.
once for each space.
I assume this is due to the fact that $1 is defined when the substitute
is compiled.
How can I do the substiture?
Josef
I am trying to escape spaces but apparently get into a naming conflict:
#! /usr/bin/perl
use warnings;
use strict;
open(OGG, "ogginfo \"$ARGV[0]\" |") or die "$0: cannot open $ARGV[0]\n";
while (<OGG>) {
last if /^User comments section follows/;
}
while (<OGG>) {
chomp;
if (/^\s+title=(.*)/) {
my $title = $1;
$title =~ s/\s/\\$1/g;
print " --tt $title";
next;
}
if (/^\s+artist=(.*)/) {
my $artist = $1;
$artist =~ s/\s/\\$1/g;
print " --ta $artist";
next;
}
}
close OGG;
exit 0;
If the artist or title name contains spaces, I get the error message
Use of uninitialized value in concatenation (.) or string at ./xinfo
line 14, <OGG> line 14.
once for each space.
I assume this is due to the fact that $1 is defined when the substitute
is compiled.
How can I do the substiture?
Josef