Page 2 of 2 First 12
  • Jump to page:
    #16
  1. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,263
    Rep Power
    1810
    Either of these methods work:

    Code:
    my $rhash= {
        lbl_emri    =>  "Lau",
        lbl_mbiemer =>  "xha",
        txt_emri    =>  "emri",
        txt_mbiemri =>  "mbiemri",
        btn_submit  =>  "submit",
    };
    
    foreach my $key (sort keys %$rhash) {
    	if ($key =~/^lbl/){
    		print "$key\n";
    	}
    }
    
    my @wanted = grep /^lbl/, sort keys %$rhash;
    foreach my $label (@wanted) {
    	print "$label\n";
    }
  2. #17
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    335
    Rep Power
    246
    sub label_input {
    my $value = @_;
    return "<label >value</label>";
    }

    sub txt_input {
    my $value = @_;
    return "<textarea >value</textarea>";
    }

    sub btn_input {
    my $value = @_;
    return"<button type="button">value</button>";
    }
    If you only want the first element of the @_ array in scalar context it is better to use
    Code:
    my $value = shift;
    Also you have missed the $ off of your returns so 'value' is just text not $value

    Also you have not escaped the quotes for "button" and you should have a space between the return command and the return value.

    Comments on this post

    • Laurent_R agrees : It is not better to use shift, it is far far better. "my $value = @_;" will assign to $value the number of elements of the @_ array.
    Free MP3 Dance Music Downloads

    To err is human; To really balls things up you need Microsoft!
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo