# Perl, C++, Unix programmers HELP!!!

**URL:** <https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578>\
**Category:** Factual Questions\
**Created:** [June 28, 2004, 5:43pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578 "2004-06-28T17:43:07Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![EhhMon](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@EhhMon](https://boards.straightdope.com/u/EhhMon)\
**Post date:** [June 28, 2004, 5:43pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/1 "2004-06-28T17:43:07Z")

</div>

I was hoping to transfer to another department, where I could do more than what I’m doing now (IT Specialist on the midshift), an opportunity came up in the programming department on the dayshift, something I would like to do, but my supervisor throws me a curve by giving me 4 problems to do, I didn’t think there be a problem, but then he told me i had to do it another program other than UNIX!!! I’ve taken C++ and Perl classes in college, but thats the extent of it. I never worked with it outside of class, the problems look vaguely familiar, but who keeps all thier old college textbooks, especially Perl!!!

I need help, I would rather back out of this, but my Lead IT helped to get me this interview. Also is it fair or common for a supervisor to do this? I learn much faster when I’m thrown into the environment and catch on pretty quickly…but to be given an assignment???

You think its his way of saying, “No chance” bud?! And just gave me the problems as a way of discouraging me…I’m stressing.

Problem 1:

The programmers need a tool that can count the number of lines in  
text file (assume that there is no ‘wc’ command). The tool must named  
‘linecount’ and it takes one argument on the command line. That argument  
is the text file for which a count of lines is to be calculated. After the  
command is executed, the message “\>\>\>There were ### lines in the file:  
\<filename\>”; where ### is the number of lines in the file, and \<filename\> is  
the name of the file passed as the command line argument.

Problem 2:

Using the newly available comment ‘linecount’ from problem 1, build a tool  
named ‘countall’ that will automatically display the number of lines in  
each file in a directory. For example, if a directory contained the files:  
text1, text2, text3, text4, then the command invocation and output might  
look  
something like this (if running on system asd1us) :

asd1us$ countall  
There were 25 lines in the file: text1  
There were 54 lines in the file: text2  
There were 345 lines in the file: text3  
There were 5 lines in the file: text4  
asd1us$

Problem 3:

Assume there is no calculator program on the unix/linux systems at FNMOC.  
Build a simple calculator that is named ‘mycalc’ that has the following  
command line:

mycalc [add | sub | mult | div] [number] [number]

Example: mycalc sub 4 3  
Result: \>\>\> 4 – 3 = 1

Example: mycalc div 54 9  
Result: \>\>\> 54 / 9 = 6

The tool must check that all arguments are present, that each is valid, and  
in  
the case of ‘div’, it must check for the last argument to assure it is NOT  
zero. If it is zero, it should print the message: \>\>\> Division by zero is  
not  
permitted!

Problem 4:

FNMOC developers need a tool to calculate the factorial of any number. Find  
an algorithm for calculating factorials, and make a tool called  
‘myfactorial’ that takes a single numeric argument and produces the  
factorial for that number.

Example command line: myfactorial 5  
Exampple result: \>\>\> The factorial of 5 is 120

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [June 28, 2004, 5:50pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/2 "2004-06-28T17:50:35Z")

</div>

These are very easy problems for an experienced Perl (or any other language) programmer to do. You are clearly unqualified, and should tell your boss that you are not able to take the position. However, If I were your boss, and found out you’d attempted to get other people to help you cheat in order to qualify, I’d kick your ass out the door so fast you’d be constipated for a month.

---

<div class="post-metadata">

**Author:** ![EhhMon](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@EhhMon](https://boards.straightdope.com/u/EhhMon)\
**Post date:** [June 28, 2004, 5:56pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/3 "2004-06-28T17:56:14Z")

</div>

Ah-hah!!! I knew it. I was set up to fail.

but shit why go through all that, why not just tell me. It looked more like problems i did in C++.

Ok now how do I graciously back out of it, without embarrasing my Lead IT???

---

<div class="post-metadata">

**Author:** ![Q.E.D](https://avatars.discourse-cdn.com/v4/letter/q/51bf81/32.png) [@Q.E.D](https://boards.straightdope.com/u/Q.E.D)\
**Post date:** [June 28, 2004, 5:58pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/4 "2004-06-28T17:58:41Z")

</div>

Yeah, I gotta say these are fairly (OK, _very_) simple problems, even for a _novice_ programmer. First of all, UNIX isn’t a programming language, it’s an operating system. Secondly, if you can’t handle these, then you’re definitely underqualified, as **friedo** said. These are all just VERY basic filehandling and logic problems.

---

<div class="post-metadata">

**Author:** ![Q.E.D](https://avatars.discourse-cdn.com/v4/letter/q/51bf81/32.png) [@Q.E.D](https://boards.straightdope.com/u/Q.E.D)\
**Post date:** [June 28, 2004, 6:00pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/5 "2004-06-28T18:00:24Z")

</div>

> [@EhhMon](#):
>
> Ah-hah!!! I knew it. I was set up to fail.

No, you weren’t. Like we said, these were VERY easy problems. If your boss was trying to set you up to fail, he’d have given you much more difficult stuff to do. I’d say he was giving you every chance to succeed.

---

<div class="post-metadata">

**Author:** ![Bill\_H](https://avatars.discourse-cdn.com/v4/letter/b/a5b964/32.png) [@Bill\_H](https://boards.straightdope.com/u/Bill_H)\
**Post date:** [June 28, 2004, 6:12pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/6 "2004-06-28T18:12:05Z")

</div>

You know, you’ve been given a big opportunity here. You can shine or you can flail. So far, you’re flailing badly, in both attitude (I’ve been set up to fail!), and ethics (Hey guys, do my homework for me). But there’s still time to do well.

You say you knew some c++ and perl once upon a time. Pick the language that you did best at, and go google a tutorial. There are plenty. Then work till you have solutions. Many people here will give you advice and tutorial-like guidence, but I doubt anyone will help you cheat.

By the way, if you sincerely want to advance in your chosen career, I advise you to take this challenge very seriously. Because these sorts of skills will be mandatory in your future. If these sorts of skills frighten you or aren’t interesting to you, then you should seriously consider other career paths.

---

<div class="post-metadata">

**Author:** ![EhhMon](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@EhhMon](https://boards.straightdope.com/u/EhhMon)\
**Post date:** [June 28, 2004, 6:16pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/7 "2004-06-28T18:16:30Z")

</div>

> [@Q.E.D.](#):
>
> Yeah, I gotta say these are fairly (OK, _very_) simple problems, even for a _novice_ programmer.

Its true and I remember doing these problems before, its just that it was so long ago. When I was learning Perl, the big talk at the time was that Perl was going away and PHP was taking over…forward 5 years later, Perl is still going strong and PHP is almost gone. But I’m so use to writing shell scripts…i’m just at a lost for both Perl and C++.

I just need a quick refresher course. anyone recommend a good “learn perl in 24 hr” book?

---

<div class="post-metadata">

**Author:** ![Trunk](https://avatars.discourse-cdn.com/v4/letter/t/87869e/32.png) [@Trunk](https://boards.straightdope.com/u/Trunk)\
**Post date:** [June 28, 2004, 6:37pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/8 "2004-06-28T18:37:41Z")

</div>

Yeah – I’d just tell him, “You know, I’ probably not the right guy for that job. I guess I’ve forgotten more about those languages than I thought I had.”

Now, I’d believe you might have forgot how to write out your headers, or some syntax. But, if you really did learn C++ in that class, you could pick up any C++ and do each one of those problems in 10-20 minutes.

Go ahead and learn C++ but apply to a job in the future with it, not this one.

Oh, and never throw out programming books.

---

<div class="post-metadata">

**Author:** ![CurtC](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@CurtC](https://boards.straightdope.com/u/CurtC)\
**Post date:** [June 28, 2004, 6:39pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/9 "2004-06-28T18:39:10Z")

</div>

So you’re going for a programming job, but have zero programming skills? I mean zero, because these problems are so simple that even I, an equipment salesman, can whip them all out in four different languages.

I’d suggest you spend some time acquiring a few programming skills, _then_ try to land that job.

---

<div class="post-metadata">

**Author:** ![Q.E.D](https://avatars.discourse-cdn.com/v4/letter/q/51bf81/32.png) [@Q.E.D](https://boards.straightdope.com/u/Q.E.D)\
**Post date:** [June 28, 2004, 6:41pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/10 "2004-06-28T18:41:13Z")

</div>

> [@EhhMon](#):
>
> I just need a quick refresher course.

If you’ve done Perl before, [this](http://www.perldoc.com/perl5.8.0/pod/perl.html) should be a sufficient refresher. Hell, I _taught_ myself Perl using this site, in fact. Everything you need is here. Good luck!

---

<div class="post-metadata">

**Author:** ![Jurph](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@Jurph](https://boards.straightdope.com/u/Jurph)\
**Post date:** [June 28, 2004, 7:11pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/11 "2004-06-28T19:11:21Z")

</div>

If you are absolutely determined to get this position, then you will need to

(a) learn some programming skills  
(b) apply yourself, to demonstrate a positive attitude.

If you go to your local bookstore, drop $29.95 on O’Reilly’s **Learning Perl** , you can knock out all of these problems in an evening. If you really do a significant amount of shell scripting, then you should honestly be able to blast through the first, ummm… _flip flip flip_ six chapters and have passable scripts written in Perl to accomplish these goals.

So, the question you have to ask yourself: is it worth $30.00 of your own money and an evening of your time to get a new, better job? If it is, get cracking. If not, nothing I can say here is going to help you.

---

<div class="post-metadata">

**Author:** ![midget](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@midget](https://boards.straightdope.com/u/midget)\
**Post date:** [June 28, 2004, 8:03pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/12 "2004-06-28T20:03:14Z")

</div>

FYI:

Any _real_ program you’d be writing in your job would most likely be substantially harder and more complex than the trivial test questions you mentioned. Is the guy who provided the questions the same person that will be assigning you potential projects for this job? It sounds to me like he knows as little about programming as you, and plans to pass you on to a project manager if you complete these questions that he likely found in a book. As soon as the real project manager encounters your lack of programming knowledge and (judging by your comments thus far) negative attitude, you’ll be done for.

If you think these problems seem impossible and a set-up for failure, I would save yourself the embarrassment and politely decline the job. You may be able to whip these out after reading a few chapters of an introductory book, but don’t count on holding the job for long if you plan to learn as you go in a programming position. Your ascertation that UNIX is a programming language is enough to suggest to me that shooting for this job would be a decidedly Bad Thing.

If you really have an interest in programming, I’d suggest taking some night classes or getting down-and-dirty with some introductory books _before_ considering a job.

---

<div class="post-metadata">

**Author:** ![Bill\_H](https://avatars.discourse-cdn.com/v4/letter/b/a5b964/32.png) [@Bill\_H](https://boards.straightdope.com/u/Bill_H)\
**Post date:** [June 28, 2004, 8:52pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/13 "2004-06-28T20:52:15Z")

</div>

Oh, another thing…

**EhhMon** wrote

> [@](#):
>
> When I was learning Perl, the big talk at the time was that Perl was going away and PHP was taking over…forward 5 years later, Perl is still going strong and PHP is almost gone.

First, if you did as you implied – i.e. learned PHP instead of Perl because you believed it was the upcoming thing – great news! You can do these assignments in PHP just as well. However, I suspect you really didn’t learn PHP, so I’m not sure why you made this statement.

Second however: PHP is plenty strong. It’s a valuable skill to know. In some ways, it’s more valuable to know than Perl. It’s also easier to learn.

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [June 28, 2004, 8:53pm UTC](https://boards.straightdope.com/t/perl-c-unix-programmers-help/252578/14 "2004-06-28T20:53:12Z")

</div>

> [@EhhMon](#):
>
> Ah-hah!!! I knew it. I was set up to fail.
> 
> but shit why go through all that, why not just tell me. It looked more like problems i did in C++.
> 
> Ok now how do I graciously back out of it, without embarrasing my Lead IT???

If you want to back out, just tell the boss that you misunderstood the skill requirements, and you’ve forgotten what programming skills you once had.

However, if you want to teach yourself programming skills (A highly lucrative idea) then get some books and start doing the exercises. People on this board (and especially more dedicated boards like [Perlmonks](http://www.perlmonks.org/), in the case of Perl, will be happy to help you if you get stuck, _and_ ask _good_ questions.

To clarify:

Bad question: Hey guys, do my work for me so I can get ahead!

Good question: I’m trying to accomplish X, here’s what I’ve done so far, I get error Y, and looked in manual Z, but couldn’t find out how to foobar the snafbaz.

See the difference? 🙂
