Help Please!!! External APP passing value to Perl

Hello Listners,

I am totally novice in perland I need help with that script.
what can be the syntex of assigning a variable (my $path) in perl which is
taking value (for example c:\documents\script.txt) from an expternal APP.
The script will actually parse the my$path value (C:\documents\script.txt)
to (script.txt) and then will send parse value of my$path to STDOUT.
I am not sure how should I declare the value of my$path.

The script looks like this

\#!/usr/bin/perl
use strict;
use File::Basename;

my $path = Variable from external app
my $base = basename($path);
my $dir = dirname($path);
print STDOUT $base;


I will really appreciate any help/comment on it.

thanks



--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
perl [ Fr, 22 Juli 2005 16:50 ] [ ID #891130 ]

Re: Help Please!!! External APP passing value to Perl

On Jul 22, Perl said:

> what can be the syntex of assigning a variable (my $path) in perl which is
> taking value (for example c:\documents\script.txt) from an expternal APP.

How is your program getting passed this value? On the command-line? If
so, then you would access the value from the [at] ARGV array. $ARGV[0] holds
the first argument, $ARGV[1] the second, and so on.

my $path = $ARGV[0];

If it's being sent to your program via an input stream (the other program
is writing, and your Perl program needs to read), you'd get the value from
<STDIN>.

chomp(my $path = <STDIN>);

--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ % -- Meister Eckhart

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
japhy [ Fr, 22 Juli 2005 18:32 ] [ ID #891131 ]

Re: Help Please!!! External APP passing value to Perl- Problem Resolved

Jeff,

Thanks a lot for your reply. Acutally external APP was passing value to
command prompt so the first option did work.



"Jeff 'japhy' Pinyan" <japhy [at] perlmonk.org> wrote in message
news:Pine.LNX.4.61.0507221230270.27216 [at] perlmonk.org...
> On Jul 22, Perl said:
>
> > what can be the syntex of assigning a variable (my $path) in perl which
is
> > taking value (for example c:\documents\script.txt) from an expternal
APP.
>
> How is your program getting passed this value? On the command-line? If
> so, then you would access the value from the [at] ARGV array. $ARGV[0] holds
> the first argument, $ARGV[1] the second, and so on.
>
> my $path = $ARGV[0];
>
> If it's being sent to your program via an input stream (the other program
> is writing, and your Perl program needs to read), you'd get the value from
> <STDIN>.
>
> chomp(my $path = <STDIN>);
>
> --
> Jeff "japhy" Pinyan % How can we ever be the sold short or
> RPI Acacia Brother #734 % the cheated, we who for every service
> http://japhy.perlmonk.org/ % have long ago been overpaid?
> http://www.perlmonks.org/ % -- Meister Eckhart



--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
perl [ Fr, 22 Juli 2005 19:06 ] [ ID #891877 ]
Perl » gmane.comp.lang.perl.beginners » Help Please!!! External APP passing value to Perl

Vorheriges Thema: File::Find if match rename
Nächstes Thema: RE: Replacing printf by print