For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2005 > Help Please!!! External APP passing value to Perl









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help Please!!! External APP passing value to Perl
Perl

2005-07-24, 8:29 pm

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


Jeff 'japhy' Pinyan

2005-07-24, 8:29 pm

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 @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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com