Numbers & stack commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Numbers & stack commands
# 1  
Old 12-02-2003
Numbers & stack commands

Hi everyone,

Sorry I keep asking these stupid perl questions here. They're not any sort of assignment or anything like that, I'm just browsing through the book "Learning Perl" and I'm finding that I can do some of their practice exercises just fine, but others give me some trouble.

Right now I am trying to make a two programs. One of them has input of two different file numbers, both in ascending order. These files contain numbers, and these numbers are displayed in ascending order. The array needs to be built before it is displayed, and you are not allowed to use any sorting technique (the numbers have to be put in the result one at a time).

They give you a hint that says that the first number from the second file can be identified by it being the first one that is smaller than the previous number.

Another one that I have yet to figure out is where the input is a file that contains a list of stack commands, one per line, and has the form operation: value, specified on the command line.

The output is a stack, displayed after each command is read and executed. It says that the possible commands are push, pop, shift, and unshift, and the values can be strings or numbers.

Like I said, I've been able to do most of these, but these are a few of the ones that I haven't been able to get to work correctly. Any help would be greatly appreciated!

Thanks all,

Jason
# 2  
Old 12-02-2003
"Learning Perl" exercise answers are in Appendix A
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Grep commands for numbers w/decimal points

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Is there a grep commands for numbers w/decimal points Display lines for students with GPA above 3.69 but less... (3 Replies)
Discussion started by: jetoutant
3 Replies

2. Shell Programming and Scripting

Regarding change in column numbers after some commands

Hi All, I was using some commands to: replace a column by a constant string character awk -v a=CA 'NF>1{ $3=a; print; } ' $line>$line"_1" to copy a column and paste it in another place awk '$5=$2" "$5' $line>$line"_2" to delete the extra columns awk '{for(i=1;i<=NF;i++)... (9 Replies)
Discussion started by: CAch
9 Replies

3. Shell Programming and Scripting

awk & remove other than numbers

lsps -s | awk '{print $1}'|tail -1 71680 MB lsps -s | awk '{print $2}'|tail -1 2% vmstat |grep lcpu |awk '{print $3}' lcpu=8 I need to removt the MB % lcpu= from the outputs so they can show as 71680 2 8 respectively. Please advise. Thank you so much, (8 Replies)
Discussion started by: Daniel Gate
8 Replies

4. UNIX for Dummies Questions & Answers

Magic numbers '&' operator problem

Hello everyone, on the man page of "magic(5)" There is explanation "&, to specify that the value from the file must have set all of the bits that are set in the specified value" . My question is that what is the difference between '&' and equal operator '=' ? I tested it with file... (6 Replies)
Discussion started by: segmentation
6 Replies

5. Solaris

Preferred Solaris 10 AMP stack

Hi all, After being dumped in a Solaris sysadmin role, i have been trying to tidy the unpatched mess I have inherited. Part of this task is to update the current AMP stack. The current stack is Webstack 1.5, which was current in 2009, and as far as I can see, no longer supported. Post the... (2 Replies)
Discussion started by: Sol-nova
2 Replies

6. Shell Programming and Scripting

Append && echo "success" to all commands

I am learning to build from SVN and other tools, with a lot of copying and pasting from forums. I like to append && echo "success" to all commands so that I can see at a glance if things went all right. Is there a way that I can have the bash shell append this to all commands? Thanks! (5 Replies)
Discussion started by: dotancohen
5 Replies

7. Shell Programming and Scripting

Ascending & Descending order numbers

Dear All, I have below attached file in which i have many nos, i want the last ascending order nos. The brief description is given below. File 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 (6 Replies)
Discussion started by: pravani1
6 Replies

8. Programming

User Frame & Stack

Can anybody tell me what a user frame & stack looks like on a sun, hp, powerpc system? (0 Replies)
Discussion started by: John Budnik
0 Replies
Login or Register to Ask a Question