Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Can figure out a way to get File::Grep's fgrep to chomp matches

by Your Mother (Bishop)
on May 14, 2017 at 00:14 UTC ( #1190245=note: print w/replies, xml ) Need Help??


in reply to Re^2: Can figure out a way to get File::Grep's fgrep to chomp matches
in thread Can figure out a way to get File::Grep's fgrep to chomp matches

chomp doesn’t return quite like that. This should work–

my @line = map { chomp; $_ } fgrep { /^[2-6] .+$/ } *DATA;

But maybe this is better–

chomp( my @line = fgrep { /^[2-6] .+$/ } *DATA );

Replies are listed 'Best First'.
Re^4: Can figure out a way to get File::Grep's fgrep to chomp matches
by Lady_Aleena (Curate) on May 14, 2017 at 00:19 UTC

    Here is what your suggestion returned...

    $VAR1 = [ { 'count' => 5, 'matches' => { '3' => '4 baz ', '5' => '6 quux ', '2' => '3 bar ', '4' => '5 qux ', '1' => '2 foo ' }, 'filename' => *::DATA } ];

    I am beginning to believe this module is not set up for chomping the matches until they are munged later. The reason I even started this was that the dumper data looks bad with the newlines in the data.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1190245]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2019-09-20 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (268 votes). Check out past polls.

    Notices?