perl limitations vs. bash?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl limitations vs. bash?
# 8  
Old 05-13-2010
Quote:
Originally Posted by m1xram
lol, Wikipedia. It "needs citation" because it is wrong.

The steeper the curve the more knowledge you get in less time. As the slope approaches infinity you instantaneously know more. Think Matrix upload to your brain.

I wish people would stop using this term, it's embarrassing.
m1xram, you are misunderstanding Wikipedia, I'm afraid.

The article/subsection I linked to says there are two interpretations of the term "steep learning curve". The first is yours, which says basically: "you can learn a lot about X quickly".

The second interpretation ( which is more common, and is how people usually use the phrase ) says basically: "how long until i get X mastered or mostly mastered or a real good grip on, etc.?".

In common parlance, people would say that the learning curve of Chess is much steeper than that of Checkers or Tic-Tac-Toe because there is more to learn about Chess, and much more to learn to "master" it.

The learning curve on the phrase "learning curve" is steeper than I had previously thought Smilie

Last edited by deindorfer; 05-13-2010 at 01:31 AM.. Reason: Text Edit
# 9  
Old 05-13-2010
I guess a practical example that I built in bash might help, it reads in a text file called ll a line at a time (with latitude/longitude) and finds nearest city and country code from the web.
Code:
cat "${@:-$ll}" |
        while read i
        do
                ref_num=$(($ref_num+1))
                lat=`echo $i | awk -F ';' '{print $1}'`
                lon=`echo $i | awk -F ';' '{print $2}'`
                url="http://ws.geonames.org/findNearbyPlaceName?lat=$lat&lng=$lon"
                                curl -s "$url" > xmlfile
                                city=`/usr/bin/xmlstarlet sel -t -m //geoname -v toponymName xmlfile`
                                country_code=`/usr/bin/xmlstarlet sel -t -m //geoname -v countryCode xmlfile`
                                mysql -u $USER_NAME --password=$PASSWORD -D "somedb" -e \
                                        "INSERT INTO somedb.sometable (id, ref_num, timestamp, lat, \
                                        lon, city, country_code) \
                                        VALUES (NULL,'$ref_num','$lat','$lon',\
                                        '$city','$country_code')";
        done

what kinds of things would I have to learn to build this in perl?
# 10  
Old 05-13-2010
Perl: XKCD Geohash Generator

Ever Read XKCD? Check this out: xkcd: Geohashing

here's a Perl Script that implements the algorithm in the comic:

Code:
#! /usr/bin/perl

use strict;
use warnings;

use LWP::Simple;
use URI::Escape;

use Finance::Quote;
use Digest::MD5;
use Math::BigInt;

my $begin_from = join '', @ARGV if @ARGV;

my $q = Finance::Quote->new;
my %dow = $q->fetch( 'nyse', '^DJI' );
my $hashthis = $dow{'^DJI', 'isodate'} . '-' . $dow{'^DJI', 'open'};
printf "DOWDATE: %s\n", $hashthis;

my $o = Digest::MD5->new;
$o->add( $hashthis );
my $hash = $o->hexdigest;
printf "MD5: %s\n", $hash;

my $x = '.' . substr ( Math::BigInt->from_hex ( '0x' . substr $hash, 0, 16), 0, 6);
my $y = '.' . substr ( Math::BigInt->from_hex ( '0x' . substr $hash, 16, 16), 0, 6);
my $addr = $begin_from || '100 S. Market St., Frederick MD';
$addr = uri_escape( $addr );
my $str = get( "http://rpc.geocoder.us/service/csv?address=$addr" );
( my $start_lat, my $start_long ) = split /,/, $str;
printf "START COORDS: %s %s\n", $start_lat, $start_long;

$start_lat =~ /(.+?)\..+$/; my $new_lat_pref = $1;
$start_long =~ /(.+?)\..+$/; my $new_long_pref = $1;
my $geohash = $new_lat_pref . $x . ' ' . $new_long_pref . $y;
printf "GEOHASH: %s\n", $geohash;

In addition to getting Lat-Long Coords, it also fetchs Real-Time Stock quotes, and runs some fairly solid crytpographic hashing algorithms....
This User Gave Thanks to deindorfer For This Post:
# 11  
Old 05-13-2010
Quote:
Originally Posted by unclecameron
1. Is there anything bash will do that perl won't?
Perl won't be usable as a login shell.
Quote:
2. How steep is the learning curve?
It's negative. The more you know, the more damage you do to your project overall productivity Smilie
Quote:
3. If perl's more powerful, why?
Depends on what power you measure.
Quote:
4. I've built a small app in python, which seemed nice, isn't there a wider support depth (i.e. example code, # of users)in perl than python?
Any other language is probably a better choice than Perl (ok, I'm too extreme here).
Quote:
5. I'm building mostly sysadmin scripts, if I were going to do more web integration (think php/javascript) with my code, would perl or python be easier to build, and which would be more powerful, or are they roughly the same?
php is fine. python would be easier to build than perl.
# 12  
Old 05-13-2010
Perl Complaints, No Substance

Quote:
Originally Posted by jlliagre
It's negative. The more you know, the more damage you do to your project overall productivity
Write my Geohash Code in Python in Fewer lines and/or so that it executes more quickly. and post please. No copying. The XKCD Geohash is a well known exercise, by now. and we will see. Where's you evidence for such grandiose and unfriendly statements.

You Just say "Perl Sucks" and repeat that 5 times, but don't give any examples; or rebuff any of the the actual specific strong points that three other posters listed here.

More over you general smugness towards Perl thumbs it's nose at literally tens of thousands of people who have added to the Perl extrodinary effort community. PHP and Ruby would not exist were it not for Perl. Perl was the first platform agnostic, run your code on anything byte machine and pioneered so much of what we expect from a high-level language today.

By the way you can make a Perl program your login shell. Just look on CPAN at the Term:: space, for one. /bin/plsh Smilie
# 13  
Old 05-14-2010
One of the plusses I saw for perl was the depth and breadth of perl code out there in the world, which must, one can surmise, account for its usefulness. I'm just trying to pick from python/perl now that I know it can do most of what I want it to do. It sounds like perl might be a little more versatile still (from what I'm hearing) for both scripting on up through web apps?
# 14  
Old 05-14-2010
Perl's Wonderful Versatility

Quote:
Originally Posted by unclecameron
It sounds like perl might be a little more versatile still (from what I'm hearing) for both scripting on up through web apps?
UncleCameron: Yes. This is an excellent point, and you stated clearly. One of the great advantages of Perl is that it can go toe-to-toe with awk and sed for command-line work; toe-to-toe with BASH/KSH/etc.. for system scripts; go toe-to-toe with PHP for web development; and go toe-to-toe with Python and even Java for Full-Fledged Systems Development.

That versatility is perhaps Perl's greatest strength. I can write any awk one-liner just as quickly and efficiently with perl. I can write a cronjob or the like just quickly and effciently as Shell. I can write a web app just as quickly and efficiently as PHP or Ruby. And I can even write very large scale systems stuff that will run with Java any day.

What other tool has such flexibilty? None. Detractors of Perl will say it tries to be everything and fails at each of it. They never seem to back it up. Perl One-Liners are ofter *better* than awk; perl scripts are almost always better than their BASH equivalent. Perl Web App are often better than their PHP or Python equivalents. etc. And there is massive proof for this.

Moreover. Perl has the most *dedicated and caring community* of all programming languages. As I mentioned before, no language has had as many smart and talented people give so much of their time willingly.

Perl 6 has struggled to say the least and went off track. Perl6 really *did* bite off a bit too much and has lacked a direction. We should all be running it now, in a perfect world. As a result Perl fell off in some important new areas of practical computing like MVC. Too many people care passionately about Perl to let this go on, and are working everyday to fix it.

Frankly, I am extremely disappointed with the moderator's post, in which he engaged in straight up "Linux vs. BSD vs. WIndows" type discussion with no substance and plenty of misplaced condescension. I hope his colleagues will give him a warning for a clear violation his own forum's rules Smilie

( I'm just sick to death of hearing Perl sucks and is useless; when it is runs a significant percent of the entire world's financial transactions. ) Barclays, BofA, Credit Suisse, and others all Use Perl; )
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Linux partitions and limitations

In recently reading an article on linux basics before I embark and my personal installation project I came across this passage - IDE drives have three types of partition: primary, logical, and extended. The partition table is located in the master boot record (MBR) of a disk. The MBR is the... (12 Replies)
Discussion started by: Synchlavier
12 Replies

2. Solaris

Solaris limitations

Hi, I recently started working with Solaris, and what I noticed is that a lot of commands I used to regularly use don't work, like sed -i and grep -r. I have found work arounds for these problems though but it's a pain in the ass. I'm just wondering why they decided not to include these handy... (4 Replies)
Discussion started by: Subbeh
4 Replies

3. Red Hat

Eth0 Limitations

Hi, I have noticed some performance issues on my RHEL5 server but the memory and CPU utilization on the box is fine. I have a 1G full duplexed eth0 card and I am suspicious that this may be causing the problem. My eth0 settings are as follows: Settings for eth0: Supported ports: ... (12 Replies)
Discussion started by: Duffs22
12 Replies

4. UNIX and Linux Applications

gnuplot limitations

I'm running a simulation (programmed in C) which makes calls to gnuplot periodically to plot data I have stored. First I open a pipe to gnuplot and set it to multiplot: FILE * pipe = popen("gnuplot", "w"); fprintf(pipe, "set multiplot\n"); fflush(pipe); (this pipe stays open until the... (0 Replies)
Discussion started by: sedavidw
0 Replies

5. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies

6. UNIX for Dummies Questions & Answers

Password limitations.

I would like to set my minimum password length to on Linux and AIX. However, doing this normally would only make it so newly added users will be affected by this. I would like for when I make this change, it either truncates everyone elses password, or prompts them to change it to 8+ characters.... (2 Replies)
Discussion started by: syndex
2 Replies

7. UNIX for Dummies Questions & Answers

csplit limitations

I am trying to use the csplit file on a file that contains records that have more than 2048 characters on a line. The resultant split file seems to ignore the rest of the line and I lose the data. Is there any way that csplit can handle record lengths greater than 2048? Thanks (0 Replies)
Discussion started by: ravagga
0 Replies

8. AIX

SORT Command Limitations

Hi every body, On AIX 4.3.3 what is the maximum file size that can be used with sort command? (0 Replies)
Discussion started by: aldowsary
0 Replies

9. UNIX for Dummies Questions & Answers

Unix Sort - Limitations

Hi All, I want to sort a flat file which will contain millions of records based on a key/field. For this I want to use unix sort command and before that I want to make sure that unix sort command has any file size limitations. And also please let me know whether I have to change any... (2 Replies)
Discussion started by: chprvkmr
2 Replies

10. UNIX for Dummies Questions & Answers

mkdir limitations

What characters can't be used with a mkdir? Any limits on length of name? Thank you, Randy M. Zeitman http://www.StoneRoseDesign.com (12 Replies)
Discussion started by: flignar
12 Replies
Login or Register to Ask a Question