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

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

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.

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???

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.

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.

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.

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?

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.

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.

If you’ve done Perl before, this should be a sufficient refresher. Hell, I taught myself Perl using this site, in fact. Everything you need is here. Good luck!

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.

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.

Oh, another thing…

EhhMon wrote

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.

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, 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? :slight_smile: