Created
          November 17, 2012 04:43 
        
      - 
      
- 
        Save nickanderson/4093338 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/perl | |
| # Author: Nick Anderson <nick@cmdln.org> | |
| # This is a nasty hacked up thing to locate and show bundles or bodies | |
| use strict; | |
| use warnings; | |
| use Term::ANSIColor; | |
| my $body_or_bundle=$ARGV[0]; | |
| my $search_path=$ARGV[1]; | |
| my (@results) = `find $search_path -name "*.cf" | xargs grep -nP "(body|bundle)\\s.*\\s$body_or_bundle"`; | |
| foreach my $result (@results) { | |
| my (@file) = split(':', $result); | |
| print color("red")."definition for $body_or_bundle found in $file[0] on line $file[1]\n\n".color("reset"); | |
| undef $/; # Enable 'slurp' mode | |
| open (FILE, '<', "$file[0]") or die "Could not open $file[0]: $!"; | |
| my $filea = <FILE>; # Whole file here now... | |
| my ($stuff_that_interests_me) = ($filea =~ m/((body|bundle)\s+\w+\b\s$body_or_bundle.*?)(body|bundle)\s.*/s); | |
| print color("green")."$stuff_that_interests_me".color("reset"); | |
| close (FILE) or die "Could not close $file[0]: $!"; | |
| } | |
| #print $results[0]; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment