in reply to grep problems and file copying issues

grep'll do what you want, in this case, but I would rather use a hash. (As your list of CDs grows, the grep operation will take longer, while a hash lookup will always take the same amount of time.)
my %dbfile = (); open DBFILE , "$dbFileName" or die $!; foreach (<DBFILE>) { $dbfile{$_} = 1; } close DBFILE; if (defined $dbfile{$cdLabel}) print "This CD ($cdLabel) is already in the database\n"; exit; }
Better way to do it.

Replies are listed 'Best First'.
RE: Re: grep problems and file copying issues
by ambiguous (Novice) on Jul 11, 2000 at 03:01 UTC
    Good answer. I'd just like to add don't forget that hash keys are case sensitive so be to lc() or uc() they keys when you populate and reference the hash. Also, depending on how/where the $cdLabel is populated, you should probably strip all leading and trailing white space, $cdLabel =~ s/^\s+//; $cdLabel =~ s/\s+$//; Hope that helps.