Solved

How to push data to an array?

Posted on 2008-10-09
6
230 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
centeredAverage challenge 8 131
Line meaning 9 82
Problem to start Neon 20 88
html form to write data to csv 24 97
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
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.

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now