I am getting the same error, I have initialized the variable used in chomp function but the problem is still persisting.Any idea why?
if ($navTitle) {chomp($navTitle);}else{# Do something here because you have no title if you actually care}
if ($breadcrumb =~m!(.*)>(.*)!){ $navTitle = $2; chomp($navTitle);} else {#regex failed}
Because you initialized the variable doesn't mean squat. You assign it to $2 after a regex. If that regex fails, $2 and then your variable are null.Change line 13 to this: if ($navTitle) {chomp($navTitle);}else{# Do something here because you have no title if you actually care} The truly best way to handle this is if ($breadcrumb =~m!(.*)>(.*)!){ $navTitle = $2; chomp($navTitle);} else {#regex failed}
...if ($breadcrumb =~ m!.*>(.*)!) { chomp($navTitle = $1);}else { # regex failed? chomp($navTitle = $breadcrumb); ?}...
.*