Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new added value 1

Status
Not open for further replies.

Natalie30

Programmer
Feb 5, 2003
12
0
0
US
well this code works, but the output is taking the current value and putting it in the front of the output, dont know whats going on.

, "76749" 7 13:40:00 2003","1.50","75","1103","78417"
, "78417" 7 13:41:00 2003","1.65","88","1099","79364"
"78417", should be at the end of the line not at the beginning. I am confused why this is happening.

so should look like,
"Feb 7 13:41:00 2003","1.65","88",'1099","79364","78417"

$data_file = "/root/bin/load.data2";
open(FILE,&quot;<$data_file&quot;) or die &quot;Cant open $data_file2:$!\n&quot;;
@log = <FILE>;
$last_element='&quot;0&quot;';
foreach(@log){
chomp;
my@list = split',';
print&quot;$_, $last_element\n&quot;;
$last_element = $list[$#list];
}
close (FILE);
 
Natalie - Hi.

Sorry to be thick - but is:

, &quot;76749&quot; 7 13:40:00 2003&quot;,&quot;1.50&quot;,&quot;75&quot;,&quot;1103&quot;,&quot;78417&quot;
, &quot;78417&quot; 7 13:41:00 2003&quot;,&quot;1.65&quot;,&quot;88&quot;,&quot;1099&quot;,&quot;79364&quot;

an example of the data fed into your script? Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
yes it is, Mike, Hi-nice to meet you, have any suggestions.
 
So -- another stupid question -- where does the &quot;Feb&quot; at the beginning of the output you'd like come from? Is it just the current month? Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
yes, its part of the data from a file, that for some reason is not showing up, thanks.
 
I believe you're reading in a DOS file with CR/LF at the end. The LF is getting chomped off, but the CR is remaining.

Try changing:
[tt]foreach(@log){
chomp;
[/tt]

to:
[tt]foreach (@log) {
chomp;
s/\015//;
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top