Hi fellow Monks!
I am encountering this error "Use of uninitialized value $word in print at C:\test\test.pl" every time I put anchors ^ or $ beside the variable $key. My goal here is to grab the exact searchword in the list and return its corresponding website. I am having trouble when in case that my searchword is "ICS" (which has an empty website in the list) but instead returning "TRONICS" which has a value.
Here is my code:
my $key = "searchword"; my $path = "C:\\test\\list.txt"; open(INFILE, "<$path"); while (<INFILE>) { if ( /^$key\t(www\.[^.]*\.com)/i ) { my $word = $1; } } print $word; close(INFILE);
Thank you in advance for adding your inputs in to this one!
In reply to Use of uninitialized value in regexp by bbb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |