> 
> Your data is perfect for the paragraph mode* of readline:
> 
Ahh, I forgot about paragraph mode.

> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> my $user  = shift;
> my $regex = qr/\A$user/;
> 
> local $/ = '';
> while (my $record = <DATA>) {
>       chomp $record;
>       if ($record =~ /$regex/) {
>               print "$record\n";
>               last;

This didn't work at first.  Then I realized it was because the file's
lines were terminated with "\r\n" instead of just "\n".  Removing the
"\r" fixed the problem and it worked.

thanks for the help.



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to