perl format statement, how do I begin a line with a hash mark?

J

joinerda

I would like to use a perl format statement to autogenerate qsub files
for a PBS scheduler. The files I need to generate are essentially
shell scripts with comments beginning with a hash mark to denote them
as pragma for the scheduler.

If I create a format statement that looks like

format QSUBFILE =
#PBS -N @<<<<<<<<<
$queue
..

the line beginning with a hash mark is read as a comment by PERL,
instead of a line that needs to be printed that starts with a hash
mark.

How can I using a PERL format statement generate a number of files all
of which has as their first few lines variations of

#PBS -N dustfit
#PBS -q default
#PBS -l nodes=1:ppn=8
#PBS -l cput=6000:00:00
 
R

Ralph Malph

I would like to use a perl format statement to autogenerate qsub files
for a PBS scheduler. The files I need to generate are essentially
shell scripts with comments beginning with a hash mark to denote them
as pragma for the scheduler.

If I create a format statement that looks like

format QSUBFILE =
#PBS -N @<<<<<<<<<
$queue
.

The easiest option is to just add a leading space before the #
format QSUBFILE =
#PBS -N @<<<<<<<<<
$queue
 
A

arus

I would like to use a perl format statement to autogenerate qsub files
for a PBS scheduler. The files I need to generate are essentially
shell scripts with comments beginning with a hash mark to denote them
as pragma for the scheduler.

If I create a format statement that looks like

format QSUBFILE =
#PBS -N @<<<<<<<<<
$queue
.
Put the hashmark in a variable
Eg)
my $hm="#";
format QSUBFILE =
@#PBS -N @<<<<<<<<<
$hm,$queue
 
A

arus

Put the hashmark in a variable
Eg)
my $hm="#";
format QSUBFILE =
@#PBS -N @<<<<<<<<<
$hm,$queue
.
I forgot to delete your original #.
Please correct that to read
Eg)
my $hm="#";
format QSUBFILE =
@PBS -N @<<<<<<<<<
$hm,$queue
..
 
J

joinerda

I thought about that, but the file has a space in the line that breaks
the way the file is parsed by the scheduler. I need the first
character of the line to be a hash. I can do this with print or printf
statements easily enough, but I am trying to come up with a solution
where the format statement looks as much as possible like the files my
end-users (who tend to ask things like "what is backslash n again?")
are used to dealing with so that this is easier to do in the future.
 
J

Jürgen Exner

joinerda said:
I would like to use a perl format statement to autogenerate qsub files

If I remember correctly there have been previous discussions about
format() and the general consensus was to use printf() instead, AFAIR
because printf() is easier to use and has less problems than format().

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,818
Messages
2,569,736
Members
45,709
Latest member
DRISenaida

Latest Threads

Top