CGI/Perl Guide
|
Learning Center
|
Forums
|
Advertise
|
Login
Site Search:
in
Perl Guide
PerlGuru Forums
Learning Ctr
MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN
Home
:
Perl Programming Help
:
Intermediate
:
Subtract two arrays
Print Thread
dwarnold45
Novice
Jul 19, 2011, 4:38 PM
Post #1 of 3 (643 views)
Subtract two arrays
Can't Post
All,
If I have @a=(5,6,7) and @b=(1,1,1), what's the best way to find the difference @d=(4,5,6)?
D.
BillKSmith
Veteran
Jul 19, 2011, 7:57 PM
Post #2 of 3 (632 views)
Re: [dwarnold45] Subtract two arrays
[
In reply to
]
Can't Post
Use the function pairwise in the module List::MoreUtils. Refer: perldoc List::MoreUtils.
Good Luck,
Bill
miller
User
Jul 23, 2011, 2:47 AM
Post #3 of 3 (605 views)
Re: [dwarnold45] Subtract two arrays
[
In reply to
]
Can't Post
Code
my @a = (5,6,7);
my @b = (1,1,1);
my @d = map {$a[$_] - $b[$_]} keys @a;
print "@d";
- Miller
Announcements
PerlGuru Announcements
Perl Programming Help
Frequently Asked Questions
Beginner
Intermediate
Advanced
Regular Expressions
mod_perl
DBI
Win32 Programming Help
Fun With Perl
Perl Quizzes - Learn Perl the Fun Way
Perl Golf
Perl Poetry
Need a Custom or Prewritten Perl Program?
I need a program that...
I Need a Programmer for Freelance Work
Throw Down The Gauntlet
General Discussions
General Questions
Feedback
Tutorial/Article Suggestions for The Learning Cent
Internet Security
Other Programming Languages
Javascript
PHP
Search
this forum
this category
all forums
for
All words
Any words
Whole Phrase
(
options
)
Powered by
Gossamer Forum v.1.2.0
Web Applications
&
Managed Hosting
Powered by Gossamer Threads
Visit our
Mailing List Archives