Removing text

2015-05-18 Thread Richard Taubo
Hi!

Trying to remove the literal text %st from the command line return value: 
0.0%st
as in:
[$] printf 0.0%st | perl -pe 's/\%st//'

I have also tried: 

[$] printf 0.0%st | perl -pe 's/\Q%st\E//'

Neither works.

Would be happy if someone had any input here! :-)

Thanks!

Richard Taubo
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Removing text

2015-05-18 Thread Richard Taubo
Hi, 

and thanks to Shawn H Corey, Jing Yu.

I see that I have not been specific enough.
(And sorry for the top posting).

The full (bash) script with perl parts looks like this:
[$] top_return=$(top -n1 | head -5)
[$] io_return=$(printf %s\n $top_return | grep ^Cpu(s))
[$] io_all=$(printf  %s $io_return | awk '{ printf $9 }' | perl -pe 
's/\%st//')
[$] printf %s\n $io_all

Returns =  0.0%st  (would want it to be: 0.0 without the '%st' 
part).
 
This kind of works:
[$] io_all=$(printf  %s $io_return | awk '{ printf $9 }' | perl -pe 
's/\%//')
[$] printf %s\n $io_all
Returns =  0.0st (without the % sign)

This too:
[$] io_all=$(printf  %s $io_return | awk '{ printf $9 }' | perl -pe 
's/st//')
[$] printf %s\n $io_all
Returns =  0.0% (without the st characters)

BUT when i search and replace for %st (as described above), I can’t
get it to work.

Thanks for any feedback, and thanks again for the answers I have received. :-)

Best regards,
Richard Taubo




 On 18 May 2015, at 17:52, Shawn H Corey shawnhco...@gmail.com wrote:
 
 On Mon, 18 May 2015 17:32:03 +0200
 Richard Taubo o...@bergersen.no wrote:
 
 Hi!
 
 Trying to remove the literal text %st from the command line return
 value: 0.0%st as in:
 [$] printf 0.0%st | perl -pe 's/\%st//'
 
 I have also tried: 
 
 [$] printf 0.0%st | perl -pe 's/\Q%st\E//'
 
 Neither works.
 
 Would be happy if someone had any input here! :-)
 
 Thanks!
 
 Richard Taubo
 
 I'm not sure what you're trying to do but if you want a percent sign in
 a printf specification, use two of them.
 
printf Sale: %d%% off, $percentage_off;
 
 See `perldoc -f sprintf`
 http://perldoc.perl.org/functions/sprintf.html

And:

 On 18 May 2015, at 17:49, Jing Yu logus...@googlemail.com wrote:
 
 Hi Richard,
 
 When you 
printf 0.0%st”
 in the command line, it prints
0.0t
 And that is the string piped to perl. This is perhaps why you didn’t succeed.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Removing text

2015-05-18 Thread Jing Yu
Hi Richard,

When you 
printf 0.0%st”
in the command line, it prints
0.0t
And that is the string piped to perl. This is perhaps why you didn’t succeed.

J
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Removing text

2015-05-18 Thread Shawn H Corey
On Mon, 18 May 2015 17:32:03 +0200
Richard Taubo o...@bergersen.no wrote:

 Hi!
 
 Trying to remove the literal text %st from the command line return
 value: 0.0%st as in:
 [$] printf 0.0%st | perl -pe 's/\%st//'
 
 I have also tried: 
 
 [$] printf 0.0%st | perl -pe 's/\Q%st\E//'
 
 Neither works.
 
 Would be happy if someone had any input here! :-)
 
 Thanks!
 
 Richard Taubo

I'm not sure what you're trying to do but if you want a percent sign in
a printf specification, use two of them.

printf Sale: %d%% off, $percentage_off;

See `perldoc -f sprintf`
http://perldoc.perl.org/functions/sprintf.html


-- 
Don't stop where the ink does.
Shawn

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Looking for a lightweight usable websocket server

2015-05-18 Thread Rob Coops
Hi all,

I'm working on a simple (or so I thought) project to build a websocket
server that broadcasts data the server receives via a telnet connection.

So a telnet connection is easily setup and messages are simple to relay to
any file handle.

But now comes the harder part.
A websocket server seems to generally be build to do one thing and one
thing only in perl and that is respond to incoming data. Running in an
infinite loop attaching event handlers to data that is received.
At least Net::Websocket::Server works that way.

Could any of you advice me a better library? I don't mind having to mess
about with Protocol::Websocket myself but if there is a good lightweight
library out there (not forcing me to install tons and tons of other
libraries would be good) I would much rather use that.

Thanks for any help pointer or tips.


Re: Looking for a lightweight usable websocket server

2015-05-18 Thread jbiskofski
Rob,

I used this for a long time : http://meteorserver.org/
At the time when I used it, it did not have support for secure websockets.

I ended up having to rebuild the system in node-js using the very popular
socket.io

I love perl as much as anyone, but I think for building a websocket server,
the most mature, well tested, documented solution is socket.io

Good luck!


On Mon, May 18, 2015 at 3:18 PM, Rob Coops rco...@gmail.com wrote:

 Hi all,

 I'm working on a simple (or so I thought) project to build a websocket
 server that broadcasts data the server receives via a telnet connection.

 So a telnet connection is easily setup and messages are simple to relay to
 any file handle.

 But now comes the harder part.
 A websocket server seems to generally be build to do one thing and one
 thing only in perl and that is respond to incoming data. Running in an
 infinite loop attaching event handlers to data that is received.
 At least Net::Websocket::Server works that way.

 Could any of you advice me a better library? I don't mind having to mess
 about with Protocol::Websocket myself but if there is a good lightweight
 library out there (not forcing me to install tons and tons of other
 libraries would be good) I would much rather use that.

 Thanks for any help pointer or tips.