Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Perlprogramm mit Paremetern aufrufen

Empfohlene Antworten

Veröffentlicht

Servus,

wie kann man den ein Perlprogramm mit Parametern aufrufen?

Bzw., wie kann die zusätzlichen Benutzereingaben beim Aufruf des Programms als Parameter interpretieren?

Volkaman.

Meinst Du auf Kommandozeilen-Ebene oder einfach über einen Browser?!

Bei einem Browser:

http://www.deinedomain.de/cgi.bin/script.pl?var1=wert1&var2=wert2&varN=wertN

Dann machst Du das im Skript so:

use CGI qw/:all/; # einbinden des CGI Moduls

my $variable1 = param('var1'); # mittels der Funktion param den entsprechenden wert/variable einlesen

my $variable2 = param('var2');

my $variablen = param('varN');

Auf Kommandozeilen-Ebene sollte es so funktionieren:

perl scriptname.pl -wert1 -wert2 -wert3

Die Übergebenen Werte stehen dann in dem Array $ARG{...}.. oder $ARGV.. da bin ich mir nicht mehr soo sicher.

Hab nochmal nachgeschlagen,.. die übergebenen Kommandozeilen Parameter stehen in @ARGV.

ja, das stimmt, das hätt ich Dir auch ohne Nachzuschlagen sagen können. Sei's drum.

Die, wie ich finde schönste Möglichkeit das auszuwerten ist folgende:

while ($#ARGV > -1)

{

	$CMDLINE = shift @ARGV;

	if ($CMDLINE eq "/a")

	{

		$A = shift @ARGV;

	}

	elsif ($CMDLINE eq "/b")

	{

		$B = shift @ARGV;

	}

	elsif ($CMDLINE eq "/c")

	{

		$C = shift @ARGV;

	}

	.

	.

	.

	else

	{

		print STDERR "invalid cmdline arg... usage: $0 /a <a> /b <b>/c <c> ..."

	}

}

Dann noch $A $B $C ... auf Gültigkeit testen und fertig ist der Lack...

ZäR

Sorry, Streiche:


print STDERR "invalid cmdline arg... usage: $0 /a <a> /b <b>/c <c> ..."

Setze:

print STDERR "invalid cmdline arg... usage: $0 /a <a> /b <b>/c <c> ...";

Danke!!!!!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.