AWESOME reply. Thank you! I did read experiment a bit before I came back. And got this to work...
$control[0]{"play"} = "/false/;
$control[0]{"ctrl"} = "/false/;
$control[0]{"loop"} = "/false/;
% control = map { $_ => 'true' } split ' ', $4;
Which I understand much better after reading your post.
I like your version much more:
my %control = map { $_ => 'false' } qw(play ctrl loop);
$control{$_} = 'true' for split ' ', $4;
(thanks for qw tip)
I don't understand in the 2nd to last example,
my %control = map { $_ => 'true' } split ' ', $4;
%control = ((map { $_ => 'false' } qw(play ctrl loop)), %control);
why the hash is not reinitialized when the 'false's are applied. Isn't this your first caveat at the start of your post? I know it has something to do with the last %control...
I now also wonder how I would use flags and then assign specific values to the specific options w/o a lot of tests.
<code>
# [
src.mov -bfd] b=big, f=fast, etc..
%control = ((map { $_ => 'off' } qw(play ctrl loop)), %control);
??
Thanks Perl Monk!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.