Rudimentary PERL – Part 1

Hello There! If you had read my previous post, you would have guessed it already, the new language that am trying to learn is PERL.

The contents of this post comes straight out of the notes that I make on my rough book while am trying to learn PERL from scratch. I promise to keep it as simple and concise as possible. I’m just a novice, so mistakes are bound to occur, apologizing in advance.

  • PERLPractical Extraction and Reporting Language (most well-known acronym in use) – developed by Larry Wall.
  • Powerful like any other high level languages, convenient like any other scripting languages.
  • Doesn’t require compiler, linker and all those stuffs.
  • Requires the PERL interpreter though.

Note: The gist is simple – there is no conversion of the script that you write into a machine language. That is where you need compiler and linker. But it is required to have PERL installed and running on the system where you are trying to execute a PERL script.

So you need PERL to be installed on your system.

  • Check if you have PERL already installed on your system by typing “perl -v” at command prompt on Windows OS. This basically returns the version of PERL installed on your system (if you have it, else bad command) – I have v5.14.2 installed.1
  • Instead of ‘-v’, you could substitute it with other letters to display various other things. (Check here for more details)
  • You can install PERL from here. This is DWIM PERL, the one I use. It contains a bundle of things as mentioned in the link. There are many other links and variants, so feel free to install whichever you like.
  • A PERL script can be typed on any text editor like notepad ++, sublime text etc. All you need to do is save the file with the extension .pl
  • Since I installed DWIM PERL, I will be using PADRE for typing and debugging my script as it comes along in the bundle. PADRE stands for PERL Application Development and Refactoring Environment.2
  • Now for some reason you want to know the path where PERL is installed, try this at command prompt – perl -e “print ^X”. This and more commands can be found here.

Writing the first PERL script

  • This is a simple script which will take in an input line from the user and print it out. Type and save it with extension .pl. Here name of script is read_and_write.pl3
  • This script can be executed from the command prompt. Ensure that you are at the location where the script is saved. Type the command perl followed by name of file.

For example perl


Then you type a line and when you press enter the same line will be outputted. Now let’s analyse the code snippet that we wrote above.

  • In the script, there are 2 lines – the first line is where the input from the user is taken in and the second line is where it is shown to the user.
  • $ – this is the symbol used to represent any scalar variable be it string or integer or float. You don’t have to declare the type of variable you are going to use; PERL will do that for you.

So $input is the scalar variable that we are using here. We can have any names instead of input.

  • <STDIN> – this is standard input i.e.; the user is inputting something on the command window (here “hi this is the line”). It gets stored into a standard input file and is present there till it is over written by another user input.
  • So in the first line of code, we are assigning the RHS to LHS which in simple terms means we are copying the contents of the standard input (user input) to a scalar variable called $input. The = in between makes this possible. So now $input has content “hi this is the line”
  • print – This is a library function which takes an argument and outputs it to the user on the standard output; here command window itself. In this code the user input (<STDIN>) is copied to the scalar variable ($input) which is then outputted by using the function print.
  •  this indicates the start of a comment. So whatever follows # on a line is simply ignored by the interpreter.
  • ; – each line of code must end in semi colon. That’s how the interpreter identifies that a line or statement of code has ended. The interpreter considers everything before it encounters a ; as a single statement. You can have any number of white spaces in a statement for formatting or readability.

Attempting to learning something new…

There are umpteen times when you would be faced with the strongest of all desires to learn something new – a new skill, a new language, a new tool or something of that sort which you think could help you secure a better position in your industry or within your team or get you a better job. I believe anyone who is in the so-called IT industry can totally relate to what I just said. Somehow you didn’t get that opportunity earlier due to some reason, maybe you didn’t have time, and had some commitments or you felt you were self-sufficient. You might think it’s too late now, how would you be able to cope up, how would you fare, will you be mocked upon. My advice – shift delete all those negative thoughts.

If you really think that learning something new can help you – like a stressbuster or like a hope giver or if it has stayed in your mind for some time, I strongly suggest that you should follow your mind. It’s never too late. NOW is the time to begin.

Let’s try to figure out some common steps to follow so that you stay on track and don’t wander off.

  • Narrowing down you interest – Ask yourself ‘what is it that you want to learn?’ If you have a defined skill or language, then you have completed your step 1. For example, ‘I want to learn Perl’ or ‘I want to learn Spanish’ is a defined interest. Instead if you say, ‘I want to learn some programming language’. You have to decide for yourself what you really want to learn. Let’s say for example, ‘I want to learn a foreign language’. Then you should narrow it down by asking yourself some questions like which language? Why this language? Or you could surely consult someone and then finalize. Remember, it’s finally you who have to be convinced of what you really want to do. So you should pick one that gives you a confidence that you can achieve it.
  • Deciding how you will learn/master it – This is a rather tough choice, do you want to self-learn or are you going to learn it from someone else? Are you going to join a class or will you be able to learn on your own. There are many factors which would affect this decision. If you need an external help to understand or practice your new skill, then you would have to join a class. Foreign languages are usually better learned as a group. Or you could find a friend who shares a similar interest. Do you want to self-learn, at your own pace and whenever you like? This is also possible. Maybe you could feel regular classes are long and you don’t have enough time to spend on it or it could be costly. This is nothing to worry about. There are scores of online materials, pdf, tutorials available freely so there’s no dearth for study stuffs.
  • Collecting materials/ Finding information – You need to collect all necessary stuffs required. All study materials, download/bookmark and keep if you have opted for self-learn. It’s not wise to spend hours searching for materials after you have started studying as it is going to be a total distraction. If you have decided to join a class, get in touch with them about availability of course, number of students, fees structure etc. It’s always wise to start at a place close to where you stay as long travel could tire you down and leave you unmotivated.
  • Estimating the duration – This is very crucial. You can’t keep on studying for a lifetime. I know learning is a life time experience and you can’t call yourself a master anytime but there could be many reasons for you to estimate how long you can continue on this skill. It could be like you have to take an exam on this new skill. Say, in 3 months you have an exam, so the duration you have is basically 3 months. In some cases you don’t have such a timeline, create one. Say, I will learn this and this and this of this skill in 4 months, then 4 months is your duration.
  • Finding the time – You should decide how much time would you be spending on this new skill, how many hours per day, per week and you should strictly adhere to it. Include this as part of your daily schedule. It could be a couple of hours in the weekend or during the weekday. This should go along with step 4. Be realistic, you can’t say I will study 20 hours per day which is practically impossible.
  • Finding the place – You should find a suitable place to sit and learn with minimal distractions. If you live with friends or family, make them aware you are doing so and so and hence you shouldn’t be disturbed unless it’s too critical.
  • Starting – You should Start learning. Decide a date when you will begin and do it. There might be lot of starting trouble but if you can reach till here, you have a high chance of achieving your goal. When you decide on a date, ensure that it’s not too far away because then other commitments can pop up and you might not be able to begin.
  • Being on track – Once you have started, ensure that you stay focused and continue to move towards your goal. You could track yourself, you have covered these and these, make a plan but not a big plan. You could plan of covering these many topics before next Saturday. Also reward yourself when you cross certain milestones. For some reason, if you skip a milestone, don’t be disheartened. Go ahead, define a new one and achieve it.
  • Discussing and learning – During the course, it would be nice to discuss about your skill with people you think are knowledgeable in it. You should get your doubts cleared as and when possible.
  • Reaching your goal – Once you reach your goal, it’s time for celebration. Congratulate yourself for reaching so far.

Hope to see you all waving the green flag of achievement very soon. Good Luck!

Are you in a relationship – with Pizza?

Julia Roberts speaks out her love for Pizza in ‘Eat Pray Love’. Do you find yourself in a similar position? If you do, read on to know more about your beloved Pizza.


Does this image appeal to you a lot? Does it make your mouth to water? Does it reminds you of the last time you had a pizza? I think you are in serious trouble then.

Pizza is definitely an easy go-to food loved by people of all ages. With myriad crust, cheese and topping combinations on varied sizes along with delivery, take-out and dine-in options, pizza fits just about any occasion. That’s the end of me praising pizza. Now into some serious stuffs.

Pizza is part of a full fledged business now with the dairy industry spending big bucks to promote pizza and partner with big food chains like Domino’s, Pizza Hut, Papa Johns… This has resulted in an increase in the consumption of cheese by nearly 30% in past 10 years. There’s a lot going on behind closed doors that nobody wants us to know or talk about, and it all starts with the ingredients. If find really want to find out what may be lurking in your pizza,  you got to review its complete ingredient list, which is often concealed from the public.

Heard of MSG – monosodium glutamate? This is a potent flavour enhancer which is often added in pizza. You wouldn’t find it in the ingredients list with the same name though; something like free glutamic acid additives would be present which is actually the main component of MSG. Or maybe these toxins: Autolyzed Yeast Extract (Hidden MSG), Textured or Hydrolyzed Proteins (Hidden MSG and GMO), Hydrolyzed Corn (Hidden MSG and GMO), Modified Starches (Hidden MSG or Possible GMO), Natural Flavors (Possible Hidden MSG), Disodium Inosinate or Disodium Guanylate (MSG enhancers).

Ever felt like repeating yumm… this is so good? MSG tricks your brain into believing that what you are eating tastes so great that you want more of it. Your taste buds sense that there is more protein in the food than there really is – which is great for food manufacturers who wants to save money by using less or lower quality meat. Ever wonder why you can’t stop at one slice? These ingredients also promote an addiction to pizza so that you keep coming back to order more. Repeat business keeps their pockets lined with lots of cash.


MSG and hidden MSG additives are known to commonly cause headaches, obesity and depression. As an excitotoxin, its effect on the brain is so toxic that it has been linked to learning disabilities, Alzheimer’s disease, Parkinson’s disease,Lou Gehrig’s disease and promoting cancerous growth. Also these ingredients can stick around in your body for a long time, leach nutrients from your system, and can make you really sick.  It can also interrupt the hormonal and biological development of children.

Advice: Avoid as much as possible.

Fat and Calories

A typical slice from 14 inches of regular-crusted cheese pizza contains between 250 to 350 calories and 10 to 17 grams of fat. Adding extra topping of pepperoni, sausage and cheese-stuffed crust can increase your calorie and fat intake to almost 500 calories per slice with 26 grams of fat. The high fat content in these pizzas comes largely from saturated fats, too much of which can raise your risk of developing heart disease by raising blood cholesterol levels. The saturated fats in the main crust of pizzas may block your arteries and cause serious problems like heart attack. Eating too many calories can cause weight gain and make you obese.

Advice: Hit the gym after relishing a pizza slice rather than crib over weight gain.

Partially Hydrogenated Oils (Trans-fat)

Partially hydrogenated oils block arteries causing heart attacks. Estimates show that they could cause up to 20,000 heart attacks every year.

Advice: Avoid the dipping sauces and the hand-tossed crust pizzas.


Commercial pizzas are high in sodium with 500 to 700 milligrams per slice. Taking in excess of 1,500 milligrams leads to water retention and increases your risk of high blood pressure.

Advice: Keep count of number of slices and stay below the limit. Also drink a lot of water to flush the sodium out.

Rest of the stuffs and its effects

Soybean Oil – causes inflammation; used in dough and pizza sauce

BHT/BHA (Butylated Hydroxytoluene / Butylated Hydroxyanisole) – toxic to organs, causes cancer; found in pepperoni pizza

Sodium nitrate – Causes cancer; found in the pepperoni, ham, bacon and sausage toppings

Artificial Colors – These are petroleum-based colourings linked to asthma, allergies and hyperactivity

Advice: If you still crave for pizza,  prepare it on your own and consume it. In that way, you can atleast be sure of what is actually in it.