[Vienna-pm] Parameteruebergabe

Thomas Klausner domm at zsi.at
Mon Jan 3 09:03:52 CST 2005


Hi!

On Mon, Jan 03, 2005 at 02:55:15PM +0100, e_horn at fh-bingen.de wrote:

> Wie kann ich den Wert von $id hier in ,my $url importieren?
> my $url=&get_s("nucl",$id);

> sub get_s($da,$id)
> {
> 	my $url='http...db=';
> 	my $da=$_[0];
> 	my $id=$_[1];
>  	my $pa='&id=';
>   	my $m='&retmode=xml';
> 	return $url.$da.$pa.$id.$m;
> }

Hmm, also die Sub ist zwar etwas seltsam geschrieben, sollte aber
funktionieren (zumindest krieg ich mit perl 5.8.5 
   http...db=nucleo&id=123&retmode=xml
zurueck).

allerdings wuerde ich dass eher so schreiben:

sub get_s {
    my $da=shift;
    my $id=shift;
    return "http...db=$da&id=$id&retmode=xml";
}

bist du sicher, dass die von get_s zurueckgegeben URL stimmt?


-- 
#!/usr/bin/perl                               http://domm.zsi.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}


More information about the Vienna-pm mailing list