Eko Budiharto <> wrote:

: 1. How to count the number data in an aray.

    You need to evaluate the array in scalar context. Read the 
'perldata' file in the documentation for details.
    
my @integers = 1 .. 10;
my $count        = @integers;

    Print normally calls arrays in list context. Perl includes the
scalar() function to change context.

print scalar @integers, " integers in the array.\n";


: 2. is there anyway that I can do converting data to something
: else using method like eof (end of file). What I mean is using
: while and do converting until the last data in array.
:
: my @Category = join(", ", $cgi->param('Category'));
: 
: the result will comes up like this J1001, J1002
: 
: And then I would like to convert them into A, B (I have
: definitions that is using "if" statement) 
: if ($Category eq "J0000") {
:  $jCategory = "-";

    I assume the "j" is a typo.

: } elsif ($Category eq "J1001") {
:  $Category = "A";
: } elsif ($Category eq "J1002") {
:  $Category = "B";
: }

my @Categories = $cgi->param('Category');

foreach ( @Categories ) {
        s/J1001/-/;
        s/J1001/A/;
        s/J1002/B/;
}

my $categories = join ',', @Categories;


    You should read up on perl's regular expressions and on its
foreach loops. Try reading the 'perlretut', 'perlrequick', and
'perlsyn' files in the documentation.

HTH,


Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.4 - Release Date: 2/1/2005
 

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to