Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]8915[/thread]

Ambiguous call resolved as CORE::close() [gelöst]

Leser: 13


<< >> 6 Einträge, 1 Seite
RalphFFM
 2007-04-11 17:16
#75952 #75952
User since
2006-11-16
258 Artikel
BenutzerIn
[Homepage] [default_avatar]
Was ist mit "qualify as such" gemeint in der Warnmeldung:
"Ambiguous call resolved as CORE::close(), qualify as such or use & at ftp.pm line 271."
Der Code an dieser Stelle sieht so aus:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
vec($rin,fileno(DATA),1) = 1;
for (;;) {
$condition = ($Timeout == 0) || select($rout=$rin, undef, undef, $Timeout);
if ($condition) {
last unless ($len = sysread(DATA, $buf, 1024));
if($Ascii) {
substr($buf,0,0)=$partial; ## prepend from last sysread
@buf=split(/\r?\n/,$buf); ## break into lines
if ($buf=~/\n$/) { $partial=''; } else { $partial=pop(@buf); }
foreach(@buf) { print DFILE $_,"\n"; }
} else {
last unless ( (syswrite(DFILE,$buf,$len)==$len) );
}
} else {
$Error = "Timeout while recieving data from $Host";
return &xferclean();
}
}
close DATA; # <-- Zeile 271 #################
close DFILE;


Ähnlich eine Warnmeldung an anderer Stelle:
"Ambiguous call resolved as CORE::open(), qualify as such or use & at ftp.pm line 450."
Code: (dl )
1
2
3
4
5
6
7
8
local($local, $remote) = @_;  
local($ret, $len)=(0,0);
local($buf);
($remote = $local) unless $remote;
unless (open(DFILE, "$local")) { # <-- Zeile 450 ##########
$Error = "Open of local file $local failed: $!";
return undef;
}


Wie kann ich diese Konstrukte ordnungsgemäß deklarieren, d.h. die Warnmeldungen vermeiden?
Im voraus vielen Dank für Infos. Mit Google habe ich nichts gefunden was weiter geholfen hat.
renee
 2007-04-11 17:29
#75953 #75953
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Aus perldiag

Quote
Ambiguous call resolved as CORE::%s(), qualify as such or use &

(W ambiguous) A subroutine you have declared has the same name as a Perl keyword, and you have used the name without qualification for calling one or the other. Perl decided to call the builtin because the subroutine is not imported.

To force interpretation as a subroutine call, either put an ampersand before the subroutine name, or qualify the name with its package. Alternatively, you can import the subroutine (or pretend that it's imported with the use subs pragma).

To silently interpret it as the Perl operator, use the CORE:: prefix on the operator (e.g. CORE::log($x) ) or declare the subroutine to be an object method (see "Subroutine Attributes" in perlsub or attributes).


Du musst also das Package angeben... Entweder CORE::open oder eben DeinPackage::open...
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
rosti
 2019-01-29 16:23
#189657 #189657
User since
2011-03-19
3180 Artikel
BenutzerIn
[Homepage]
user image
Hi,

komischerweise kriege ich diese Meldung auch trotz Angabe der package:

Code (perl): (dl )
1
2
3
my $sca = ScaligerTime->time( time() ) or die $@;

Ambiguous call resolved as CORE::time(),...


Hatte ich noch nie und verstehe das auch nicht.

MfG
renee
 2019-01-30 10:32
#189663 #189663
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Benutzt Du Exporter oder so?
In dem Code wird ja zweimal time aufgerufen... Das erste (ScaligerTime->time()) dürfte nicht das Problem sein, sondern wahrscheinlich das innere time().
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
rosti
 2019-01-30 10:44
#189664 #189664
User since
2011-03-19
3180 Artikel
BenutzerIn
[Homepage]
user image
Nein, kein Exporter. Und ja, es ist das innere time(), wenn das als CORE::time() notiert wird, ist die Warnung weg.

Wie gesagt, was dahintersteckt ist klar, aber so hatte ich das noch nicht. Für mich und meine Module jedoch der Anlass, die Klassenmethode nicht time() sondern new() zu nennen. Zumal ScaligerTime ohnehin von Scaliger erbt.

Es ist nur so, daß ich dieselbe Library auch in C entwickelt habe. Und da bleibts beim Namen time().

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
typedef struct SCA{
int jd; // Julianday
int day; // as created
int month; // wie erstellt
int year; // wie erstellt
int leap; // 1 || 0
char age; // G || J
int wd; // DoW Mo:1,, So:7
int hour;
int minute;
int second;
} SCA;


SCA *scaliger_day(int julianday);
SCA *scaliger_date(char age, int day, int month, int year);
SCA *scaliger_time(int secsince);




MfG
Gast Wolfgang
 2020-06-25 21:43
#192400 #192400
Danke
Last edited: 2020-06-25 22:02:38 +0200 (CEST)
<< >> 6 Einträge, 1 Seite



View all threads created 2007-04-11 17:16.