Basic Perl questions from Perl beginner now using Leopard

Question: I used to dabble in Perl programming (beginner!!) and want to continue my dabbling with my new iMac running Leopard.
Which Perl do I need to install?
Where do I get it from?
What tricks / concerns are there in the installation?
What's the best source of information (books?, internet?) for learning about using/programming Perl on Leopard?
Any other advice that you believe would be helpful would be appreciated.
Many thanks!! D

I used to use MacPerl as well, it's even better now that Perl is pre-installed and native.
The two thing that took me the most time to figure out are:
Line endings. All my old scripts had carriage return - line feed as end of line delimiters.
On linux they have to be line feed '\x0A'. You do that by setting it in your text editor. I use BBEdit or Text Mate to write perl, although I'm pretty sure that using TextEdit will work, and will have line feed line endings.
Setting the script's executable bit. A script file needs to have a bit set in the linux filesystem to tell linux it's executable. You do that by opening the terminal and typing chmod +x then drag your script file into the terminal and pressing return.
That's detailed here:
http://www.oreilly.com/pub/a/mac/2003/11/07/scripting_osx.html
Also there are 2 main ways to run your script.
One is by opening Terminal and +typing perl+ then dragging your script into the terminal window and hitting return. if you want to do it this way the very first line in your perl script needs to look like this:
#!/usr/bin/perl
The other way (which is only slightly easier) is by dragging your script into the terminal window and hitting enter, no typing perl every time. To do this the very first line of your perl script needs to be:
#!/usr/bin/env perl
Another huge tip is if you are in the Terminal window hitting command-up arrow will show you the last command you typed in, so you can hit enter and re-run it.
Other than that stuff I can't remember any differences between regular linux perl and Leopard perl. I still refer to the Camel book I bought 15 or so years ago.
So type into a text editor:
#!/usr/bin/perl
use strict;
use warnings;
print "Hello World\n";
Then save the file as Hello.pl
open terminal and type *chmod +x*
drag Hello.pl into the terminal and press return
Type perl into the Terminal
drag Hello.pl into the terminal and press return.
and it should print.

Similar Messages

  • Basic question from a beginner

    I am looking for a solution to this problem: I wish to record some classical piano for an audition DVD. I have a video camera, but the dynamic range and fidelity of the microphone are not very good. I'd like to simply strip out the audio and replace it with input from a good microphone. (I have a good microphone and USB input for it.) The audio/video syncing has to be seamless. In the past I've recorded audio using GarageBand, and I've used iMovie from camera input (A&V) for separate projects. I hear the problem is that GarageBand samples at 44 kHz (and cannot be adjusted) while video is normally recorded a 48 kHz. What do I need in terms of software to do this job? Would you recommend FC Express, strip out the audio, and find some audio recording software that can sample at 48 kHz? Any recommendations? An economical solution would be nice. I appreciate the help in getting me started.
    Message was edited by: joelmg

    Does your camera allow use of an external mic? That would be the simplest solution.
    If you need to record the audio separately, you can use the QuickTime Player to convert the sample rate to match that of your Final Cut Sequence, though lots of folks have used 44.1kHz audio successfully in FCE. (I think you need QT Pro in order to have the sample rate conversion capability.)
    As you begin recording, include a clap or some big sound to aid you in synching the two audio sources. Once you get everything recorded, I'd bring the video into your Timeline with the camera's audio, then import the external audio, synch up the audio sources, then unlink the camera audio from the video and delete that audio.

  • A few questions from a beginner

    Please don't hit me because of my questions...
    1. Is there a build in method (class or whatever) to increase an array size? I don't want to copy the array each time into a larger array and then setting the pointer of the new larger array to be the same as the old smaller array. I mean a method like Array.increase(param) or something like that.
    2. Is there a way to find out how many dimension an array has? A build in method like .length
    3. Can I convert a array into a vector? If yes, how?
    4. The Math.round() method accepts only one parameter which contains the double number to be rounded. But it does't have a second parameter by which I can tell the method to round a number to the second (third or whatever) number after the dot. Is there a method like that somewhere else or do I need to program it for myself?

    ::smack::
    there, now that's out of the way..
    1) No.. arrays are static in length, which is set upon instantiation. If you need a datatype to store multiple objects that will need to increase in size, you should use Vector.
    2) I believe I'm right in saying that there's not really a way to check that. A multidimensional array is basically an array of arrays. I guess you could know that if you got myarray[0] and did a check to find out what datatype it was, you'd know that if the index contained an array, it'd be 2D ... then you could check that array, etc. However, since you are declaring the array, and when passing the array, you'd have to specify what it was (ie public void foo(int[][][] my3dIntArray) ) you should never not know the dimensions.
    3) Yes. But you'll have to loop through your array and add items to the Vector.
    4) You're right, it doesn't. Now that you mention it though, I can't think of a method that does that.... but it shouldn't be too hard for you to work out your won.

  • Question from a beginner

    Hi, all, I'm new to JSP and JavaBeans. Now I have to develop a web site with these technology.
    My first question is:
    Can I just put all database access(query, update, delete...) into JavaBean and create a bean for every table I have. Is this a good idea or I'd better follow the MVC model? Am I able to call a method in such a bean to access database?
    I've tried it, but I got a "NoSuchMethodError".
    Thank you so much.

    Using beans is a pretty good way to display database content in your jsp - it's certainly better than having all your code in JSP scriptlets (ie. between <% ... %> tags). The idea is to have as little actual java code in your jsps (separate presentation from business logic).
    The ultimate goal is an MVC architecture. Struts (http://jakarta.apache.org) is a framework which helps you to set this up and takes a lot of the pain out of setting up your own.
    HOWEVER ... I'd say that if you're just starting out with java and jsp then an MVC framework might confuse the hell out of you and your colleagues. If your app is not too complex then you might prefer to start off simply using beans in your pages until you get up to speed with all the other jsp issues. It's virtually impossible to get your jsp webapp architecture perfect the first time round, so perhaps set your sights on a simple model.

  • HP simplesave ca94304 keep data on hard drive from PC and now use with Mac computer

    Hi, I've recently purchased a new Apple Macbook Air and I have this HP simplesave ca94304 1 TB Ext Hard drive that I would like to be able to use for backing up my new MacbookAir. I have had this hard drive for a few years and have the backups from my PC formated laptop on it already. How can I keep this information on the hard drive and still back up the macbook Air?

    Agree with what Dragon-fur said.
    I will add...
    There are numerous queries on here where consumers report these drives not being recognized suddenly. Their end of life seams to be coming to pass now.
    Once that happens, you cannot retrieve the data because SimpleSave drives are not like a traditional external drive.
    Also, if you only have your data backed up on one drive (one backup), you dont have a backup. WHEN that drive fails, your data is gone.  A good rule of thumb is to have 3 backups using a combination of different ways to do so.
    Good luck.

  • Question from a beginner, really need help

    I am starting to do a little programming these days. The question is about the (program file) format to provide to the end users.
    I can use "javac" "java" to compile or run my code in a command prompt window, or use some development tool. But I do not expect the users of my program to install the jdk (or other software) in order to run the program. How to deal with this?
    What is the usual last format of a Java Program?
    Hope I have made my question clear.
    Thanks
    Xiaohua

    It depends, a good solution is to pack it into a jar file and make it executable, but if you are new to Java (I have no idea how experianced you are) it might give you more trouble than it's worth in the beginning.
    You could distribute your .class file (the .java files are only source and can not be executed) and a .bat file which would contain the command to launch the applicaiton. That's how I would do it as a newbie.
    Check out an installer program like Inno Setup ( http://www.jrsoftware.org/isinfo.php ) if you want a neat way to distribute your files. You can specify a .bat file as being the one executed when the applicaiton is started, that way your program could be run from a start menu entry (sorry, I'm assuming that you are using Windows here, to maintain cross-platform abilities this won't work)
    Does this give you an idea? There are many ways to distribute an application. You should also read up on Java Webstart...

  • Questions from a beginner

    does Jdeveloper have a servelet containers?
    i have to choose bettween eclipse and Jdevelopper which one shall i choose and why?
    i have to call "api" written with "c" to a java application ,are there a solution?
    thank u

    As already stated, Jdeveloper comes with an embedded version of the OC4J J2EE container, which supports JSP's, Servlets, EJBs, etc...
    Our organisation is currently migrating away from a combination of WSAD 5.1, which is an Eclipse based IDE, and MyEclipse, and standardizing on JDeveloper 10.1.3 - the feedback in almost all areas has been extremely positive.
    The only area where Eclipse seems superior is in its interfaces to CVS. JDeveloper works OK in this area but can be clunky with accessing repositories on WAN connections.
    Also, if you plan on using Maven2 - its not really documented anywhere, but a workable plugin was available as part of the original ADF Faces release to Apache. I can't find it right now, but it would be great if Oracle would officially release it or contribute it to the Apache Maven group <hint/>

  • Few questions from a beginner

    hi there , i have a few questions first thing
    is it possible to make every connector that comes out of a specific shape the same color , im building a map where 1 shape gives of multiple connections, i want them all to be in the same color, and the connections coming from the second shape are all in
    a different color from the first shape
    second question: how can i select all the connectors that pass in a particular area
    i selected in the option select shapes partially in area, but it selects connectors that are NOT in the area that i selected
    thank you very much for your help

    There is no out of the box way for the first question but you can write a macro to do that. 
    Shape properties Shape.Connects and Shape.FromConnects can be used for selecting all
    outgoing connectors of a shape programmatically. And then appropriate formatting (colors) can be applied on selection by selection.

  • Very simple question from a beginner

    I am currently doing a little exercise, but I ran into a problem. I have written a class that supports operations on rational number. The fields are two long variables, one each that stores the numerator and denominator.
    I have made add, subtract, multiply, and divide methods...
    1. what I need help in is: beingh able to store the rational number in reduced for, with the denominator always positive
    2. constructing a toString method, equals method, and compareTo method.
    3. it also says "make sure the toString method correctly handles the case in which the denominator is zero by throwing an exception.
    I have been working on this for a long time now, an I am stuck at this point.
    I know this will be very simple for you guys and gals, but I am a beginner. Please offer some input, advice, and/or some code to help me get past this problem.
    Thanks so much,
    Jason

    ok, here is what I have so far
    public class Rational {
         public long num, den;
         public Rational(long n,long d) {
              this.num = n;
              this.den = d;
         public static void main(String args[]) {
              Rational r = new Rational(1,2);
              Rational s = new Rational(3,4);
              Rational rmuls = r.multiply(s);
              Rational rdivs = r.divide(s);
              Rational radds = r.add(s);
              Rational rsubs = r.subtract(s);
              r.print();
              s.print();
              rmuls.print();
              rdivs.print();
              radds.print();
              rsubs.print();
         public void print(){
              System.out.println(this.num+ "/" +this.den);
         public Rational multiply(Rational t){
              long n;
              long d;
              n = this.num*t.num;
              d = this.den*t.den;
              Rational answer = new Rational(n,d);
              return answer;
         public Rational divide(Rational t){
              long n;
              long d;
              n = this.num*t.den;
              d = this.den*t.num;
              Rational answer = new Rational(n,d);
              return answer;
         public Rational add(Rational t){
              long n;
              long d;
              n = (t.den*this.num)+(t.num*this.den);
              d = t.den*this.den;
              Rational answer = new Rational(n,d);
              return answer;
         public Rational subtract(Rational t){
              long n;
              long d;
              n = (t.den*this.num)-(t.num*this.den);
              d = t.den*this.den;          
              Rational answer = new Rational(n,d);
              return answer;
         //public int compareTo (Rational t)??????

  • Oracle Triggers  - A few questions from a beginner to oracle.

    Hi,
    1. If we cannot COMMIT within a trigger, then how is it possible to use TRIGGERS to INSERT rows into an audit table that will track any INSERT/UPDATE attempt on a table. I have to record even failed attempts.
    2. Is it possible to make API calls from within a TRIGGER? (This API will write out data from the table being INSERTED/UPDATED into corresponding tables in a MYSQL database (somewhat like replication))
    3. If 2 is not possible, we are planning to write updates to an intermediate table that will be checked by a webservice every few minutes and in turn update the MYSQL db.
    Please help/advise.
    Thx.
    Vis.

    1. use autonomous transactions.
    2. if the API a PL/SQL code, yes you can call PL/SQL from
    the trigger body.
    To connect Oracle and MySQL, following thread might help:
    Re: Oracle to MySQL database connectivity
    Message was edited by:
    Pierre Forstmann

  • Compression Question from a beginner

    I'm trying to export my first video. I'm a little lost when it comes to all the compression options. Basically I have a 2min video with sound that I want to upload to youtube, but its fairly important that the sound quality isn't diminished too badly. I'm guessing that I want to export to an AVI or MPEG4, but again, I'm new to this. Can anyone make any recommendations? Much appreciated.

    This is for Compressor, but the principles are the same for exporting from FCE.
    http://www.kenstone.net/fcphomepage/youtube_compressorgary.html

  • A question from a beginner

    I'm teaching a introductory programming course in java to some folks, and explaining variable lifetimes and the need for object member variables to store values longer than just a method call.
    So the example given was of a parameter being saved in a member variable
    The question arose, "Why can't you just specify the member variable as the parameter?"
    To which i gave the obvious reasons.
    When the class was over, i thought about it some more, and except for syntactic unpleasantries, there is no reason why this couldn't be done. Given that this is a common idiom, its odd that you can't do that.
    It's only not odd, because it's never been done before.
    Just thought it was an interesting thought that new-person thought produced.

    To paraphrase the JLS: When the method or constructor is invoked, the values of the actual argument expressions initialize newly created parameter variables, each of the declared type, before execution of the body of the method or constructor. The identifier may be used as a simple name in the body of the method or constructor to refer to the formal parameter. Taking your example:
    public class Foo {
      private int input;
      public void setInput( int Foo.input ) {}
    }Here you are not initializing any newly created parameter variables, and you have no identifier that may be used as a simple name in the body of the method or constructor to refer to the formal parameter. This breaks another part of the language specification which states that formal parameters are referred to only using simple names, never by using qualified names. You might also get into issues with the float-extended-exponent value set and the double-extended-exponent value set.
    Alternatively, you may just be suggesting that the compiler perform qualified name erasure to transform:
    public class Foo {
      private int input;
      public void setInput( int Foo.input ) {}
    }to:
    public class Foo {
      private int input;
      public void setInput( int input ) {
        this.input = input;
    }If this is the case, isn't syntactic sugar supposed to makes things "sweeter" to use? IMHO, this syntax isn't.

  • Very basic function question from numbers virgin

    I have been working on a numbers table sent to me and adjusting data, need to calculate column totals but the function key on the toolbar is not 'highlighted' so I can't click on it to caluculate the sum. can't work out how to do this or find another way round it. don't want to create a new table. any advice? thanks

    photogogirl, if you haven't given up yet, here is another suggestion.
    Looks like that toolbar menu named Function also is not available if you have a range of cells selected that include a footer cell. The person that sent the file to you may have activated the footer row. If so, and since you said you are trying to sum columns, I would select ONLY the footer cell in the column you want to sum and then select Sum from the toolbar Function menu. Also, notice as you select single cells, you can see the underlying formula (if it exists in the selected cell) right under the toolbar. You can select any single cell and type the formula there directly if you like.
    gluck.
    Rob

  • A simple question from a beginner

    how do i check for a null reference? eg:
    String val = null;
    // do some stuff with a hashtable...
    // now want to check if val is still null
    if (val.equals(null)) // this is where i get a NullPointer Exception
    System.out.print ("val is still null!");
    thanx in advance

    if (val == null) ...

  • A beginner question from a beginner in JDBC

    Hi,
    I am trying to execute a query on the database and I have a really strange problem:
    When i execute the query, the system answers me "invalid column name?". I try to male query to find the name of all the column and the answer is good (all the column exist).
    The qu

    Did you check the spellings of column names?
    -XL

Maybe you are looking for

  • Iphoto will not open since upgrading to mountain lion

    Is iphoto obselete? Should I transfer to another program?

  • How to open a mac mini

    Hi, I was wondering how you take off the mini's shell to access all the inside components

  • ROM file from Powermac G3?

    I have sheepshaver all ready on my intel-based mac but how can I get the ROM file from the old PowerMac G3 running Mac OS 8.6? Zip drives? floppys? CDs? I want it to be something USB because my intel-based mac is a mac mini. I tried re-partitioning m

  • Express with mac and dell laptop?

    Hi - I am a newbie to wireless internet access. I have an eMac with an airport extreme card installed, and an airport express hooked up to my DSL line. I am a teacher and would like to plan lessons on a basic notebook to bring in and share with the c

  • Windows 2008 64 bit - BSOD

    Hi, I have a win2k8 - 64 bit VM running on OVM2.1.5 and if i start some I/O in the VM, i occasionally get a BSOD with the "stop 0x00000101" error accompanied with "A clock interrupt was not received on a secondary processor within the allocated time