I have a foreach loop that operates on the elements of an array. However, the size of the array is variable. Here is the code segment:
if ($#name>1) {
.
.
.
foreach my $part ($name[2..$#name]) {
.
.
.
Occasionally $#name will evaluate to 2. That seems to be...
Once again, thanks for your help. I pretty much copied and pasted what you proposed. Here is the code segment in question:
my $string="NOV 1939";
($date,$place)=$string=~/(.*?\d{4}) ?(?:,(.+)$)?/;
print length($date)," - ",length($place),"\n";
Thanks. Not very satisfying but at least I was right in my understanding of the problem. You are correct, it will require a lot of complex code to try and cover as many bases as possible.
Sorry but I'm having a problem in the case where there is no location part. It seems that any time I try to use $location, I get an error saying it is uninitialized. How do I handle that to avoid the error? TIA.
In this case the relative links start with ../blah/blah. What is not clear is how much of the full URL I need to store. For example:
http://www.domain.com/dir1/dir2/dir3/page.html
On that page is the URL:
../dir3a/another.html
Then suppose the URL is:
../../dir2a/third.html
Is it legal to...
I need to follow some links using LWP (simple). However, some of the links are relative. Does anyone have an easy way to parse a relative URL to complete it? TIA.
That is great. Thanks for taking the time.
I think one thing that confused me is the '.'. I thought that meant at least 1 character but maybe the following '?' fixes that. The trailing '?' means that it is an optional substring? So what is the difference between '.*?' and just '*'?
The '?:' is...
Thanks. Let me understand this a little before I try it. First is it not clear (I'm not a perl expert) how the regexp knows what to work on. I guess it is a special featur of the for loop but I'll need it to work on a variable. Anyway, let me test my meager regexp knowledge:
'.*' means 1...
I have been racking my brain to come up with an efficient way to parse a string. I am hoping those more experienced then me can come up with something. I suspect a regexp is the answer if I can come up with the right template but I am not a regexp expert.
I need to parse a string that contains...
Thanks for the reply. I'm not too worried about the termination condition. I've written plenty of recursive applications (mostly C) but never with perl. I'm writing an HTML to GED conversion application. Since I want it to go up and down the branches, recursion seems the easiest way to go.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.