in reply to Writing to a New File

If the 1st line of your flashcount.txt file contains "5", then the following code:
#!/usr/bin/env perl use warnings; use strict; my $file = './flashcount.txt'; open my $fh, '<', $file or die "Can not open file $file: !$\n"; my $count = <$fh>; close $fh or die "Can not close file $file: !$\n"; chomp $count; my $outcome = $count + 1; print "outcome = $outcome\n";

prints (Update):

outcome = 6

Another update: added chomp.

Replies are listed 'Best First'.
Re^2: Writing to a New File
by SillyMonk (Initiate) on Jan 28, 2008 at 20:20 UTC
    Your way does look impressive toolic and i've saved that code, it'll probably come in handy very shortly, But I've seemed to have fixed it in a strange way indeed.
    print flashcount $outcome, "count=".$outcome;
    this code seems to allow the value to continue incrementing. the the result i get in the txt file is 5count=5 I know thats not so pretty but flash will be able to pick up the value from the txt file Strange I know, Thanks again TheZip, Bradcathey and Toolic!