Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I install a few handy dandy widgets in my path. These include re and its inverted cousin re! so I have less typing! re! has 3 extra ! chars to invert the matches. Here is re.

[root@devel3 log]# cat /usr/bin/re #!/usr/bin/perl die " Usage re [RE] <optional filename/dirname> Full Perl grep on STDIN or filename Recursive if filename is a dir " unless @ARGV >= 1; my $re = qr/$ARGV[0]/; if ( $ARGV[1] ) { if ( -d $ARGV[1] ) { # we have a dir so let's recuse require File::Find; File::Find::find( \&grep_file, $ARGV[1] ); } else { open F, $ARGV[1] or die "Can't read $ARGV[1] $!\n"; do{print if m/$re/} while <F>; close F; } } else { do{print if m/$re/} while <STDIN>; } sub grep_file { return unless -f $_; open F, $_ or die "Can't read $File::Find::name $!\n"; my $matches = ''; do{$matches .= $_ if m/$re/} while <F>; print "$File::Find::name\n$matches" if $matches; close F; } [root@devel3 log]# re pri.. /usr/bin/re do{print if m/$re/} while <F>; do{print if m/$re/} while <STDIN>; print "$File::Find::name\n$matches" if $matches; [root@devel3 log]# cat /usr/bin/re | re [A-Z]+IN Full Perl grep on STDIN or filename do{print if m/$re/} while <STDIN>; [root@devel3 log]# cat /usr/bin/re | re "\b[A-Z]+\b" Usage re [RE] <optional filename/dirname> Full Perl grep on STDIN or filename " unless @ARGV >= 1; my $re = qr/$ARGV[0]/; if ( $ARGV[1] ) { [snip] [root@devel3 log]# re perl /devel/www/modperl /devel/www/modperl/ #!/usr/bin/perl -w /devel/www/modperl/ #!/usr/bin/perl -w /devel/www/modperl/ #!/usr/bin/perl -w [snip] [root@devel3 log]#




In reply to Re: Useful addition to Perl? by tachyon
in thread Useful addition to Perl? by tilly

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (5)
    As of 2018-07-16 22:44 GMT
    Find Nodes?
      Voting Booth?
      It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

      Results (352 votes). Check out past polls.