newby has asked for the wisdom of the Perl Monks concerning the following question:
Any suggestions are welcome, thank you#!/usr/bin/perl -w #use strict; open (FF, "myfile.txt") ; if(!-e FF, "myfile.txt") { open FF, "> myfile.txt"; print FF "0\n"; close FF; } else { sub get_record { open (FF, "myfile.txt") or die "Cannot open file: $! "; chomp(my $record = <FF>); close FF; return $record; } } $text = &get_record('pid.dat'); print "text = $text\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I try to write script which try to open a text file and read first line from it
by moritz (Cardinal) on Mar 19, 2012 at 19:08 UTC | |
|
Re: open file
by choroba (Cardinal) on Mar 21, 2012 at 21:45 UTC | |
|
Re: I try to write script which try to open a text file and read first line from it
by JavaFan (Canon) on Mar 19, 2012 at 19:06 UTC | |
|
Re: I try to write script which try to open a text file and read first line from it
by kennethk (Abbot) on Mar 19, 2012 at 19:09 UTC | |
|
Re: open file
by Riales (Hermit) on Mar 21, 2012 at 21:49 UTC | |
|
Re: I try to write script which try to open a text file and read first line from it
by Anonymous Monk on Mar 19, 2012 at 19:10 UTC |