so I tried using some regex I usualy have used in php with preg_match but they don't seem to work. So I got the above regex after searching google..
and tbh I don't understand it..
What I understand from it : href followed by none or more whitespaces followed by = followed by none or more whitespaces followed by 0 or 1 " and afterwards... I don';t get it at all! it's really frustrating.
my second problem..
let's assume I have this array : @horse = ("mdamdamad" , "asdasda" ,"asdasd" ,"a");
I want to delete the element which is equal to "a".
foreach $key (@horse){
if ($key == "a"){
delete $horse[$key];}
}
the above code doesn't seem to work.. it deletes the @horse[-2] value. I have also tryied using $key =~ /a/ and (grep $key eq "a",@horse). All have failed me.. any suggestions? please...
Sry about using perl code in the php code tag must of missed the <code> tag.
Anyway I know about escaping the metacharacters, and I did that, but dunno for what reason I copied it wrong, not sure. thx for pointing that out though
One more question :
Afaik in a sub $_[0],$_[1] refers to the first and second parameter which was sent to the function (correct me if im wrong please). So for example I have
the problem is that @a in getindex only gets the first value of @horse , and not the entire array. How do I manage to pass to it the whole array?
edit: i found out the answer I had to use @a= @_;
#!C:\Perl64\bin\perl.exe -w
print "Content-Type: Text/plain\n\n";#<-- this is not necessary unless running as a CGI script
@horse = ("mdamdamad" , "asdasda" ,"asdasd" ,"a");
getindex ("asd",@horse);
sub getindex {
($string,@a) = @_;
print $string."\n";
foreach $key (@a){
print $key."\n";
}
}
You're going to want to learn how to use references in perl really quickly insterad of trying to pass mixed data types like int he code above. An example: