Perl script help URGENT???

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl script help URGENT???
# 1  
Old 12-17-2007
Perl script help URGENT???

I generated a code too read a list if names from file and store it in array. The file contains names of some files. like
c.txt ........
while I am running the script and gives a file name as argument I have to check wehere the file processed or not. if processed exit the program . Code is given below .
#!/usr/bin/perl -w
#Opening "file" for getting parsed file information
open (DATA,"+>>file") || die ("OOOps");

while (<DATA>) {
$f_name .= $_;
@check = split(/ /,$f_name);
foreach $check (@check) {
while ($check == @ARGV) {
print "Already processed\n";
It is not working .
What is wrong with it ..

# 2  
Old 12-17-2007
To help others help you, you should give more details as to how it doesn't work, and state your expected results.
# 3  
Old 12-17-2007
I will tell it
1) Read command line argument (for the given Perl script). ( Command Line argument will be a file name)
2) Check existence of the file name in "file" . That i tried to do here open (DATA,"+>>file") || die ("OOOps");
#Open "file"
while (<DATA>) {
$f_name .= $_;
@check = split(/ /,$f_name);
#store the contents of "file" to @check.
print "@check\n";
foreach $check (@check) {
while ($check == @ARGV) {
print "Already processed\n";
#Check the presence of file name in @check.
3) if the file npresent in @check then exit
4)Else exicute other programs
Now it 1-3 is not wotking .

# 4  
Old 12-17-2007
First, you are reading from <DATA>. Why are you not opening it with open(DATA, "<file")?

Second, why are you doing this:

$f_name .= $_;

I guess running this in a loop will give you a string consisting of concatenating multiple lines, and you split it by space afterwards will not work because the line read from <DATA> is not chomped, and I could not see a space being added in the middle at all. So you will not get a valid @check.

Third, you should not use "while" if you mean "if".

Fourth, string comparison is not ==. You should use "eq".

Fifth, @ARGV is an array. $check is a scalar. You probably meant $ARGV[0] here. "$check == @ARGV" means checking whether @ARGV has the number of elements equals the value of $check. That doesn't seem to make sense here.

I think your program is full of errors. Please kindly revise your Perl learning materials and fix the errors accordingly.
# 5  
Old 12-18-2007
Thank you for your kind advice and guidence. I solved the peroblem. My code is given below..
$parse = @ARGV[0];
open(DATA,"+<file") || die ("failed to open");
@files = <DATA>;
foreach $files (@files) {
if ($files =~ m/$parse/) {
print "Already processed file\n";
sleep 10;

It is working fine now

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

2. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

3. Post Here to Contact Site Administrators and Moderators

Urgent: please replace the perl script in the post with following code

Hi This is very urgent as it is confidential info posted by mistake.Kindly help us asap. post link below: please replace the perl script with following script in the post ... (1 Reply)
Discussion started by: ptappeta
1 Replies

4. UNIX for Dummies Questions & Answers

Uninstalled Perl - Need Urgent Help

Hey Guys, I'm hoping this is the right section.I am using a centos server. I was installing modules in perl when one got stuck in the installation and from there onwards I was having problems installing cpan modules using perl. I figured I'll reinstal perl (I SHOULDNT HAVE). So I went ahead... (2 Replies)
Discussion started by: zee3b
2 Replies

5. Shell Programming and Scripting

Need urgent help with PERL scripting

From the attached file I to need pick all rows that have AVG2 column value larger than 0.050, and write those values in to a separate file. Help me on how I pick the approp value & output them onto a file. Very Thanks in advance. :b: (5 Replies)
Discussion started by: tonystark
5 Replies

6. Shell Programming and Scripting

replace a string in perl - Urgent

Hi, Can anyone help me to replace ='is NOT NULL' to is NOT NULL in perl. I tried all the methods which i know, i didnt arrive at the solution. please help!! ---------- Post updated at 03:01 PM ---------- Previous update was at 02:56 PM ---------- I got it.......! Thanks, (1 Reply)
Discussion started by: jam_prasanna
1 Replies

7. Shell Programming and Scripting

it's urgent ! round number in perl scripting

my $number = 12.345673412 I need 3 digits after decimal or after dot(.) i mean , i need only 12.345 I used int(), ceil(), floor() but it gives me only 12 I need it. (10 Replies)
Discussion started by:
10 Replies

8. Shell Programming and Scripting

Urgent help for perl script

I am having the autosys script for the perl as follows #!/usr/bin/perl print "Welcome to Autosys Ice Script\n"; print "Please enter the Environment (UAT PRD TRN ST DEV ALL):\n"; $environment = <STDIN>; chomp($environment); print "Please enter the Action (ON_ICE OFF_ICE):\n"; $action =... (0 Replies)
Discussion started by: shellscript22
0 Replies

9. Shell Programming and Scripting

Script Needed Urgent in shell or PERL!!!!!!!!!!!!!!!!!!!!

My I/p FIle #%npr # { { collectionBeginTime_Date 19Jul2007 granularityPeriod 900 NODEID BSC19 RLC_Raw_Blocksize_CS2 2048 START_DATE 19Jul07 measTimeStamp_Date 20Jul2007 COLLECTION_INTERVAL_MINS 15 RLC_User_Blocksize_CS2 1024 ... (1 Reply)
Discussion started by: aajan
1 Replies

10. Shell Programming and Scripting

Calling CGI Perl in Shell script [urgent]

All I want to call a perl program from my shell script. Please help me. I want to call through URL only. Like "" Please help to write this script. Thanx in advance. Thanking you Regards Deepak Xavier (0 Replies)
Discussion started by: DeepakXavier
0 Replies
Login or Register to Ask a Question