Re: chaining substitutions?

2017-09-23 Thread ToddAndMargo
>> Hi All, >> >> Question. Can I chain these two substitutions together? >> >> $ perl6 -e 'my $x="State : abc "; $x ~~ s/.*?" : "//; $x ~~ s/" >> ".*//; say "<$x>";' >> >> >> >> Many thanks, >> -T On 09/23/2017 07:58 AM, raiph mellor wrote: You want to do two things: 1. match/replace

Re: Why can't I "write"?

2017-09-23 Thread Brandon Allbery
On Sat, Sep 23, 2017 at 3:31 PM, Brandon Allbery wrote: > On Sat, Sep 23, 2017 at 2:09 AM, ToddAndMargo > wrote: > >> method write(IO::Handle:D: Blob:D $buf --> True) >> > > The key here is the colon *after* `IO::Handle:D`: that marks the Handle

Re: overwrite?

2017-09-23 Thread Brandon Allbery
On Sat, Sep 23, 2017 at 2:34 AM, ToddAndMargo wrote: > I see ":truncate". This seems liek it will do the trick. > Problem: I would like to read from the file first before > truncating (ro). > > Is there a way to do this, or should I >1) open the handle with :ro >

Re: Why can't I "write"?

2017-09-23 Thread Brandon Allbery
On Sat, Sep 23, 2017 at 2:09 AM, ToddAndMargo wrote: > method write(IO::Handle:D: Blob:D $buf --> True) > The key here is the colon *after* `IO::Handle:D`: that marks the Handle as an invocant, i.e. this is a method to be applied to an object. (The fact that it has

Re: chaining substitutions?

2017-09-23 Thread raiph mellor
You want to do two things: 1. match/replace something 2. match/replace something else To do this in one command you need: * `:g` to tell P6 to keep going after the first match * `||` to tell P6 to match what's on the left first, or if that fails, what's on the right Which yields: my $x="

Re: Why can't I "write"?

2017-09-23 Thread Brent Laabs
OK, a method is something you call on an object, using a the dot operator. A subroutine is an independent object installed into your current lexical scope. If write was a sub, it would work exactly as you described: 48: my $Handle = open( $DateFile, :rw ) 53: write( $Handle,

Re: Why can't I "write"?

2017-09-23 Thread ToddAndMargo
On Sat, Sep 23, 2017 at 8:19 AM, ToddAndMargo > wrote: On 09/22/2017 11:09 PM, ToddAndMargo wrote: Hi All, https://docs.perl6.org/routine/write (IO::Handle)

overwrite?

2017-09-23 Thread ToddAndMargo
Hi All, I want to overwrite a file. Looking at: https://docs.perl6.org/routine/open I see ":truncate". This seems liek it will do the trick. Problem: I would like to read from the file first before truncating (ro). Is there a way to do this, or should I 1) open the handle with :ro 2)

Re: Why can't I "write"?

2017-09-23 Thread Fernando Santagata
Hi, "write" is a method; its signature is method write(IO::Handle:D: Blob:D $buf --> True) so it has to be called as a method, not a sub. Also note the way the first argument is declared, as a IO::Handle:D:, without a comma separating it from the second argument. That's the type of the object

Re: Why can't I "write"?

2017-09-23 Thread ToddAndMargo
On 09/22/2017 11:09 PM, ToddAndMargo wrote: Hi All, https://docs.perl6.org/routine/write (IO::Handle) method write Defined as: method write(IO::Handle:D: Blob:D $buf --> True) Writes $buf to the filehandle. This method can be called even when the handle is

Why can't I "write"?

2017-09-23 Thread ToddAndMargo
Hi All, https://docs.perl6.org/routine/write (IO::Handle) method write Defined as: method write(IO::Handle:D: Blob:D $buf --> True) Writes $buf to the filehandle. This method can be called even when the handle is not in binary mode. This: 48: my $Handle =