How to push data to an array?

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

open(DAT, "lxfer.tmp") ;
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";
Question by:matgold
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
LVL 84

Expert Comment

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

Author Comment

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";
LVL 84

Expert Comment

ID: 22680475
> if the two lines above are not blank, then the print command below should have something in it
Yes, that is correct.
Industry Leaders: 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

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

Expert Comment

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";


Accepted Solution

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

762 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