On Sun, Apr 04, 2010 at 08:25:03AM -0700, Randal L. Schwartz wrote:
> >>>>> "Gary" == Gary Kline <kl...@thought.org> writes:
> 
> Gary> #!/usr/bin/perl
> Gary> $argc = @ARGV;
> Gary> if (! $argc ) {
> Gary>         printf("No args; need filename.\n");
> Gary> }
> Gary> else {
> Gary>         printf("%s\n", @ARGV);
> Gary> }
> 
> Even simpler:
> 
>     if (@ARGV) {
>       print "No args\n";
>     } else {
>       print "arg is $ARGV[0]\n";
>     }
> 
> If you're studying perl, you might want to join the very
> beginner-friendly mailing list, info at
> http://lists.perl.org/list/beginners.html, or start a conversation on
> perlmonks.org, also relatively beginner-friendly.
> 
> And I'd recommend a couple of good books, but I might be seen as
> self-pimping. :)


        hey man, pimp away!  we'll all learn a few tricks.  ---i had
        to teach myself perl around '96 and bought a couple books,
        one with a floppy full of short programs.  After doing a
        find . -name "*" -exec head -15 {} \; | more thru the
        truckload of these nifties, i finally came across the "$argc"
        idea.  

        there are around a dozen no-longer-throwaways that need the
        kind of no-arg tip just to make the scripts more user
        friendly.  even tho i'm the Only person who'll ever use them.

        ---Maybe you can clue me in on this one: around a dozen years
        ago i somw found a recursive grep named tgrep online. to save
        tying, i renamed it "rgr". i can start anywhere and 'rgr pattern'
        --WITHOUT ANY ASTERISK-- will find any pattern and skip
        binary or tarballs or compressed files.  given this, rgr has
        become my favorite utility, but since it doesn't have All of grep's
        options, yes, it's tru e, there are times whrn i have to use
        the real thing.   i have searched for tgrep and cannot find a
        newer more complete version.  would you or anyone reading
        this know where an upgraded version is?

        Here is the Usage string:


        p4 13:07 <tao> [5524] rgr
        Usage: tgrep [-iredblLnf] regexp filepat ...
               tgrep -h for help



        if not for trgep/rgr my shoulder would've fallen off and just
        laid on the floor; that's how much i use this script.  having
        the 'w' switch would be nice, so would the -N switch.  


> 
> But if you look at http://learn.perl.org/ you'll see a number of other
> resources, including free tutorials online.


        tx for the pointer;  i'll add it to my bookmarks. 

        gary



> 
> print "Just another Perl hacker,"; # the original
> 
> -- 
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
> See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
        http://jottings.thought.org   http://transfinite.thought.org
    The 7.79a release of Jottings: http://jottings.thought.org/index.php

_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to