Won't argue, but the better point from my perspective is remove any carriage
returns and/or linefeeds, so you when data does not match, it is because the
data is different.

Again, only my thoughts.

Wags ;)

-----Original Message-----
From: Jeff Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 18, 2001 13:47
To: Wagner-David
Cc: 'Jason Cruces'; [EMAIL PROTECTED]
Subject: RE: passing array values into a command string


On May 18, Wagner-David said:

>$_ will have the carriage return as part of the name, so should do a chomp
>before putting in the hash otherwise would have to have the carriage rturn
>as part of the testing process and I don't think you want that. So the line
>right after <NAME>, place a chomp.

I beg to differ.  Here is his code (simplified):

  open (NAMES, "<atts.txt") || die "cannot read atts.txt";
  $names{$_} = 1 while <NAMES>;
  close NAMES;

  open (COMS, "<commands.txt") || die "cannot read commands.txt";
  while (<COMS>) {
    print if $names{$_};
  }
  close COMS;

He does not chomp() the data coming from <NAMES>, so why should he
chomp() the data coming from <COMS>?

His code works perfectly when I tested it.  My guess is that one file has
\r's in it as well as \n's.  To that end, I suggest:

  s/\r$//, $names{$_} = 1 while <NAMES>;

and

  while (<COMS>) {
    print if s/\r$//, $names{$_};
  }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
** I need a publisher for my book "Learning Perl's Regular Expressions" **

Reply via email to