-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsub_file_overwrite.pl
51 lines (36 loc) · 1.47 KB
/
sub_file_overwrite.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#-----------------------------------------------
#-----------------------------------------------
# file_overwrite
#-----------------------------------------------
#-----------------------------------------------
# The subroutine erases the specified file
# ($global_filename) and overwrites it with the
# specified text ($global_content_to_append_to_file).
# Afterward, the specified text
# ($global_content_to_append_to_file) is
# emptied.
sub file_overwrite
{
#-----------------------------------------------
# Open the file that will be overwritten.
if ( open ( OUTFILE , ">" . $global_filename ) )
{
$global_log_output .= "<fileoverwrite>Opened file for overwriting: " . $global_filename . "<\/fileoverwrite>" ;
} else
{
$global_log_output .= "<fileoverwrite>Failure opening -- for overwriting -- file named " . $global_filename . "<\/fileoverwrite>" ;
return ;
}
#-----------------------------------------------
# Write the content to the description file.
print OUTFILE $global_date_and_time_in_xml ;
print OUTFILE $global_content_to_append_to_file ;
#-----------------------------------------------
# Finish up.
close ( OUTFILE ) ;
$global_log_output .= "<fileoverwrite>Closed file.<\/fileoverwrite>" ;
$global_content_to_append_to_file = "" ;
$global_log_output .= "<fileoverwrite>Overwriting done<\/fileoverwrite>" ;
#-----------------------------------------------
# End of subroutine.
}