in reply to Prepending characters to lines in file

If you already have it slurped into a variable (say $data) the following line should work:
$data =~ s/^/> /mg;

-Blake

Replies are listed 'Best First'.
Re: Re: Prepending characters to lines in file
by arturo (Vicar) on Aug 03, 2001 at 04:08 UTC

    Well, you could use a regular expression if you had something against $data = "> $data"; =)

    But the regex do gots the cool factor.

    perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
      Um, those aren't the same.....
      my $data = <<"EOF"; I really like jellybeans of all colors and flavors pink lemonaide blue raspberry and orange marmalade are great EOF print "First try:\n"; print "> $data\n"; print "Second try:\n"; $data =~ s/^/> /mg; print "$data\n";
      Output
      First try: > I really like jellybeans of all colors and flavors pink lemonaide blue raspberry and orange marmalade are great Second try: > I really like > jellybeans > of all colors > and flavors > pink lemonaide > blue raspberry > and orange marmalade > are great

      -Blake