Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Print lines based on matching words

by ArifS (Beadle)
on Jul 11, 2016 at 13:10 UTC ( [id://1167555]=note: print w/replies, xml ) Need Help??


in reply to Re: Print lines based on matching words
in thread Print lines based on matching words

GrandFather, Your script is working just fine. I however am trying to take out the duplicate lines if exists above. I tried as following but giving me a hash error-
Original-
for my $list (@lists) { print $list->{line}; printGroups($list->{groups}, %group); print "\n"; }
with
sub uniq { my %seen; grep !$seen{$_}++, @_; } for my $list (@lists) { my @filtered = uniq(@lists); printGroups(@filtered->{groups}, %group); # prints acl lines AFTER object-groups print $list->{line}; print "line 54: ACL line\n\n"; }
Please let me know.

Replies are listed 'Best First'.
Re^3: Print lines based on matching words
by GrandFather (Saint) on Jul 11, 2016 at 21:09 UTC

    Add a minimum number of lines of code to initialize @lines with data built into the test code and ask again. I have no way of telling what the contents of @lines is, but it seems most likely it is an array of hash refs.

    Premature optimization is the root of all job security

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-18 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found