mentby.com
Blog | Jobs | Help | Signup | Login

loading

Tell me how to use CGI.pm in table

Sat, 18 May 2013 01:19:26 -0700 Post Comments

Hi Masayoshi,

  The line above gives a warning message: Odd number of elements in hash
assignment.

You can re-write that like so:

  my $radio = $q->radio_group(
    -name    => 'celeb',
    -values  => [ 'Hilary Duff', 'Taylor Momsen' ],
    -default => 'Hilary Duff');

my %form = (
    celeb  => $radio,
    submit => $q->submit,
    reset  => $q->reset,
);

--
Tim

map problems

Thu, 16 May 2013 14:27:38 -0700 Post Comments

Hi Natxo,
Please see my comment below:

Since you use  "qw", there is no need to still separate the element of
your array with comma.

  Does etc etc here mean words like group...?

    Understanding for/foreach loop could help in a way to understand and
use map function.

    Please see below one of the way of doing what you intended:

  [CODE]

  use warnings;
  use strict;

my @memberof  qw( cn=group1 cn=xxx dc=domain dc=tld cn=group2 cn=xxx d=domain dc=tld
etc etc);

## using for loop

for my $grp (@memberof) {
    if ( $grp =~ m/(?<=\=)(.+)/ ) {
        my $matched = $1;
        print $matched, $/ if $matched =~ /group/;
    }
}

## use map function

@memberof = map {
    if (/(?<=\=)(.+)/) {
        my $matched = $1;
        $matched, $/ if $matched =~ /group/;
    }
} @memberof;

print @memberof;

  [/CODE]

Hope this helps.

--
Tim
Hi Dariusz,

You don't have to install warnings is already installed for you, when perl
was installed.

  Check first if you have the module installed before trying to install all
over again. If a module is installed, most likely it would have it's
documentation so, you could do like so from the CLI `perldoc File::Find`.
Checking for the documentation of the module File::Find.

--
Tim
Group(s)
Profile Widget
Copy and paste this HTML code to your blog or website: