Robert am Mittwoch, 14. September 2005 00.38:
> Chris Charley wrote:
> > ----- Original Message ----- From: "Robert" <[EMAIL PROTECTED]>
> > Newsgroups: perl.beginners
> > To: <beginners@perl.org>
> > Sent: Tuesday, September 13, 2005 1:39 PM
> > Subject: Re: Comparing file contents (code included)
> >
> >> Is there a way (since I have the file open) that I can prepend a value
> >> (I need a number to be inserted) onto the line?
> >>
> >> Robert
> >
> > Not sure what 'kind' of number you want. Perl provides the line of the
> > read file in the variable, $. and I'm guessing you want to prepend
> > 'some' number to your files being read. (VASH, MONH, MANI).
> >
> > It all depends on what kind of number you want.
> >
> > If you want to prepend to one of the read files, you could open them for
> > inplace editing.
> > http://perldoc.perl.org/perlfaq5.html#How-can-I-use-Perl's-'-i'-option-fr
> >om-within-a-program%3f
> >
> >
> > Chris
>
> I am sorry I wasn't more specific. I meant that for each line that is
> going to be written to the file that before that line is written to
> prepend it with a number, I mean all lines.
>
> 12345 this is the line
> 12345 this is the next line
> 12345 this is the next next line
>
> I guess can I re-write the line before it gets written to the file?

Of course, f.e. by replacing the line

   print VASH2MANI if !$dict{$_};

with 

   print VASH2MANI $some_value, $_ if !$dict{$_};

(where $some_value is what you want to prepend to the line(s))

joe

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to