Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
So I got to looking at the first perl node that you mention... what an incredibly interesting piece of history! Larry pretty much had the right idea all along :) I however especially like his sample code:
#!/bin/perl $SIG{'QUIT'} = 'quit'; # install signal handler for SIGQUIT while ($ARGV[0] =~ /^-/) { # parse switches $ARGV[0] =~ /^-h/ && ($showhost++,$silent++,shift,next); $ARGV[0] =~ /^-s/ && ($silent++,shift,next); $ARGV[0] =~ /^-d/ && ($dodist++,shift,next); $ARGV[0] =~ /^-n/ && ($n=' -n',shift,next); $ARGV[0] =~ /^-l/ && ($l=' -l ' . $ARGV[1],shift,shift,next); last; } $systype = shift; # get name representing set of hosts while ($ARGV[0] =~ /^-/) { # we allow switches afterwards too $ARGV[0] =~ /^-h/ && ($showhost++,$silent++,shift,next); $ARGV[0] =~ /^-s/ && ($silent++,shift,next); $ARGV[0] =~ /^-d/ && ($dodist++,shift,next); $ARGV[0] =~ /^-n/ && ($n=' -n',shift,next); $ARGV[0] =~ /^-l/ && ($l=' -l ' . $ARGV[1],shift,shift,next); last; } if ($dodist) { # distribute input over all rshes? `cat >/tmp/gsh$$`; # get input into a handy place $dist = " </tmp/gsh$$"; # each rsh takes input from there } $cmd = join(' ',@ARGV); # remaining args constitute the com +mand $cmd =~ s/'/'"'"'/g; # quote any embedded single quotes open(ghosts, '/etc/ghosts') || die 'No /etc/ghosts file'; # /etc/ghosts drives the rest $one_of_these = ":$systype:"; # prepare to expand "macros" if ($systype =~ s/\+/[+]/g) { # we hope to end up with list of $one_of_these =~ s/\+/:/g; # colon separated attributes } line: while (<ghosts>) { # for each line of ghosts s/[ \t]*\n//; # trim leading whitespace if (!$_ || /^#/) { # skip blank line or comment next line; } if (/^([a-zA-Z_0-9]+)=(.+)/) { # a macro line? $name = $1; $repl = $2; $repl =~ s/\+/:/g; $one_of_these =~ s/:$name:/:$repl:/; # do expansion in "wanted" + list next line; } # we have a normal line @attr = split; # a list of attributes to match against # which we put into an array $host = $attr[0]; # the first attribute is the host nam +e if ($showhost) { $showhost = "$host:\t"; } attr: while ($attr = pop(attr)) { # iterate over gh arr +ay if (index($one_of_these,":$attr:") >=0) { # is host wanted? unless ($silent) { print "rsh $host$l$n '$cmd'\n"; } $SIG{'INT'} = 'DEFAULT'; if (open(pipe,"rsh $host$l$n '$cmd'$dist |")) { # start rsh $SIG{'INT'} = 'cont'; while (<pipe>) { print $showhost,$_; } # show results close(pipe); } else { $SIG{'INT'} = 'cont'; print "(Can't execute rsh.)\n"; } last attr; # don't select host twice } } } unlink "/tmp/gsh$$" if $dodist; # here are a couple of subroutines that serve as signal handlers sub cont { print "\rContinuing...\n"; } sub quit { $| = 1; print "\r"; $SIG{'INT'} = ''; kill 2, $$; }
:) I think it'd be fun to translate that to perl 5 (or 6 even) and use all of the new tools... funny thing is, that code would be chastized on perlmonks like crazy... no strict, no -w, handrolled commandline parsing! tsk tsk tsk. (I know that Perl back then didn't have these things, my sarcasm flag is set to 1 :) Also, a very interesting little historical sidenote:
I wasn't going to add a "goto" except that the sed-to-perl translator needed one.
:) how fun is that! Also of note: On top of which, C didn't have the picture-style report formats I wanted. And I didn't want to do a make every time I tweaked the program. I take it he is talking about perl formats... a feature that has now been voted out of the core and into a module (if memory serves me right...) So, I guess that says a few things about how perl has moved from a systems management / formatting language to a much more general beast. I guess he succeeded when he said he wanted to make a language that is: intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal).

In reply to Re: First Perl mention, was Re: First mention of Star Wars in Google by eduardo
in thread (Not Perl) First mention of Star Wars in Google by eduardo

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-03-28 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found