queue problem perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting queue problem perl
# 1  
Old 09-27-2011
queue problem perl

Hi, I have implement queue but it take last element instead of fist element
Code:
#!/usr/bin/perl -w

print "Enter page Access";
chomp ($item = <STDIN>);
my @queue = split /\s+/, $item;
print "Enter a page frame";
$frame = <STDIN>;
if ( $frame >= 3 )
{
    $fifo = pop @queue;

    print "Remove FIFO item: $fifo\n";
    print "Final queue:\n  @queue \n\n";

}

output
Code:
Enter page Access1 2 3 4 5 6 7 8
Enter a page frame3
Remove FIFO item: 8
Final queue:
  1 2 3 4 5 6 7

# 2  
Old 09-27-2011
Use "shift" to remove the first element.

Code:
$fifo = shift @queue;

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to write Perl Script to Get MQ Queue Depth?

Hi , I got the following script from internet to display queue depth using Perl Script. However, when I execute it , im getting following error. Can anyone shed light on what is going wrong? #!/usr/bin/perl ## 07/23/01 ## Depth Inquiry sample program. ## Arguments: ## Connects to... (11 Replies)
Discussion started by: srkmish
11 Replies

2. Shell Programming and Scripting

Check if Queue empty or full in perl

Hi, I got problem with queue code how to determined empty and full and problem with while loop Here is my pseudo code : Input page Access Input Pgae Frame For i =3 to pageframe count by 1 construct queue of size i set pageFaultCount to 0 while morepages do page = NextPage... (1 Reply)
Discussion started by: guidely
1 Replies

3. UNIX for Dummies Questions & Answers

problem submitting job to queue

Hi, I am trying to submit a job to a queue on a cluster. When I run the job ( python script) from the command line it runs without putting python at the start. The script imports everything from another congifuration file (.config) but when I submit to the queue it tells me there is no module... (0 Replies)
Discussion started by: i-dont-know
0 Replies

4. AIX

Problem with Queue of the Printer

Guy's This is the Queue of the printer ... >lpstat -pTOPPRINTER Queue Dev Status Job Files User PP % Blks Cp Rnk ------- ----- --------- --- ------------------ ---------- ---- -- ----- --- --- TOPPRIN @TOPP DOWN QUEUED ... (1 Reply)
Discussion started by: ITHelper
1 Replies

5. Programming

Message Queue Problem

Hi all, I need help about message queues, i have a server-client program that communicates each other via msg queue, firstly server opens its msg queue and waits for msg then client opens server msg queue and its own msg queue(for receiving msg from server,clients sends msg to server msg... (7 Replies)
Discussion started by: SaTYR
7 Replies

6. Programming

[C]Problem removing a message queue

Hi!! This code works if I don't remove the message queue. In A.c I create 3 processes that send a message in a message queue. in B.c other 3 processes receive 1 message for each (the messages sent from A), change the value of "dato" and put again the message in the queue. The processes in A.c... (0 Replies)
Discussion started by: Sentinella
0 Replies

7. IP Networking

message queue problem

I am sending and retriving the message to the queue the problem is after retrieving the message can i see what is there in my message queue. (actually in my application i am encountring some garbage value) so i want to retieve this garbage value and also want to know its size how... (0 Replies)
Discussion started by: ramneek
0 Replies

8. UNIX for Dummies Questions & Answers

Problem with print queue

I have a problem with a print queue that keeps going down on me every couple of days. When it happens I run an 'enable' and all is fine for a few more days. Can anyone can tell me where to start looking to debug this problem as i am new to UNIX Thanx (1 Reply)
Discussion started by: carell
1 Replies

9. Programming

Message Queue Problem Again..

Is there any way one can delete , say , a particular message from a message queue on system V? (2 Replies)
Discussion started by: satansfury
2 Replies

10. UNIX for Dummies Questions & Answers

Cron message queue problem

I have a problem with running jobs out of cron on Solaris 8. Initially when one of the users on the box (other than root) attempted to save the crontab after modification by using "crontab -e", the message "Crontab: cannot open the crontab file in the crontab directory" was given. I then... (7 Replies)
Discussion started by: mattd
7 Replies
Login or Register to Ask a Question