Solved

How to push data to an array?

Posted on 2008-10-09
6
272 Views
Last Modified: 2012-08-14
Can you see why  $ns = blank, when do a print?

open(DAT, "lxfer.tmp") ;
@raw_data=<DAT>;
close(DAT);
open(ORA, ">>list_of_file.bat");
print ORA "cd $rdir\n";
foreach my $filename (@raw_data)
{
   @fname = split(/\s+/, $filename);
   print ORA "get $fname[8]\n";
   print ORA "del $fname[8]\n";
  $ns = "$fname[8]";    
  push(@fles, $ns);      
print  "filename:  $ns\n";
}
print ORA "quit\n";
close(ORA);
#
0
Comment
Question by:matgold
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 22679406
perhaps because $filename  does not have at least 9 whitespace separated fields
0
 

Author Comment

by:matgold
ID: 22680408
there is nothing wrong with $filename.

print ORA "get $fname[8]\n";
print ORA "del $fname[8]\n";

if the two lines above are not blank, then the print command below should have something in it.
$ns = "$fname[8]";    
  push(@fles, $ns);      
print  "filename:  $ns\n";
0
 
LVL 84

Expert Comment

by:ozo
ID: 22680475
> if the two lines above are not blank, then the print command below should have something in it
Yes, that is correct.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 39

Expert Comment

by:Adam314
ID: 22680662
Can you post the lxfer.tmp file?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 22682278
Add a

print "$filename\n";

before the

print "filename: $ns\n";

and post the output.

Note that you should also ensure you add error checking in case files can be opened/writen to, eg:

open DAT, "lxfer.tmp" or die "Can not open lxfer.tmp $!\n";

0
 

Accepted Solution

by:
matgold earned 0 total points
ID: 22688742
my bad, it was a typo
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
seriesUp challenge 7 199
Perl script to delete older files 6 98
Capture logon name 13 116
collection output issue 9 90
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article will show, step by step, how to integrate R code into a R Sweave document
This video teaches viewers about errors in exception handling.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question