Did not find leading dereferencer

R

Ronny

I get a weird error message saying

"Did not find leading dereferencer, detected at
offset 6728syntax error at ... near "mk_remote_filename"

The expression in question is this:

join(' ', 'rcp', map(mk_remote_filename, @_))

where mk_remote_filename is a sub defined earlier, prototyped
as

sub mk_remote_filename($)

Maybe Perl doesn't like the isolated occurence of the bareword
mk_remote_filename here (it doesn't look very perlish to me),
but when I check the perldoc for the function map, it mentions
a very similar construct. From the perldocs:

"@chars = map(chr, @nums);
translates a list of numbers to the corresponding characters."

What am I doing wrong? Of course I could also write
(map { mk_remote_filenam $_ } @_)
but I wonder why it doesn't work the way I wrote it.

Ronald
 
P

Paul Lalli

Ronny said:
I get a weird error message saying

"Did not find leading dereferencer, detected at
offset 6728syntax error at ... near "mk_remote_filename"

Odd, I can't find that entry anwhere in my `perldoc perldiag` (This is
perl, v5.8.4 built for sun4-solaris). What Perl version and OS are you
using?
The expression in question is this:

join(' ', 'rcp', map(mk_remote_filename, @_))

where mk_remote_filename is a sub defined earlier, prototyped
as

sub mk_remote_filename($)

Maybe Perl doesn't like the isolated occurence of the bareword
mk_remote_filename here (it doesn't look very perlish to me),
but when I check the perldoc for the function map, it mentions
a very similar construct. From the perldocs:

"@chars = map(chr, @nums);

Similar, but not at all identical. chr is a built-in function that
specifically uses the value of $_ if no other value is passed to it.
Your user-written subroutine has no such magic.
translates a list of numbers to the corresponding characters."

What am I doing wrong? Of course I could also write
(map { mk_remote_filenam $_ } @_)
but I wonder why it doesn't work the way I wrote it.

Get rid of the prototype. You shouldn't be using them anyway. Then
try putting something like this in your subroutine:

my $arg = @_ ? shift : $_;

and do to $arg whatever you were doing to $_[0] in the original.

I still have no idea what that error message you're talking about
means, so the above is all guesswork. If it doesn't help, please post
a SHORT but COMPLETE script that demonstrates your error.

Paul Lalli
 
R

Ronny

Paul said:
Odd, I can't find that entry anwhere in my `perldoc perldiag` (This is
perl, v5.8.4 built for sun4-solaris). What Perl version and OS are you
using?

5.8.3 for Linux
Get rid of the prototype. You shouldn't be using them anyway. Then
try putting something like this in your subroutine:

my $arg = @_ ? shift : $_;

and do to $arg whatever you were doing to $_[0] in the original.

I did and, and now it works! Thank you very much for your help.

Ronald
 
M

Mumia W.

I get a weird error message saying

"Did not find leading dereferencer, detected at
offset 6728syntax error at ... near "mk_remote_filename"

The expression in question is this:

join(' ', 'rcp', map(mk_remote_filename, @_))

where mk_remote_filename is a sub defined earlier, prototyped
as

sub mk_remote_filename($)

Maybe part of the problem is that you prototype the sub as
requiring a scalar parameter, but you don't give it any
parameters in the call.
Maybe Perl doesn't like the isolated occurence of the bareword
mk_remote_filename here (it doesn't look very perlish to me),
but when I check the perldoc for the function map, it mentions
a very similar construct. From the perldocs:

"@chars = map(chr, @nums);
translates a list of numbers to the corresponding characters."

Yes, but chr can function without any parameters.
What am I doing wrong? Of course I could also write
(map { mk_remote_filenam $_ } @_)
but I wonder why it doesn't work the way I wrote it.

Ronald

Try this: map mk_remote_filename($_), @_

Or you could define mk_remote_filename to not have a prototype
and use your old code.
 
S

sfelkes

Hi,

I'm getting the same error

Uncaught exception from user code:
Did not find leading dereferencer, detected at offset 8231.

Its very frustrating because it's not relating it to a specific line of
code and I have 8000 lines of code in my Perl module. Often I can use
my Perl module find but then when I put in a simple print statement in
I get the error. Could you tell me what type of things cause this
error?

I used to use prototypes but I took those out. Instead in subroutines I
dereference as @{ $_[0] ) when I'm expecting an array as one of my
arguments and @_ when an array is the only argument. I use my $hash =
$_ when a hash is passed as the only or one of the arguments. I
store references to arrays as $array[$i] = \@array.

Any ideas?

Cheers,

Sean
 
M

Mumia W.

Hi,

I'm getting the same error
[...]

Any ideas?

Cheers,

Sean

Hi Sean, I have no ideas. No one seems to know what "Did not
find leading dereferencer" means. It's not in perldiag, and
the string doesn't appear in the Linux perl (5.8.4) binary:

$ strings perl | grep dereferencer
[ empty ]
 
T

Tad McClellan

I have 8000 lines of code in my Perl module.


You might consider a refactoring then.

Even heavy-hitters like CGI.pm and DBI.pm aren't that big.



[snip TOFU, please do not top-post!]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,652
Latest member
Campbellamy

Latest Threads

Top