AwesomePerson has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Splits and Arrays, PLEASE HELP:D
by Corion (Patriarch) on Nov 04, 2013 at 19:25 UTC

    Have you reviewed your course material for the solutions?

    It's highly propable that your course material already provides you with all the information you need to tackle these tasks.

Re: Splits and Arrays, PLEASE HELP:D
by NetWallah (Canon) on Nov 04, 2013 at 21:03 UTC
    One of the reasons we don't simply give the answer is that if we gave you the following code:
    perl "-aF:|\s" -nE"$h{shift @F}+=shift @F while @F}{say qq|$_\t=$h{$_} +| for keys %h" YOUR-FILE-NAME.txt
    You probably would not learn anything, and may have difficulty explaining it.

    On the other hand, if you do take the trouble of researching each construct used in that code, you could learn a great deal, and if you have trouble understanding a particular aspect, we would be glad to help.

                 When in doubt, mumble; when in trouble, delegate; when in charge, ponder. -- James H. Boren

Re: Splits and Arrays, PLEASE HELP:D
by Old_Gray_Bear (Bishop) on Nov 04, 2013 at 19:28 UTC
    What class are you taking? If I write the code for you, I want the credit with your instructor.

    ----
    I Go Back to Sleep, Now.

    OGB

Re: Splits and Arrays, PLEASE HELP:D
by 2teez (Vicar) on Nov 04, 2013 at 20:01 UTC

    Hi AwesomePerson,
    Welcome to the Monastery.
    As much as perlmonks help in various ways, out rightly doing your work for you is not one of such.
    Believe me, if you give all of your proposed work some trial you will be surprised the legions of monks at your service helping you grow.
    Please check How do I post a question effectively?.
    Hope this helps.

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me
Re: Splits and Arrays, PLEASE HELP:D
by AnomalousMonk (Archbishop) on Nov 04, 2013 at 23:28 UTC

    Here's an answer, not necessarily the best, to PART 2, at least the string transformation portion thereof, but I'd strongly suggest you understand all of it before submitting it to your instructor lest embarrassing questions be asked. (See List::Util for the  sum() function)

    >perl -wMstrict -le "use List::Util qw(sum); ;; my $s = 'r1y2g3g4y2r4r3y5y3g3g6g2r1'; my $r = 'r 1 y 2 g 7 y 2 r 7 y 8 g 11 r 1 '; ;; $s =~ s{ (([[:alpha:]]) \d+ (?: \2 \d+)*) } {$2 ${ \sum $1 =~ /\d+/g } }xmsg; print qq{'$s'}; ;; $s eq $r or die 'not what was wanted'; " 'r 1 y 2 g 7 y 2 r 7 y 8 g 11 r 1 '

    Notice that I had to cheat a bit to make this work: the extra space at the end of the  $r "required output" string. Can you alter the substitution to get rid of this extra space, perhaps by adding a  (\z)? or  (\Z)? term to the regex and modifying the replacement expression accordingly?

Re: Splits and Arrays, PLEASE HELP:D
by marinersk (Priest) on Nov 05, 2013 at 18:22 UTC
    The final pro- gram, for

    LOL! Not even bothering to rephrase the question, it is cut and pasted directly from the homework assignment.