[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



sub ping($$) { 
  my ($IP, $tries) = @_;
  my $resp = undef;
  my $max = ($tries ? $tries : 2);
  
  
  for(my $x = 0; $x < $max; $x++) {
    open(OUT, "ping -c 1 $IP |");
    while(<OUT>) {
      next unless  m/(\d+)\sreceived/;
      $resp = $1;
      _print(sprintf("Try: %d/%d Resp: %d\n", ($x+1), $max, $resp));
    }
    close(OUT);
    if($resp) {
      $x = $max;
    } else {
    }
  }

  return $resp;
}

All the function does is test to see if a host is up.  IF not it then
reports and error to a user using Net::SMTP.  Is there an equivalent in
Pyton?  If not I could simply roll my own using sockets.

On Wed, 2005-01-26 at 12:12, Benjamin Scherrey wrote:
> uh... read it again six months after you wrote it and understand what 
> the heck it does? :)
> 
>     Perl really does excel as a scripting language for processing files 
> of text, especially using regular expressions. That's its original 
> purpose and, sticking to that scope, I couldn't argue conclusively for 
> another language over it. However, python and ruby, while perhaps 
> introduced as scripting languages, are really full fledged and elegant 
> high level application development languages that are purposely written 
> to develop complex and powerful applications beyond scripts and admin 
> tasks. Perl has a gazzillion majic symbols that one must remember to do 
> anything complex with and there are more (correct!) ways to approach a 
> given task than there are perl programmers so consistency of code 
> amongst a group of programmers (even with the group size==1!) is almost 
> never found. Even in respect to its regular expression abilities, the 
> new version of python is as expressive and as efficient so, in the area 
> where perl once stood above all others, it has not maintained its dominance.
> 
>     Without trying to engage in a language war I think the question you 
> pose is not the right one. Given enough mastery of any given programming 
> language I could make the same assertion of being capable of 
> accomplishing almost any task. Does that mean all languages are equally 
> functional or expressive? Certainly not. It really should be which 
> language is the right tool for a particular job. Perl was designed for a 
> particular job and does it well. Outside of that scope, however, perl 
> shows its shortcomings pretty rapidly. Just because something *can* be 
> done using a given language doesn't mean its a good idea.
> 
>     For me, C++ and python cover the full breath of any programming 
> project I've ever encountered or conceived of. Yet, to this day, each 
> time I approach a new programming task I always try to identify what 
> languages are best suited for that task if only to identify what idioms 
> or patterns might best be used to attack the problem at hand. Each 
> language has its own particular idioms that drive its best use and can 
> teach us things about problem solving even when we may not end up using 
> that particular language in the final solution. That is why one should 
> learn as many languages as one can - it makes you more expressive.
> 
>     -- Ben Scherrey
> 
> Christopher Fowler wrote:
> 
> >I'm finding that I can accomplish almost any task in Perl that I want. 
> >Only problem is that it is not fully OOP.  Other than OOP what can you
> >do in say Ruby or Python that you can not do in Perl?
> >
> >  
> >


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="01215" href="msg01215.html">[ale] Py[h]hon syntax (sic)</a></strong>
<ul><li><em>From:</em> jpheale at LearnLink.Emory.Edu (John P. Healey)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="01121" href="msg01121.html">[ale] Pyhon syntax</a></strong>
<ul><li><em>From:</em> fletch at phydeaux.org (fletch at phydeaux.org)</li></ul></li>
<li><strong><a name="01129" href="msg01129.html">[ale] Pyhon syntax</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
<li><strong><a name="01133" href="msg01133.html">[ale] Py[h]hon syntax (sic)</a></strong>
<ul><li><em>From:</em> scherrey at proteus-tech.com (Benjamin Scherrey)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg01206.html">[ale] OT: Scrum and Extended Development</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg01208.html">[ale] Getting Linux OS to boot</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg01139.html">[ale] Py[h]hon syntax (sic)</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg01215.html">[ale] Py[h]hon syntax (sic)</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#01207"><strong>Date</strong></a></li>
<li><a href="threads.html#01207"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>