perlquestion
Lady_Aleena
<p>Hello. I've been stuck for over an hour now. I can't figure out how to get [mod://File::Grep]'s <c>fgrep</c> to return <c>chomp</c>ed values in its matches. I've tried <c>chomp</c>ing <c>$file</c>, <c>chomp</c>ing <c>$_</c> in the <c>fgrep</c>, and more. Am I using it wrong, not understand something in the module description, or just plain out of luck and have to munge the values of <c>matches</c> later?</p>
<code>
#!/usr/bin/perl
use strict;
use warnings;
use File::Grep qw(fgrep);
use Data::Dumper;
my @line = fgrep { /^[2-6] .+$/ } *DATA;
print Dumper(\@line);
__DATA__
2 foo
3 bar
4 baz
5 qux
6 quux
7 thingy
8 widget
</code>
<p>The output is</p>
<code>
$VAR1 = [
{
'filename' => *::DATA,
'count' => 5,
'matches' => {
'1' => '2 foo
',
'2' => '3 bar
',
'3' => '4 baz
',
'4' => '5 qux
',
'5' => '6 quux
'
}
}
];
</code>
<p>I'm at the end of my abilities.</p>
<div class="pmsig"><div class="pmsig-161890">
<div><strong><em>No matter how hysterical I get, my problems are not time sensitive. So, relax, have a [id://1026423|cookie], and a very nice day!</em></strong></div>
<div><em>Lady Aleena</em></div>
</div></div>