By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,708 Members | 2,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,708 IT Pros & Developers. It's quick & easy.

subroutine input from external txt file?

P: 4
Hi,

I need to have a Perl script run a query command using ten different input variables that exist in a separate text file and save the output of each query into the same (new) external text file.

Questions:
1. What are the proper Perl terminologies that define my objectives (ie: subroutines, etc.)?

2. Can you direct me to any links that will give me examples / test scripts?

Thanks in advance for your time and assistance.

-TechQA
Feb 12 '09 #1
Share this Question
Share on Google+
7 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
@TechQandA
First, we don't provide test scripts and I don't have any resources for any. This is a learning forum and we will help you when you get stuck.

My first suggestion is that you get a Perl book, like "Learning Perl" and read it and learn Perl. Also, you can reference the perldoc resource as much of the documentation on Perl itself is there at your disposal.

Why don't you try and write something. Then, when you get stuck, post your code here (in code tags) for us to see and point you in the right direction.

Regards,

Jeff
Feb 12 '09 #2

P: 4
Hi Jeff,

I have two books: "Learning Perl" and "Perl Core Language Little Black Book". I'm a newbie working on my first script and am more confused the more I read. I understand how this forum works and am not not looking for someone to write a script for me, but any suggestions (and direction assistance) on the correct type of Perl topics I should be reviewing (ie: subroutines, etc.) would be very helpful to me.

Thank you,

-TechQA
Feb 12 '09 #3

KevinADC
Expert 2.5K+
P: 4,059
Whats a query command?
Feb 12 '09 #4

P: 4
I'm writing a Perl script to run queries against a Tivoli TSM (backup system) database to define the status of a list of tape volumes. Each day there will be a different list of tape volume numbers that I need to have this script process (In Perl-speak, I think this is a subroutine that will 'read' the first line of a text file, place it into the query, save the output to a new text file and repeat the process until it has read through all lines of the source text file and appended all the outputs into the same 'new' text file).
Feb 12 '09 #5

numberwhun
Expert Mod 2.5K+
P: 3,503
@TechQandA
If you are interacting with Tivioli, then you may want to look at any of the number of modules on CPAN.

If its a database that you are directly querying, then you want to write perl code using the Perl DBI interface.

I wasn't trying to imply that you don't know how the forum works, I was just giving my standard speech. Why not post the code you are working on (again, in code tags) and we will work with you to get it working.

Regards,

Jeff
Feb 12 '09 #6

KevinADC
Expert 2.5K+
P: 4,059
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. open (my $IN, "<" , 'path/to/queryfile.txt') or die "$!";
  4. while (my $line = <$IN>) {
  5.    chomp $line;
  6.    # here do something with $line
  7. }   
  8.  
Like Jeff said, if you are querying a database you probably want to use the DBI module for the DB interaction stuff. I don't know anything about TiVoli TSM so I can't help there. Search CPAN as suggested.
Feb 13 '09 #7

P: 4
Jeff and Kevin,

Thanks for your input and assistance with my post. I'll work on the this over the next week and post a new topic question if/when I have one.

Have a great weekend,

-TechQA
Feb 13 '09 #8

Post your reply

Sign in to post your reply or Sign up for a free account.