Unfortunately I don't have the time to see what this is really about and to delve into your code in its entirety. I have a few general remarks that hopefully will help you anyway...

Update: eventually I checked the rules and I provide some minimal but complete working example here: 433664.

#!/usr/bin/perl # Shuffles cards
Always -yes: always!-
use strict; use warnings;
in all but most trivial code (e.g. one-liners). This does not address your specific issue, but applies to any issue...
@pack = (1, 2, 3, 4, 5, 6, 7, 8);
As a side note, since you use .. below, I can't see why you don't use it here too...
sub b { push(@pack, shift @pack); }
Hmmm, while occasionally it can be handy to have a sub manipulating some "global" data, parameter passing is generally a much better solution. It's what a function is for.

I suggest you read something about @_, e.g. perlsub.

sub i { my ($a, $b, $c, $d, $e, $f, $g, $h) = @pack; @pack = ($e, $a, $f, $b, $g, $c, $h, $d); } sub o { my ($a, $b, $c, $d, $e, $f, $g, $h) = @pack; @pack = ($a, $e, $b, $f, $c, $g, $d, $h); }
Ditto as above. But then you may also use slicing instead. In that case you may also "generate" the subscripts rather than hardcoding them, but I agree that in this case you wouldn't earn much and probably hardcoding them is the best choice...

Also, it is always recommended to avoid using $a and $b as general purpose variables. This can lead to confusion and gotchas (see perlvar).

sub parse { my ($string) = @_; print "\nParse $string: "; foreach $offset (0..(length($string)-1)) { $char = substr($string, $offset, 1);
I think that most people here would write
for (string =~ /./g) { # ...
or
for (split //, $string) { # ...
instead. As a side note I would also have (a local()) $_ instead of $string and so I'd have
for (/./g) { # ...
or
for (split //) { # ...
respectively.
if ($char =~ /b|i|o/) { print "bio "; &{$char}; }
Ouch!
elsif ($char =~ /\d/) { print "digit "; # foreach (1..$char) { &parse(substr($string, $offset+1)); +}
Ditto as above. Also, apart that the line is commented out, do you really want to have 1..$char?!?

Update: never mind, there's nothing wrong a priori with 1..$char above, only you now have foreach (1..$char) but you use $offset as if it were the loop iterator, in the loop.

Well, I couldn't go past this point in your code in detail, but fundamentally it seems to me that the same cmts as above apply. I will look into the rules and maybe provide some minimal sample code as time permits. (But then I'm sure others will do!)


In reply to Re: Shuffling cards by blazar
in thread Shuffling cards by amnesty_puppy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.