• ItsNotMe (unregistered) in reply to diaphanein
    diaphanein:
    And besides, I got laid at the whorehouse, and it only cost me $5. Granted, she only had 1 tooth left...

    Before or after? No, don't answer that. It just had to be said.

  • Anonymous Coward (unregistered) in reply to lurkee-lurk
    lurkee-lurk:
    It's called the possessive case. Back to middle school for the Gramma Police.

    However, "it's" is shorthand for "it is", while the possessive case is written "its". It's one of the many little quirks of the English language. I would guess (not being one) that this is one of the things a native speaker would learn in elementary school.

  • ItsNotMe (unregistered) in reply to Anonymous Coward
    Anonymous Coward:
    lurkee-lurk:
    It's called the possessive case. Back to middle school for the Gramma Police.

    However, "it's" is shorthand for "it is", while the possessive case is written "its". It's one of the many little quirks of the English language. I would guess (not being one) that this is one of the things a native speaker would learn in elementary school.

    Not anymore. :(

    Doom. How apropos. Bwahahahaha

  • Will (unregistered) in reply to PseudoNoise
    PseudoNoise:
    lurkee-lurk:
    Nah:
    Axit:
    jtwine:
    >That is the beauty of C++ - you get C's stuff with it. :)
    And by far it's greatest weakness.

    The RWTF is not knowing the difference between "it's" and "its".

    It's called the possessive case. Back to middle school for the Gramma Police.

    Possessive pronouns never use an apostrophe: its, hers, his, ours, theirs, ones.

    It's (i.e., "it is") not rocket science.

    Possibly it does have some element of rocket science in it, since a reasonably intelligent person such as you is unaware that "one's" does have an apostrophe in it.

  • Michael (unregistered) in reply to gilleain
    gilleain:
    Considering the alternatives (shell scripting, sed, and awk) Perl sucks the least!

    Ha! I want that on a t-shirt - "If you look at the alternatives, I suck the least!" :)

    Don't bother making that in women's sizes.

  • Nomen Nescio (unregistered) in reply to mkb
    mkb:
    The only one that comes close is Python, which isn't any more maintainable or readable than Perl.

    ok, thanks a lot. now the cognitive dissonance is going to have me boggle-eyed and slack-jawed all day.

    • N.N., professionally Perl-coding Pythonista
  • Xaroth (unregistered) in reply to Anonymous Coward
    Anonymous Coward:
    lurkee-lurk:
    It's called the possessive case. Back to middle school for the Gramma Police.

    However, "it's" is shorthand for "it is", while the possessive case is written "its". It's one of the many little quirks of the English language. I would guess (not being one) that this is one of the things a native speaker would learn in elementary school.

    Just remember Strong Bad's song!

    o/~ Oh, if it's supposed to be posessive, then it's just i-t-s/But, if it's supposed to be a contraction then it's i-t-apostrophe-s! Scalawag! o/~

  • Tyler (unregistered) in reply to TheRealBill
    TheRealBill:
    Tyler:

    You would not have to guess. You would read "perlfunc", which is the Perl function list, and you would find it under "Functions for filehandles, files, or directories".

    Gee that's hard.

    Yup cuz we all know that beginners intuitively know to take the name of the programming language, tack on "func" and answer their questions. Heck, it's something that come sin real handy when doing anything else.

    Wait you mean that there is no "cfunc", "pythonfunc", "bashfunc", "lispfunc", etc? Oh, well then maybe it is something only an experienced or trained perler would reactively know. (That or someone who spent time googling and searching so they could post it and appear to be knowledgeable.)

    This problem isn't specific to Perl or any language, it's a hindsight or familiarity problem. But seriously I've not yet met anyone who not having used it a lot needed a Perl (Python, PHP, bash, ksh, scheme, lisp...) question related to functions and thought "I know, I'll try to combine the name of the language with the first 4 letters of the word function and look there!"

    If you didn't know about perlfunc, you could read the perl man page, which directs you to many resources including perlfunc. If you didn't know about the man page, you could read the perl FAQ which directs you to the man page, as well as the perldoc perl page in case you don't have man installed. (The perldoc perl page also directs you to perlfunc.)

    So yeah, if you're just blindly hammering on the keyboard, you're not going to find the reference material you need, but if you have 12 seconds to look for the information in one of several different ways, you'll find what you need.

    Or you can be a copy/paste cargo cult programmer, and end up featured on this site.

  • (cs) in reply to Smitty
    Smitty:
    Oh, I get it, that's what makes perl so 'powerful', it's non-intuitive use of shorthand whenever and wherever possible.

    How would one EVER guess that the supplied code solved that problem. Where would you look to find the '-s' operator (or whatever perl twinks call it.)

    What the hell is wrong with

    $filesize = size_on_disk(filename); or some equally intuitive and easily remembered (or guessed) function name?

    perl sucks - get over it.

    your_prompt> perldoc -f -s

        -X FILEHANDLE
        -X EXPR
        -X      A file test, where X is one of the letters listed below. This
                unary operator takes one argument, either a filename or a...
    

    HTH

  • mathew (unregistered)

    ObRuby:

    mysize = File.new(filename).stat.size

    I gave up Perl for Ruby. It's worth the performance drop to be able to avoid Perl syntax, and the performance thing will be addressed in 1.9 anyway...

  • (cs) in reply to Hey Nonny Mouse
    Hey Nonny Mouse:
    Of course you can connect an InputStream to an OutputStream.

    Just do it like this:

    public class IOStream implements Runnable {
      private InputStream in;
      private OutputStream out;
      public IOStream(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
      }
    
      public void run() {
        byte[] buff = new byte[4096];
        int got;
        while ((got = in.read(buff)) > 0)
          out.write(buff, 0, got);
      }
    }
    
    new IOStream(in,out).run();
    

    First of all, by using >0 instead of >=0, you make this class worthless with streams that are open and still transmitting data -- network streams, for example. Second, you miss entirely the point that this still requires you to copy the bytes into memory and then write them. Java provides four gazillion classes, and they don't have one to abstract this process for the programmer?

    Ben:
    PipedInputStream and PipedOutputStream may help here. Not used them yet (but am about to in a project coming up). From Java in a Nutshell:

    PipedInputStream

    This class is an InputStream that implements one half of a pipe and is useful for communication between threads.... ... Data read from a PipedInputStream object is recieved from the PipedOutputStream to which it is connected ...

    • ducks, preparing for the inevitable Java guru discourse on why not to use this class ever *
    Those classes work in the opposite direction than you typically want. Normally you're looking to take something from an InputStream, and put it out to an OutputStream. These classes take everything written to the output and provide it to the input. Also, if you use them both in a single thread, you could make the entire universe collapse on itself. Or maybe you'll just deadlock your thread; I don't know, I stopped paying attention.
  • (cs) in reply to TheRealBill
    TheRealBill:
    Yup cuz we all know that beginners intuitively know to take the name of the programming language, tack on "func" and answer their questions. Heck, it's something that come sin real handy when doing anything else.

    http://www.perl.org/ links to Online Documentation, and to FAQs. Perhaps from the FAQ page you could learn about perlfaq2: Obtaining and Learning about Perl and ask Where can I get information on Perl?. It would tell you about http://perldoc.perl.org/, among other things. And if you have a copy of the Llama book or the Camel book from O'Reilly, you'll find some assistance there as well. And if you read 'man perl', it says

    If you’re new to Perl, you should start with perlintro, which is a general intro for beginners and provides some background to help you navigate the rest of Perl’s extensive documentation.
    and then presents you with an index to a variety of topics, including perlfunc.

    Now, I realize that there are a variety of valid complaints against Perl, but a) you honestly cannot expect to be able to sit down in front of a programming language and know everything you need to know in five minutes, so you should expect a need to consult with at least minimal documentation, and b) there are a wide variety of ways to stumble upon the proper documentation. I have no respect for programmers who would claim that this is an undue burden upon them.

  • FooBar (unregistered) in reply to Smitty
    Smitty:

    What the hell is wrong with

    $filesize = size_on_disk(filename); or some equally intuitive and easily remembered (or guessed) function name ?

    perl sucks - get over it.

    that's called PHP -- and if you want to talk about what sucks, go look at the PHP ref docs for a while. Bottom line, if you're going to write in any language, at least have the decency to scan a language reference to get a feel for the types of functions, operators, etc.

  • (cs) in reply to mathew
    mathew:
    ObRuby:

    mysize = File.new(filename).stat.size

    I gave up Perl for Ruby. It's worth the performance drop to be able to avoid Perl syntax, and the performance thing will be addressed in 1.9 anyway...

    That's what they keep telling us. "Wait for 1.9! It'll be faster! It'll solve world hunger! It'll run on Parrot or JVM, be powered by the wind, and heal leprosy!" I might have made up some of those claims.

  • (cs) in reply to fennec
    fennec:
    TheRealBill:
    Yup cuz we all know that beginners intuitively know to take the name of the programming language, tack on "func" and answer their questions. Heck, it's something that come sin real handy when doing anything else.

    http://www.perl.org/ links to Online Documentation, and to FAQs. Perhaps from the FAQ page you could learn about perlfaq2: Obtaining and Learning about Perl and ask Where can I get information on Perl?. It would tell you about http://perldoc.perl.org/, among other things. And if you have a copy of the Llama book or the Camel book from O'Reilly, you'll find some assistance there as well. And if you read 'man perl', it says

    If you’re new to Perl, you should start with perlintro, which is a general intro for beginners and provides some background to help you navigate the rest of Perl’s extensive documentation.
    Either way, you will eventually find yourself presented with a list of topics, including perlfunc.

    Now, I realize that there are a variety of valid complaints against Perl, but a) you honestly cannot expect to be able to sit down in front of a programming language and know everything you need to know in five minutes, so you should expect a need to consult with at least minimal documentation, and b) there are a wide variety of ways to stumble upon the proper documentation. I have no respect for programmers who would claim that this is an undue burden upon them.

    As I mentioned before, one of the great things about Perl is that you can learn so much of the language simply by reading all the man pages. That's not common.

  • (cs) in reply to savar
    savar:
    gilleain:
    edit : also, as for the timing - 75 mins is quite a big improvement no matter how long the program takes. I mean no program is going to take 20,000 hours is it? So 75 mins must be quite a chunk of time.

    Even if the program takes 24 hours to run, 75 minutes is still a huge improvement. If it takes more than 24 hours to run...why are they using Perl?

    Of course, they must be making a ton of file size calculations in that time to make the change that significant. If the piped method takes .01 seconds (which is a drastic overestimate), and the perl "-s" method returns instantly, then 75 minutes difference means they looked up a file size 450,000 times while executing this perl script.

    It was probably using network files, in which case .01 seconds is an extremely optimistic value. .1 s to 2s, depending on the network, just to get a stat back, and potentially any amount of time to read the file with wc.

    Otherwise, it had to be a backup script to be statting that many files at once.

  • Dave B (unregistered) in reply to Nex

    It's wide use does not mean that it doesn't suck. It's wide use is because it's been around for long enough, and prior to better languages that have come along since.

    So, just 'cause it's used on X number of web sites, does NOT mean you should use it for yours.

  • (cs) in reply to FridayUK
    FridayUK:

    I'm surprised at the number of obnoxious comments like your though, I think some people are unable to be objective about it, which is pretty pathetic really (it's just a scripting language, and an increasily creaky one at that). ...

    Not true. Perl is a language that supports scripting, true. It does not impose scripting.

    I have Perl programs that run to the thousands of lines, in which there are fewer than 10 lines in the global namespace [things like use directives], and no single sub that can not be viewed in its entirety in a single screen.

    It's not the tool, it's the design decisions made by those using the tool.

  • dnm (unregistered)

    rjnewton wins this thread.

    The end.

  • Franz Kafka (unregistered) in reply to savar
    savar:

    Even if the program takes 24 hours to run, 75 minutes is still a huge improvement. If it takes more than 24 hours to run...why are they using Perl?

    What's wrong with a 24 hour perl script run? If it's doing a lot of IO (like reading the whole file and flushing the cache in order to get its size), then going to C won't be much faster.

    savar:
    Of course, they must be making a *ton* of file size calculations in that time to make the change that significant. If the piped method takes .01 seconds (which is a drastic overestimate), and the perl "-s" method returns instantly, then 75 minutes difference means they looked up a file size 450,000 times while executing this perl script.

    for a 2G file, the piped command could take 10-20 seconds to complete. 500 calls to it = about 75 minutes.

  • Anonymous (unregistered) in reply to DocJowles
    DocJowles:
    I also like that the original code doesn't even work for files less than ~ 1 meg. Take "crap.txt", a roughly 5kb text file:
    wc -c crap.txt | cut -c0-8 | sed 's/ //g';

    9112cra

    WTF, indeed.

    This is actually fine, because when "9112cra" is interpreted in a numeric context, the letters will be dropped. It's only a problem if your filename begins with digits or the letter 'e', and since no one ever does that, there can't possibly be any problem. :D

  • (cs) in reply to bstorer
    bstorer:
    Hey Nonny Mouse:
    Of course you can connect an InputStream to an OutputStream.

    Just do it like this:

    public class IOStream implements Runnable {
      private InputStream in;
      private OutputStream out;
      public IOStream(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
      }
    
      public void run() {
        byte[] buff = new byte[4096];
        int got;
        while ((got = in.read(buff)) > 0)
          out.write(buff, 0, got);
      }
    }
    
    new IOStream(in,out).run();
    

    First of all, by using >0 instead of >=0, you make this class worthless with streams that are open and still transmitting data -- network streams, for example. Second, you miss entirely the point that this still requires you to copy the bytes into memory and then write them. Java provides four gazillion classes, and they don't have one to abstract this process for the programmer?

    Bzzzt. Sorry, try again:

    JavaDocs for read():
    If no byte is available because the stream is at the end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

    If reading from a network socket which does not have any data available, read() will block.

  • (cs) in reply to Hawk777
    Hawk777:
    bstorer:
    Hey Nonny Mouse:
    Of course you can connect an InputStream to an OutputStream.

    Just do it like this:

    public class IOStream implements Runnable {
      private InputStream in;
      private OutputStream out;
      public IOStream(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
      }
    
      public void run() {
        byte[] buff = new byte[4096];
        int got;
        while ((got = in.read(buff)) > 0)
          out.write(buff, 0, got);
      }
    }
    
    new IOStream(in,out).run();
    

    First of all, by using >0 instead of >=0, you make this class worthless with streams that are open and still transmitting data -- network streams, for example. Second, you miss entirely the point that this still requires you to copy the bytes into memory and then write them. Java provides four gazillion classes, and they don't have one to abstract this process for the programmer?

    Bzzzt. Sorry, try again:

    JavaDocs for read():
    If no byte is available because the stream is at the end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

    If reading from a network socket which does not have any data available, read() will block.

    You're right. I'm thinking of SocketChannel's read, not InputStream's.

  • NJAPH (unregistered) in reply to Steve
    Steve:
    It's not as if we weren't all newbies at one time in our lives. Perhaps some of use learned Perl and C++ at our father's knee but many of use came to these things later along in life.
    Yes. I, for example, only learned Perl about two months ago. It took me three days to learn, and after those three days were over I was writing relatively-idiomatic Perl code in an altogether WTF-free manner.

    The secret? I'm smart enough to know that I don't know everything, so I, uh, read the fucking manual instead of jumping in and assuming I would know how to do everything without having to learn.

    I think that gives me the right to sneer.

  • Ruby ate my puppy (unregistered) in reply to mathew
    mathew:
    ObRuby:

    mysize = File.new(filename).stat.size

    This is supposed to be more intuitive? Do you really believe "stat" is more transparent to the average newbie than "-s" is?

    I gave up Perl for Ruby.

    That's like giving up herpes for rabies.

    It's worth the performance drop to be able to avoid Perl syntax

    I tried Ruby once, and liked the syntax even less than Perl's. Pretending that everything should be an object is stupid - numbers are abstract concepts, not objects. And treating things like string literals as objects is just plain ugly.

  • (cs) in reply to gilleain
    gilleain:
    edit : also, as for the timing - 75 mins is quite a big improvement no matter how long the program takes. I mean no program is going to take 20,000 hours is it? So 75 mins must be quite a chunk of time.

    I've got a password cracker that will take just shy of 14 months to exhaust all reasonable passwords for older *nix systems. Would you consider a 75-minute speedup to be worthwhile?

  • fleischdot (unregistered) in reply to Russ
    Russ:
    It never ceases to amaze me how many people don't know the constructs that are available to them in the programming language and are too lazy to google what they need.

    Edit: fist

    No, you'll have to read a real manual - especially for perl. If you try to google for it, you'll end up with answers from a bunch of wannabe's saying "I know the answer to this problem, but it's way below my skills to give you the answer." or "I found this problem solved after 2 sleepless weeks, and I'm not going to give you the answer such quick" ...

    I call such boardmembers of any programming board or even newsgroup the RTFM BASTARDS ;) ... They'll never give you any helpful answer.

    BTW. I'm always wondering about the energy such BASTARDS invest to write lengthy articles why not to give the answer ...

  • (cs) in reply to fleischdot
    fleischdot:
    Russ:
    It never ceases to amaze me how many people don't know the constructs that are available to them in the programming language and are too lazy to google what they need.

    Edit: fist

    No, you'll have to read a real manual - especially for perl. If you try to google for it, you'll end up with answers from a bunch of wannabe's saying "I know the answer to this problem, but it's way below my skills to give you the answer." or "I found this problem solved after 2 sleepless weeks, and I'm not going to give you the answer such quick" ...

    I call such boardmembers of any programming board or even newsgroup the RTFM BASTARDS ;) ... They'll never give you any helpful answer.

    BTW. I'm always wondering about the energy such BASTARDS invest to write lengthy articles why not to give the answer ...

    http://www.google.com/search?q=perl+file+size&num=1

    Lurk moar.

  • Dubu (unregistered) in reply to mathew

    Well, as mentioned before, with Perl and File::stat you could write

    $mysize = stat($filename)->size

    and that looks quote similar to your code. OTOH, in Ruby you could also do it like this:

    mysize = test(?s, filename)

  • Billco (unregistered)

    This is proof that programmers should be shot on sight, and the ones who survive should be promoted to super-geekdom. Too many "programmers" are just imbeciles who read the first chapter of "Sams Teach yourself Minesweeper in 24 hours" and got their certificate. Any half-wit with any experience using ANY language would look for a file size function as one of the first steps of learning a new language. Frig even MS Batch files can fetch the file size, how ghetto is that ?

  • Michael G. (unregistered) in reply to Smitty
    Smitty:
    Oh, I get it, that's what makes perl so 'powerful', it's non-intuitive use of shorthand whenever and wherever possible.

    How would one EVER guess that the supplied code solved that problem. Where would you look to find the '-s' operator (or whatever perl twinks call it.)

    What the hell is wrong with

    $filesize = size_on_disk(filename); or some equally intuitive and easily remembered (or guessed) function name ?

    perl sucks - get over it.

    Some of Perl's shortcut test operators evolved from shell test operators and the test command.

    And, if you prefer a more verbose way, someone has already mentioned that you can use the stat function.

    What the hell is wrong with being concise, anyway? It's not my problem that you can't read it and can't take the time to learn.

  • Michael G. (unregistered) in reply to DocJowles
    DocJowles:
    I also like that the original code doesn't even work for files less than ~ 1 meg. Take "crap.txt", a roughly 5kb text file:
    wc -c crap.txt | cut -c0-8 | sed 's/ //g';

    9112cra

    WTF, indeed.

    Actually, it won't work for file sizes over 8 digits.

    Perl will happily turn "9112cra" into the number 9112 as soon as you try to do a numeric operation on it. Don't believe me, try this:

    perl -e 'print "9112cra" + 888;'

    or

    perl -e 'print "9112cra" == 9112 ? "true\n" : "false\n";'

    There are also several versions of wc out there. The one included with Solaris 10 puts the number in an 8-character field padded with spaces (if it <= 8 digits). Thus for any file with a size <= 8 digits work perfectly with this particular wc.

  • Tyler (unregistered) in reply to Irrelevant
    Irrelevant:
    fleischdot:
    Russ:
    It never ceases to amaze me how many people don't know the constructs that are available to them in the programming language and are too lazy to google what they need.

    Edit: fist

    No, you'll have to read a real manual - especially for perl. If you try to google for it, you'll end up with answers from a bunch of wannabe's saying "I know the answer to this problem, but it's way below my skills to give you the answer." or "I found this problem solved after 2 sleepless weeks, and I'm not going to give you the answer such quick" ...

    I call such boardmembers of any programming board or even newsgroup the RTFM BASTARDS ;) ... They'll never give you any helpful answer.

    BTW. I'm always wondering about the energy such BASTARDS invest to write lengthy articles why not to give the answer ...

    http://www.google.com/search?q=perl+file+size&num=1

    Lurk moar.

    So what you're saying is that a reasonable search query turned up not one but two ways to do it on the very first result, plus it has the exact perldoc commands you should type if you want more information.

    OMG PERL IS HARD LIEK U CANT GUESS THE FNUCTIONS PERL IS THE REAL WTF

  • choy (unregistered)

    perl inexperience is beside the point. the code is bad in any language.

    a coder's inner "ridiculously inefficient" alarms should go off when they see this kind of code. O(n^2) alarms. alarms that tell you that this only ok if you do it once in a while.

    even if the coder was using bash, he'd have to sense the evil caused by this piece of code. somewhere deep in his gut, some voice should be telling him, "there has got to be a better way."

    The multiplication of the code indicates that the coder had no idea what the runtime cost of this code was. or perhaps didn't care.

  • koni (unregistered) in reply to mkb

    [snip] diaphanein: If that's the only set you consider, then yes. There are (other) scripting languages that don't suck, that aren't cryptic, that don't inherently lend themselves unreadable, unmaintainable code.

    Sure, but do they have the advantages perl has? -regular expressions -C-like syntax for easy adoption -large user base -large installed base on random machines

    The only one that comes close is Python, which isn't any more maintainable or readable than Perl.

    I've been programming in Perl for close to 10 years and I have yet to see code that I can't read except for an obfuscation contest.

    [/snip]

    I agree. If you take the time to LEARN how to use a language, it is not "mysterious" or "non-intuitave" to use. It is only difficult to read or maintain if you are a "one language wonder" and the language you know is not the one in use...

  • Paolone (unregistered) in reply to mkb

    That, and CPAN.

  • (cs)

    PERL...

    The problem I have with perl is that its conciseness is confusing. If I needed to edit perl on a daily or even weekly basis, I might look into 'just finding the documentation' and then reading it, rereading it, trying it, failing, and trying again to understand what it's supposed to be doing. So, for me, it's not a problem of finding how to write something (I can do that!) but a problem of trying to decipher what others' 'simply concise' code actually means.

    So: writing in perl...easy reading perl...difficult maintaining perl...can be really difficult or really easy!

    Oh, on an aside: I hate Python.

  • viking (unregistered) in reply to dnm
    dnm:
    I work with people who to this day think the best way to get the system time in perl is:
    $date = `date +%Y%m%d`;
    chop $date;
    

    I confess to using that. Not because I think that it's the best way,but because it's quicker to type than using perl's built-in. However, I wouldn't use it on a production system.

  • fhfdh (unregistered)

    www.yalla-casablanca.com

  • Alex (unregistered) in reply to TheD
    TheD:
    For example, I've spent a lot of time with (and enjoy working with) PHP. Everyone knows how badly that sucks (just check out then function names. WTF?!) but there are a large number of big sites that use it....

    PHP sucks for some reasons but its popularity is not hard to understand ... a PHP application is easy to deploy (easier than with Perl, Python, Java, whatever), it is cheap to deploy because of PHP's nature (compared to Java and .NET which are quite expensive), the PHP interpreter has a reasonable speed, it can be easily extended by C modules ... thus it can connect to a wide variety of services, there are countless of open-source applications and framerworks already built for it ... and put simply ... It Gets The Job Done in most cases.

    PHP is quite a mature, stable and robust platform for web apps ... and if you can't see that from your ivory tower that doesn't mean the rest of us are blind too.

  • (cs) in reply to viking
    viking:
    dnm:
    I work with people who to this day think the best way to get the system time in perl is:
    $date = `date +%Y%m%d`;
    chop $date;
    

    I confess to using that. Not because I think that it's the best way,but because it's quicker to type than using perl's built-in. However, I wouldn't use it on a production system.

    use POSIX qw(strftime);
    $date = strftime "%Y%m%d", localtime; # or gmtime, if you'd rather

    Admittedly, I did have to do a bit of digging to locate strftime() the first time I wanted it, but I wouldn't consider it that much slower to type... I guess having to add the use() to your preamble makes it forgivable. ;]

    But not, as you say, on production systems.

  • (cs) in reply to NJAPH
    NJAPH:
    Steve:
    It's not as if we weren't all newbies at one time in our lives. Perhaps some of use learned Perl and C++ at our father's knee but many of use came to these things later along in life.
    Yes. I, for example, only learned Perl about two months ago. It took me three days to learn, and after those three days were over I was writing relatively-idiomatic Perl code in an altogether WTF-free manner.

    The secret? I'm smart enough to know that I don't know everything, so I, uh, read the fucking manual instead of jumping in and assuming I would know how to do everything without having to learn.

    I think that gives me the right to sneer.

    I'm sure you are a joy to work with. We can only hope that whoever inherits your code knows about thedailywtf.

  • (cs) in reply to TheRealBill
    TheRealBill:
    Yup cuz we all know that beginners intuitively know to take the name of the programming language, tack on "func" and answer their questions. Heck, it's something that come sin real handy when doing anything else.

    Hold your horses man, "man perl" will refer the reader to "man perlfunc".

  • PseudoNoise (unregistered) in reply to Will
    Will:
    PseudoNoise:
    Possessive pronouns never use an apostrophe: its, hers, his, ours, theirs, ones.

    It's (i.e., "it is") not rocket science.

    Possibly it does have some element of rocket science in it, since a reasonably intelligent person such as you is unaware that "one's" does have an apostrophe in it.

    Indeed, I lose. "One's" isn't a personal possessive, it's an indefinite possessive.

    But it must be somewhere between middle school & rocket science.

  • Patrick (unregistered) in reply to Toralf
    Toralf:
    I'd prefer '$my_filesize = (stat($file))[7]'

    or even better:

    $filesize = filesize($file);

  • Tinkerghost (unregistered) in reply to mkb
    I've been programming in Perl for close to 10 years and I have yet to see code that I can't read except for an obfuscation contest.
    Let me send you some of the stuff I have to work with - 15 calls to the same table for different data in the same record in the same script. Had 1 loop writing lines for a web based report - called the database every line to make a dropdown menu.

    I would say he was ignorant of hashes, but he used them at the start of every script to grab the CGI parameters. He also used a whopping 4 subroutines in the 2 dozen scripts I've rebuilt. One script included an entire cut & paste of the tax calc code 4 times.

  • /Arthur (unregistered)

    I really liked this thread, nice how folks come up with an example in there favorite language.

    From experience i can tell: if a job falls in all other environments, it can be done in perl.

    When switching between languages, switching to perl takes the most adjustment of one's mind.

    one's ... every board has it's Captain Pedantic.

    The end.

  • dkf (unregistered) in reply to Hey Nonny Mouse
    Hey Nonny Mouse:
    Of course you can connect an InputStream to an OutputStream.

    Just do it like this:

    public class IOStream implements Runnable {
    
    ...

    }

    new IOStream(in,out).run();

    Oh dear. You were doing so well up until the last line there. Either you wanted a separate thread to run the stream, in which case, that line is wrong and should be
    new Thread(new IOStream(in,out)).start();
    
    or you didn't want to run it in a separate thread, when wrapping it all in a Runnable is just silly overhead. As it is, you've got overhead but no concurrency; whichever you really wanted, what you've given us a WTF Classic! :-)
  • Anonymous (unregistered) in reply to bstorer
    bstorer:
    mathew:
    ObRuby:

    mysize = File.new(filename).stat.size

    I gave up Perl for Ruby. It's worth the performance drop to be able to avoid Perl syntax, and the performance thing will be addressed in 1.9 anyway...

    That's what they keep telling us. "Wait for 1.9! It'll be faster! It'll solve world hunger! It'll run on Parrot or JVM, be powered by the wind, and heal leprosy!" I might have made up some of those claims.

    Yes, that stuff about being faster is clearly bollocks. :P

  • Anonymous (unregistered) in reply to rjnewton
    rjnewton:
    It's not the tool, it's the design decisions made by those using the tool.

    Hear, hear!

Leave a comment on “The UNIX Philosophy”

Log In or post as a guest

Replying to comment #:

« Return to Article