[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] OFFTOPIC: Perl -w oddities?



	A few style suggestions first . . . :)

> open(TOC, "$CDA toc |");

Always check the return from open:

open( TOC, "$CDA toc |" ) 
  or die "Can't open pipe to `$CDA': $!";

> #Get headers
> $Catagory=<TOC>;
> chop($Catagory);

chomp just removes line ends (honouring $/).  chop blindly removes
the last character:

chomp( $Category );

> $TitleArtist=<TOC>;
> chop($TitleArtist);
> 
> $Trash=<TOC>;
> chop($Trash);

Same on chomp/chop goes for these two as well.

> while(<TOC>) {
>   chop;

chomp;

>   ($Spacer, $Track, $Len, $Name)=split(' ',$_);
>   $Trash=$Spacer;
>   $Trash=$Len;

Since you're apparently throwing away $Spacer and $Len, you probably
want to use either:

    ( undef, $Track, undef, $Name ) = split( ' ', $_, 4 );

or:

    ( $Track, $Name ) = (split( ' ', $_, 4 ))[1,3];

>   $Songs{"$Track"}="$Name";
> } 
> close(TOC);

	At any rate, judging from the debug output:

[...]
main::(./encodeit:44):    $Songs{"$Track"}="$Name";
  DB<1> s
[...]
Use of uninitialized value at ./encodeit line 44, <IN> chunk 51.
main::(./encodeit:39):  while(<TOC>) {
DB<1> 

	What it looks like is that either $Track or $Name isn't being
initialized.  You might check those variables in the debugger, or go
with the old standby:

print "\$Track `$Track'\t\$Name: `$Name'\n"
  if defined( $ENV{DEBUG} );

	And run your script:

DEBUG=1 perl myscript 

-- 
Fletch                |                                            __`'/|
fletch at phydeaux.org   |       "I drank what?" -- Socrates          \ o.O'
678 443-6239(w)       |                                            =(___)=
                      |                                               U