I suspect that this may be before the statement separators (semicolons). As you may have noticed - with the code you use, the line number specified by caller is the same as the foreach .
So, I think what happens because there are no semicolons.
If you need to execute a multi-line subtitle, caller will report the first line:
print "first call:", __LINE__, "\n"; print "Start of statement\n", "a bit more on line ", __LINE__, "\n", print_line( 1, 2, 3, 5, );
You get the line number of the start of the call, not the end. Therefore, I think that what you get - the statement begins with a comma separator - is the foreach line in the first example.
So, as a workaround - I could suggest using __LINE__ . Although I also probably suggest that you donβt worry too much about it, because it will still point you to the right place in the code.
You get something similar if you use croak , for the same reason.
source share