08:50 dakkar joined 11:03 teatime joined 14:24 Heptite joined
winfredraj hello all, do we have any string functions which will remove line breaks inside the string. I have a XML payload which has a line break or 0x0A which could be causing a problem 14:57
nahita3882 hi, there is the generic subst method on Strings for substitution so that might help 15:03
important to note is that it by default only substitutes the 1st occurence (if any); you need an "adverb" to change them all, i.e., :g 15:04
(for "g"lobal)
winfredraj ok thanks
antononcube Maybe, there is named-regex for line breaks. 15:23
rcmlz you mean like the unicode category „<: Line_Separator>“ 16:24
docs.raku.org/language/regexes#Uni...properties
maybe these unicode categories make the code slower than a single hard—coded „\n“, but to me it still feels superior … 😀 16:27
antononcube @rcmlz Thanks for looking that up! 16:40
16:53 Heptite left
timemelon what are the rules around $_ in quoted code blocks? 16:56
for context:
bash printf 'foo\ngoo\n' | raku -ne 'say "$_"' prints foo then goo as I expected 16:57
but bash printf 'foo\ngoo\n' | raku -ne 'say "{$_}"' tells me Use of uninitialized value $_ of type Any in string context.
17:03 Heptite joined
ab5tract timemelon: the second example should be resolved by adding xargs 17:11
Oh, sorry
The second version creates a new block, which creates a new lexical $_ 17:12
librasteve @timemelon ... here is the way I would model this - every block has a topic $_, in your working example, the topic is a $ scalar and gets interpolated by the quotes ... so the value of the topic of this code (ie the MAIN block) is printed BUT in the second example you now have a new inner block inside the double quotes and the inner block (the closure) has it's own topic that is uninitialized - so to get
this to work you will need to pass the topic from the outer block into the inner closure.
ha!
ab5tract librasteve ++
librasteve printf 'foo\ngoo\n' | raku -ne 'my $x = $_; say "{$x}"' 17:13
timemelon oh right, I didn't realise $_ was per-block, thank you! 17:14
librasteve you're welcome
@winfredraj you may want to look at \v which matches vertical whitespace docs.raku.org/language/regexes#\v_and_\V 17:17
maybe something like .subst( /\v/, '', :g); 17:18
17:35 dakkar left
winfredraj @librasteve thanks for the tip. 17:45
Got my TCP server in Raku working - now I am able to simulate my PLC inputs from the Raku application
lets see how far I go with my simulation suite in Raku 17:46
librasteve 🍬 18:05
lizmat And yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2024/10/28/2024-...es-fallen/ 18:12
librasteve yay 18:56
19:07 Heptite left 20:17 Chanakan left, Heptite joined 20:20 Chanakan joined
ab5tract timemelon: keep in mind that declaring a signature for a block will stop the automatic creation of a topic variable 21:06
m: { -> { say $_ }() }(42)
camelia 42
ab5tract m: { -> $s = “ignored” { say $_ }() }(42) 21:07
camelia 42
timemelon oh interesting 21:10
ab5tract m: sub f { say $_ }; sub x() { try say $_ }; f(42); x(); $_ = 666; x() 21:16
camelia ===SORRY!=== Error while compiling <tmp>
Calling f(Int) will never work with declared signature ()
at <tmp>:1
------> b f { say $_ }; sub x() { try say $_ }; ⏏f(42); x(); $_ = 666; x()
ab5tract Oops, miscalculated there, one second 21:17
Subs act according to slightly different rules, so please ignore the last example 21:19
(With subs you gut @_ when you don’t specify a signature) 21:20
*get
22:20 Heptite left 22:31 Manifest0 left