When I run it with: use scrict; use warnings; at the top (which you should ALWAYS do) I also get the error: "Not enough format arguments at XXX.pl line 49" This is referring to the formline call, perhaps that's your root cause?
Upon closer inspection the array @_ in your code has two values but your format string has three fields. I have never looked at formline before but the text states that: @< ^< and ^< are all fields. I assume you must pass a value for each. I removed the first field and it worked fine. If that's your actual solution is a question I can't answer. -Wayne Simmons > -----Original Message----- > From: colin_e [mailto:[EMAIL PROTECTED] > Sent: Tuesday, November 23, 2004 7:09 AM > To: [EMAIL PROTECTED] > Subject: formline "Modification of a read-only value attempted" error > > > Hi guys. Presumably I am doing something silly here, but I can't see it. > I am using > the formline function to write formatted text into a string, in the > manner recommended > in the "Camel Book" (Programming Perl, O'Reilly ). Basically what I want > to do is > build a set of numbered footnotes in a string, to be appended to a mail. > > This worked fine until I tried to use a caret field (^<<<<) to do > auto-filling, when I > hit the above error. Example code below. > > The docs warn that caret fields eat (modify) their corresponding > variables, which is why > I pass a copy of the $note text to the _swrite subroutine for formline > to chew on. However > formline seems to choke on this variable (The error doesn't tell me, but > I assume it's > "$copy" that it is failing to modify). > > Any insights/ideas much appreciated. > > Regards: Colin > > > #!/bin/perl # ignored by Windows > > my $notes= ['This is note 1.', 'Another note.', 'And a third.']; > > #----------------------------------------------------------------------- > > my $footer= write_footnotes(); > > print "Footnotes-\n$footer\n"; > > #----------------------------------------------------------------------- > > sub write_footnotes() { > > my $note_format= <<'EOT'; > > @> ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > > ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > > EOT > > my( $n, $note, $copy, $text); > > foreach $note (@$notes) { > > $copy= $note; > > $text.= _swrite( $note_format, $n++, $copy); > > } > > return $text; > > } > > #----------------------------------------------------------------------- > > sub _swrite { > > my $format= shift; > > $^A= ''; # clear accum. > > formline( $format, @_); > > return $^A; > > } > > #======================================================================= > > > _______________________________________________ > ActivePerl mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
