Hi, This is just my two cents. I tend write very verbose code (sorry in advance). Most of what I point out here may be obvious.
$current_url = "http://www.domain.com/sub/name/anothername/page4/"; print "1. $current_url\n"; $save = $current_url; # adding "|| die" will alert you to a pars problem. $current_url =~ s/.*?\/(page\d+).*/$1/ || die "Cant pars $current_url\ +n"; print "$current_url\n"; # I personally like to do this, It's a lot more code but it allows # you to recoved from a pars error. # or ignore URL's that dont match your expected format) $current_url = $save; print "2. $current_url\n"; if ($current_url =~ /^http[s]{0,1}:\/\/.+\/page(\d+).*$/i) { $current_url = $1; print "Decimal page number is: $current_url\n"; } else { print "pars error on $current_url\n"; #Do what you may with this issue, but you # know it happened... }
In reply to Re^3: Stripping part of URL
by mark4
in thread Stripping part of URL
by htmanning
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |