in reply to Re: easy newbie question
in thread easy newbie question

mmm..ok

I'm a newbie but im not stupid. At least i dont think i posted that its a "stupid newbie question". I would not ask if it was in some documented form readily available for me. I have 4 books on perl and not one answer this question.

I printed the line like i did for a reason. It was with single quotes not double. I just wanted to know how you would put a new line if you didnt have the double quotes. Its not in all 4 books i have and it might be that "you would never use the single quotes if you want to make a new line" but i cant find that statement and wish to know this before i move on.

So one more time. ---How would you get this to print a line after it-- ------------------------------------------------------- -----print 'This will be on a line by itself.';-------- ------------------------------------------------------- 1. is the only way with double quotes? 2. can you get a new line with single quotes?
as for "Programming Perl published by O'Reilly "--there is nothing newbie about this book. O'Reilly is good but they dont cater to beginners.

Edit by tye

Replies are listed 'Best First'.
Re: Re: Re: easy newbie question
by arturo (Vicar) on Apr 24, 2001 at 02:42 UTC

    Double quotes interpolate, which means that variables get expanded within them, and escaped characters like \n and \r are interpreted as special. Single quotes are intrepreted literally, so

    print "$string\n"; #(prints the current value of $string followed by a + newline) print '$string\n' # prints out the characters $, s, t, r, i, n, g, \, +n

    (Update see String Literals in Perl for more info. We now return you to the original message) You may be relieved to find out that

    print 'This must appear on its own line ';

    Sticks a newline into the printed string. And Learning Perl, from O'Reilly, certainly does cater to beginners; moreover, there is Learning Perl on Win32 Systems from the same publisher, and if you have something against Sebastopol, CA, Elements of Programming With Perl is out there.

    When do you *need* to explicitly output \r ? I don't think one usually needs to worry about that under NT/2K. I do believe that Perl is smart enough to add it for you when needed. Unfortunately, I can't check that just now ... (I'm too much of a *nix guy these days)

      Woot! thanks for your help. you rock!
Re: Re: Re: easy newbie question
by deprecated (Priest) on Apr 24, 2001 at 20:15 UTC
    Hiya, rimuladas.

    I wanted to let you know that I did downvote your node, for a couple of reasons.

    • nobody called you stupid, hombre. we generally dont do that here.
        <print 'I a new line after this statement';>
    • doesnt even appear to be in perl. is that javascript? and yet, people attempted to help you. what irked me is that you got hostile and defensive about things.

    Programming Perl is not intended to be a book for newbies. I read Programming Perl 1st edition and was truly lost, even though I knew quite a bit of C and a few other languages at the time. A couple years later, I came back to it, and decided instead to purchase the second edition and Learning Perl as well. O'Reilly has excellent books, and they even do a good job at teaching newbies. Programming The Perl DBI (by alligator descartes) is an excellent example of this, as is Learning Perl.

    arturo gave you the correct answer. There are also several other threads that deal with this. I encourage you to use the Super Search and, if youre 'leet, the Secret Search <grin>.

    finally, i want to restate that we're here to help, and i think that 99% of the time, we manage to be a very good, generous lot. so be respectful.

    brother dep.

    --
    Laziness, Impatience, Hubris, and Generosity.