CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: General Discussions: General Questions: Re: [Laurent_R] Good afternoon!: Edit Log



ryanthelion91
New User

Nov 23, 2016, 8:29 AM


Views: 24121
Re: [Laurent_R] Good afternoon!

Hey, so I figured out what I was trying to do. I'll put some code here:

Code
#!/usr/bin/perl 
use 5.010;
use List::Util qw(sum); # This function sums our array in line 15
use strict;
use warnings;
say "Awaiting input: ";
my $text = <STDIN>;
chomp $text;
my $textsaver = $text;
$text=~ tr/abcdefghijklmnopqrstuvwxyz/12345678912345678912345678/;
$text=~ tr/ABCDEFGHIJKLMNOPQRSTUVWXYZ/12345678912345678912345678/;
my @wnums = split / /, $text;
foreach my $wnums(@wnums) {
my @lnums = split(//, $wnums);
my $wtotal = sum @lnums;
print " $wtotal ";
}



(This post was edited by FishMonger on Nov 23, 2016, 9:53 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Nov 23, 2016, 9:53 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives