The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
perl -write values in a file to @array in perl meghana Shell Programming and Scripting 27 06-07-2009 06:05 PM
How to Turn perl one-liners into full perl script? EDALBNUG UNIX for Dummies Questions & Answers 1 02-04-2009 10:49 AM
[Perl] Accessing array elements within a sed command in Perl script userix Shell Programming and Scripting 2 10-03-2008 01:05 PM
[PERL] Running unix commands within Perl Scripts userix Shell Programming and Scripting 1 05-28-2008 07:06 PM
Perl: Run perl script in the current process vino Shell Programming and Scripting 10 12-09-2005 10:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-25-2009
pnay711 pnay711 is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 1
Perl Help

Hello experts,

I am in need of some assistance on how start this off.

Prompt user to enter 10 random numbers
add only the even numbers
multiply the odd numbers
  #2 (permalink)  
Old 02-25-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,944
perldoc perlintro
perldoc perlop
and anything that a search for "Perl tutorial" might come up with. Also, you might want to re-read the forum rules, esp. Rule 6.
  #3 (permalink)  
Old 02-25-2009
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,092
Hope below can help you some


Code:
#!/usr/bin/perl
print "Input number\n";
while(<>){
	chomp;
	exit if $_ eq "q";
	print 2 * $_ if $_ % 2 ==0;
	print 3 * $_ if  $_ % 2 !=0;
	
	print "Input another\n";
}

  #4 (permalink)  
Old 02-26-2009
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
Quote:
Originally Posted by summer_cherry View Post
Hope below can help you some


Code:
#!/usr/bin/perl
print "Input number\n";
while(<>){
	chomp;
	exit if $_ eq "q";
	print 2 * $_ if $_ % 2 ==0;
	print 3 * $_ if  $_ % 2 !=0;
	
	print "Input another\n";
}
You shouldn't do students work for them. Instead tell them to look into the modulus operator or other tips, but just writing the code for them is not appropriate. Especially when they demonstrate no effort at all to write such a simple little program.
  #5 (permalink)  
Old 03-05-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,891
summer_cherry is an incorrigible altruist. What can one do?
  #6 (permalink)  
Old 03-05-2009
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
Quote:
Originally Posted by otheus View Post
summer_cherry is an incorrigible altruist. What can one do?
Ban him/her from the forum for doing students work for them. It should be just as bad a violation, or worse, than posting the schoolwork. But black is white and white is black in this cazy world. Oh well.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0