Perl: Receiving an early number from one to two



  • Hello, the syntax of the pellet is not familiar, but the early value between the unit and the double after the function. There's a function that depends on the parameter to be assigned 2.

    Generate(17, "test",3,1 , 2);
    

    Actually, no matter what the first arguments mean, it's the last one. In the function itself, its value shall be as follows:

    my %values = ('CAT' => $dbCategoryUrl,'CATNAME' =>$dbCategoryName , 'TEST' =>$test );
    

    and only 2 after performance, indicate how to perform a function that is given an early value 1 or 2 after performance. Thank you.



  • To get an accident number one or two, use this design.

     int(rand(2)+1)
    

    Can we make them crazy?

    Yes, it is.

    #!/usr/bin/perl
    

    use 5.018;
    use strict;
    use warnings;

    {
    my $counter = 1;
    sub getNext {

    $counter = 3 - $counter;
    return $counter;
    

    }
    }
    for (1..100) {
    print getNext(), "\n";
    }




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2