Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> How to step over the <STDIN>, while input redirection is not given at commandline

How to step over the <STDIN>, while input redirection is not given at commandline

From: SubbaReddy M <m_subbareddy_at_hotmail.com>
Date: Thu, 14 Feb 2002 02:43:34 -0800
Message-ID: <F001.0040F487.20020214020326@fatcity.com>

Hello Gurus,
Source code: of printFile.pl

#########   File: printFile.pl  ##################
#! /usr/bin/perl -w
my (@data, $user);

# Input rediretion file

$user = (defined @ARGV) ? shift @ARGV : "Anonymous";

# I don't wish to prompt by program, but it's still waiting how to Step Over
here
@data = <STDIN> if ( defined <STDIN>);

die " perl $0 < data.txt" if (@data);

print "User: $user \n";
foreach (@data){

                            print $_;

}

1;
########### EOF ############# I have a perl scripts, which expects the input file as redirection at command line.
i.e.,
[user3_at_Linux] # perl printFile.pl < data.txt

=> This will display the inputed file content, if file name is piped as redirection.

=> Otherwise, program will wait to accept the file.
=> So, I don't want program prompt for the file name,
=> I would like to check the file name is given or not.
=> But, becuase of <STDIN> statement in program to dump the content of the
file into Array, will cause to wait if " < data.txt" is missing at command line.
=> It's very easy, if @ARGV checking, will have the command line parameters. But, it 's not in command line paramenters list. => It is input redirection.

<=> How to check the input direction is given or not in perl, @ = <STDIN>; => like @ = <STDIN> if ( defined <STDIN> ); But this will not full fill the requirement, because, it's prompting for input, if redirection missing at commandline.

Please, kindly give me suggestions to proceed.

Thanks in advance.

Regards,

~ SubbaReddy .M

   Sr. Programmer, Frontlinesoft, Hyderabad    http://www.frontlinesoft.com
   Ph: 91-40-3392147, 3391683 (O)

         91-40-3307980 ( R)
   w3page: http://www.geocities.com/msubbareddy/    ICQ: 56093095

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: SubbaReddy M
  INET: m_subbareddy_at_hotmail.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu Feb 14 2002 - 04:43:34 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US