
pstevens
New User
Aug 2, 2012, 7:25 PM
Post #1 of 5
(1462 views)
|
|
Executing Block of code inside loop before continuing loop. (nested loops?)
|
Can't Post
|
|
I'm looking for a way to execute and complete a block of code within a loop before allowing the loop to continue. (or even let parts of the loop continue while killing other parts?) Not looking for anybody to write the code for me, but to steer me in the right direction and offer some suggestions. I've pirated my existing code from all over the place and learned a lot in the process. I'm a total newb but wanna learn more... any help is appreciated!
#!/usr/bin/perl use strict ; use warnings ; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; $year += 1900; $mon++; $mon = "0$mon" if $mon < 10; $mday = "0$mday" if $mday < 10; my $data_file="config.csv"; open(DAT, $data_file) || die("Could not open file config.csv!"); while(<DAT>){ chomp; my ($column1,) = split(','); my $filename1="$column1\.cfg"; ##################################################################### ## This next section needs to be completed for all lines in $data_file ## ## before continuing. If ANY $filename1 exists for any line in ## ## $data_file, script should die and output a list of all ## ## preexisting files to be reviewed. (ideally, it would allow ## ## new files to be written and output the list of existing files ## ## without overwriting them, but... bay steps...) ## ##################################################################### if (-e $filename1) { print "File $filename1\ Aready Exists!\n\n"; } open OUT, ">$filename1"; print OUT '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- automatically generated Configuration File --> <!-- Created:'; print OUT " $mday/$mon/$year"; print OUT ' --> <config> <config.parameter.1 config.parameter.1="one"/> <config.parameter.2 config.parameter.2="two"/> <config.parameter.3 config.parameter.3="three"/> </config>'; close OUT; } close(DAT);
|