Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^3: Running complex sed from perl

by shmem (Canon)
on Dec 02, 2013 at 03:29 UTC ( #1065211=note: print w/replies, xml ) Need Help??

in reply to Re^2: Running complex sed from perl
in thread Running complex sed from perl

If I can figure out how to get double quotes at the begining and end of each line...

There are several ways to do that.

# if the current line is in $_ s/^|$/"/g; # if the current line is in $line $line =~ s/^|$/"/g; # or with [doc://substr] substr $_, 0, 0, '"'; substr $_, length $_, 0, '"'; # but it is simpler just to append a " $_ .= '"'; # or even $_ = '"' .$_ . '"';
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^4: Running complex sed from perl
by sunglant (Initiate) on Dec 02, 2013 at 23:39 UTC

    I attempted this and I get a double quote in front of each line, that was one of the issues I was having with the perl componet, which was I returned to awk. Do you have any idea why only the beginning lines get two double quotes? The same thing occurs when I attempted to make a one liner out of the sed call for the double quotes.

      Your lines probably end with newlines (carriage returns), so your end quote ends up at the beginning of the next line. To avoid that, chomp the line, add your quotes, then print it with a newline:

      chomp $line; $line = qq|"$line"|; print "$line\n";

      Aaron B.
      Available for small or large Perl jobs and *nix system administration; see my home node.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1065211]
[choroba]: My week was hectic as well, and so will be the next several ones...
[Corion]: Sane Dots Supplies - your brand manufacturer for satisfying experiences!
[choroba]: preparing the trip to Vietnam + buying a new car = enough fun
[Corion]: choroba: Yeah, that's a lot of "fun" for one week...
[Corion]: I guess I should stage some product photos for Sane Dots Supplies ;)
[marto]: I had some ideas about that Corion
[marto]: I'll send a message over the weekend maybe :P
[Corion]: choroba: I avoided the "fun" of emergency shopping for a new flat iron by trying the flat iron without the timer that sat between it and the mains power. Seems as if just the timer is broken.
[Corion]: marto: Heh, would be cool!

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2017-01-20 10:15 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (174 votes). Check out past polls.