Solved

How to push data to an array?

Posted on 2008-10-09
6
242 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
scoresSpecial  challenge 13 52
delphi parse string to params 3 122
Bartender label printing - switch on and off graphics 3 38
Bartender Integration Builder 3 19
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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…

777 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