Find the answer to your Linux question:
Results 1 to 8 of 8
Well, I was thinking about learning some programming so I would understand more of the instruction in the forums. I looked at the learn perl in 10 easy steps, but ...
  1. #1
    Linux Newbie
    Join Date
    Aug 2005
    Location
    Indiana
    Posts
    101

    trying to teach myself programming

    Well, I was thinking about learning some programming so I would understand more of the instruction in the forums. I looked at the learn perl in 10 easy steps, but can't get past the first example. I really feel stupid now. All I had to do is type what was already there and I can't even do that.

    I am using ubuntu 7:10. Is there a diff. in the way it must be written?

    I am wanting to eventually be able to write a program; any program.

    I was wanting to learn C++ but thought perl or python looked simple and might be a good place to start.

    Can any one tell me; where is a tutorial that tells every step and can get me past the first example. When it says create a file called xyz.pl, how do I do this.
    I really, really don't know anything to start. I'm 39 yrs old and had a class many years ago using QBASIC in dos. I haven't done anything since then and have forgotten all of it..

    thanks for your help
    Alienware M17
    Dual ATI 3870 512Mb ram each
    intel 5300 wireless
    Ubuntu 8.04

  2. #2
    Linux Newbie mazer's Avatar
    Join Date
    Jul 2006
    Location
    Tucson, Arizona, USA
    Posts
    109
    Quote Originally Posted by tomeriker View Post
    Well, I was thinking about learning some programming so I would understand more of the instruction in the forums. I looked at the learn perl in 10 easy steps, but can't get past the first example. I really feel stupid now. All I had to do is type what was already there and I can't even do that.

    I am using ubuntu 7:10. Is there a diff. in the way it must be written?

    I am wanting to eventually be able to write a program; any program.

    I was wanting to learn C++ but thought perl or python looked simple and might be a good place to start.

    Can any one tell me; where is a tutorial that tells every step and can get me past the first example. When it says create a file called xyz.pl, how do I do this.
    I really, really don't know anything to start. I'm 39 yrs old and had a class many years ago using QBASIC in dos. I haven't done anything since then and have forgotten all of it..

    thanks for your help
    Hi man,

    Perl is a great choise to learn programming! I really love it.
    Just open an editor as for example nedit (type "nedit"). You can configure nedit so that it uses syntax high-lighting. Then just type
    -----------------------------------------------------------------
    #!/usr/bin/perl

    print 'Hello world.'; # Print a message
    -----------------------------------------------------------------
    without the ------- and save this under any file name (as for example xyz.pl)
    In perl, the lines with "#" in the front are comments. The first line
    #!/usr/bin/perl just "tells" the script (xyz.pl) that perl is used as script language. "print" just prints the "Hello world" in your terminal. However, when you have saved the file "xyz.pl" you have also to change its attributes so that you are allowed to execute it. Type in your terminal "chmod u+x xyz.pl" and then type in the terminal "./xyz.pl" and you should see "Hello world".

    Good luck,
    Mazer
    I was seduced by SUSE 5.1.
    Registered Linux User #451562

  3. #3
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    I think you need to learn the basics of Linux before you embark on programming. Learn to use the shell (bash or ksh) first, and then you can get into programming by writing shellscripts which, IME, are much easier to start with than Perl, which can be a bit daunting to a novice. Perl is a great language, but I wouldn't recommend it for someone just starting out.

    To create a file you'd start your favourite editor (which should be vi), type some stuff and save it into the file with the name you want. Or, if it's a simple file, you could just echo the contents into the file:
    Code:
    echo "This is the first line of my file
    the second,
    third,
    etc." >xyz.pl
    This creates the file "xyz.pl" (or any name you choose to use) in the current directory with the characters between the quotes as its content.

    Also, a forum like this is a great place to learn, since you can ask whatever you need to know and get plenty of help, we're only too willing.

    Good luck on your learning path!

  4. #4
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    One of the most common questions I see is how to get started in learning programming. And the most common answer is just do it.

    You say Perl. Well, Perl's a great language, and one of my personal favorites. I would personally suggest that you pick up a copy of "Learning Perl" from O'Reilly. Some people prefer online resources, but I found this book to be incredible. It's written with a great sense of humour, has tons of examples, and is a pretty excellent book all around.

    Anyway, you said you're struggling with an example. This doesn't mean that you're stupid. Although languages can vary in their difficulty, picking up the real heart of programming can sometimes be very difficult. What would have helped is, instead of posting that you can't even get past the example, if you had posted the example, your code, and asked some questions on what is going on.

    Also, if you're referring to the "Learn Perl in 10 Easy Steps" tutorial located at:
    http://www.linuxforums.org/programmi..._lesson_1.html

    Then the first example (the "Hello world" one) is actually formatted wrong, and therefore actually would not even run.

    The trick to learning anything, but particularly a programming language is effort, and lots of questions when you don't understand something. Pretty much everyone who posts in the Linux Programming & Scripting forum knows at least several languages, and we've had to go through the same process you are. Don't give up! Just have some faith in yourself.
    DISTRO=Arch
    Registered Linux User #388732

  5. #5
    Linux Newbie
    Join Date
    Aug 2005
    Location
    Indiana
    Posts
    101

    thanks for the responses

    After reading all the replies I really should have explained better.

    I was using the learn pearl in 10 easy steps and thought I did everything just as it said. I feel better knowing that it might not be me, and that it might be written wrong.

    I was kind of thinking that I didn't have something installed because I get this error:

    bash: ./helloworld.pl: /usr/bin/perlprint: bad interpreter: No such file or directory

    I think I might be in the wrong directory, but I put it in my home directory like the exaple said. I also dont know how to navigate directories in a term.

    I thought if I could start with simple programming I would get a better feel for moving around in linux. ie. where files are stored and why they are stored there. I am a convert from windows and have a good understanding of where files are and why they are there. So, when there is a problem I know where to look and what effects that file has. ( Hope that makes sense )

    I beleve bash is a programming language? similar to dos in windows? You can type commands in the bash language and if you type it correctly it will carry the command out?

    I would like to eventually be able to create programs like little games or utilities or trouble shoot and fix.

    Thanks for your help!
    Alienware M17
    Dual ATI 3870 512Mb ram each
    intel 5300 wireless
    Ubuntu 8.04

  6. #6
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Alrighty. Well first off, programming can be done on any system. Bash scripting, for instance, is tied to a particular environment (that being the Bash shell), but the Bash shell could be on any system. If you want to learn to navigate Linux better (and this is a noble pursuit), I suggest doing that. There are lots of good guides out there that you can Google for, or maybe somebody here has some advice. I personally didn't really use any specific tutorials, but rather just messed around a lot.

    Now then, Bash and DOS do indeed fulfill something of the same purpose (though I will note that Bash is infinitely more powerful), but it can be debated whether this purpose is full-on programming. These are both shell languages, and their primary purpose is to automate shell actions. This basically involves executing commands, looking at what those commands did, and doing something else. You can write programs with these by tying together existing programs, but it is rather difficult to write your own new project.

    Perl (and C, C++, Java, Ruby, Python, etc.) are all rather more fully-featured languages, and have somewhat more power behind them. However, these all have different syntax rules, different cultures, etc., and this is where the trouble lies.

    So for this particular instance, your script probably looks like this:
    Code:
    #!/usr/bin/perlprint "Hello, world!\n"
    So the '#' character in Perl means a "Everything after this is a comment". However, the '#!' pair means something special to UNIX. This means "Use the program that follows this to execute this script". So Linux is told "Find /usr/bin/perlprint, and use that to execute this script". Well, that obviously won't work. What the script should look like is:
    Code:
    #!/usr/bin/perl
    print "Hello, world!\n"
    This means "Execute the following script with /usr/bin/perl". And this will run correctly.

    I hope that this helps. I will reiterate my earlier advice to pick up "Learning Perl", as it goes a lot more into using Perl in a UNIX environment, and why you do some of the things you have to do.
    DISTRO=Arch
    Registered Linux User #388732

  7. #7
    Linux Newbie
    Join Date
    Sep 2005
    Posts
    140
    Quote Originally Posted by tomeriker View Post
    I also dont know how to navigate directories in a term.
    Maybe a bash tutorial would be the place to start. I like this one, or at least the first few pages of it
    LinuxCommand.org: Learn the Linux command line. Write shell scripts.

    I thought if I could start with simple programming I would get a better feel for moving around in linux. ie. where files are stored and why they are stored there. I am a convert from windows and have a good understanding of where files are and why they are there. So, when there is a problem I know where to look and what effects that file has. ( Hope that makes sense )
    Not sure if that makes sense. Learning to use linux and learning to program are different things altogether. If there's a shortcut to the things mentioned above I'd love to hear about it. Preferably a few years ago.

    Anyway, good luck with perl. I'm an occasional python programmer. In a newbie kind of way.
    WARNING: I may be telling you more than I know !

  8. #8
    Linux Newbie
    Join Date
    Aug 2005
    Location
    Indiana
    Posts
    101

    It Works!

    Thanks to Cabhan for correcting the flawed code. I retyped the hello world program and now it works.. It's exactly that kind of knowledge I wish to have. I feel much better about learning this now.

    I have an A.S. in electronics and one of the projects was to build a pci card with some LED's. We would write little programs to make the LED's flash or add up to certain numbers, etc.. We used assembly and qbasic. but that was many moons ago.

    Thanks Googled First for the info. I will check into that too.

    I am going to finish the tutorial I am working on now and see how that turns out. I hope there aren't anymore problems with the accuracy of the tutorial.
    Alienware M17
    Dual ATI 3870 512Mb ram each
    intel 5300 wireless
    Ubuntu 8.04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...