Re: is there a limit to a s/ ?

2018-08-11 Thread yary
I'm happy when I can use the .. and ... operators in p5, thanks for
the tip on the p6 analog!
-y


On Sat, Aug 11, 2018 at 1:44 AM, Simon Proctor  wrote:
> One thing your example you'll lose the second <\div>.
>
> ff is great for working though lines of data. Going back to your previous
> example say we have a file like.
>
> A
> B
> C
> D
> E
> F
> G
>
> And we want to print the lines from C to F we can write.
>
> for "file".IO.lines {
>print if /C/ ff /F/;
> }
>
> Each line in the file is assigned to $_. If ff has not seen the LHS (so C)
> yet it will compare the line to that if it matches (and it doesn't match the
> RHS) it returns True. It continues to return True until the line matches the
> RHS. At which point I *think* it resets to Looking for the LHS and returning
> False.
>
> The more I think about ff and fff the more I'm mind blown, operators that
> remember state? Whacky.
>
> But anyway I hope that helped a bit. The gather example might be closer to
> what you're looking for, putting lines into an array for further looking at.
>
> Or Take a look at DOM::Tiny which might also help you out.
>
> Hope that helped, I should get up and start the drive to Scotland soon.
>
> On Sat, 11 Aug 2018, 06:41 ToddAndMargo,  wrote:
>>
>> On 08/10/2018 08:59 PM, ToddAndMargo wrote:
>> >
>> >> On Fri, Aug 10, 2018 at 8:16 PM, ToddAndMargo 
>> >> wrote:
>> >>> Hi All,
>> >>>
>> >>> I was thinking of doing a
>> >>>
>> >>> $ p6 'my $x="a\nb\nc\nd\n"; say "$x\n"; $x ~~ s/ .*?c /c/; say "$x";'
>> >>> a
>> >>> b
>> >>> c
>> >>> d
>> >>>
>> >>>
>> >>> c
>> >>> d
>> >>>
>> >>>
>> >>> Except the real deal will be across 1460 lines.  Am I pushing the
>> >>> limits?
>> >>>
>> >>> There are other ways of doing what I want.
>> >>>
>> >>>
>> >>> Many thanks,
>> >>> -T
>> >
>> >
>> > On 08/10/2018 08:29 PM, yary wrote:
>> >  > 1460 lines, at an average of say, oh, 70 characters per line, that's
>> >  > oh 100k or so? Sounds like a piece of cake... try it and see
>> >  > -y
>> >  >
>> >  >
>> >
>> > Hi Yary,
>> >
>> > I will.
>> >
>> > This is what I am after:
>> >
>> >  
>> >  Version:*
>> >
>> >  
>> >  
>> >  > >  >9.2.0.92978.3.6.35572
>> >  
>> >  
>> >  
>> >
>> >
>> > $WebPage ~~ s/ . * ''//;
>> > $WebPage ~~ s/ '' .* //;
>> >
>> >
>> > Then
>> >
>> > ( $NewRev  = $Webpage ) ~~ s/ .*? '> >
>> > I may have to fuss with the escapes.
>> >
>> > I do so adore Perl!
>> >
>> > :-)
>> >
>> > -T
>>
>>
>> I have done this with two web pages already.  Perl 6
>> eat its lunch!
>>
>> --
>> ~~
>> Computers are like air conditioners.
>> They malfunction when you open windows
>> ~~
>
> --
> Simon Proctor
> Cognoscite aliquid novum cotidie


Re: is there a limit to a s/ ?

2018-08-11 Thread Simon Proctor
One thing your example you'll lose the second <\div>.

ff is great for working though lines of data. Going back to your previous
example say we have a file like.

A
B
C
D
E
F
G

And we want to print the lines from C to F we can write.

for "file".IO.lines {
   print if /C/ ff /F/;
}

Each line in the file is assigned to $_. If ff has not seen the LHS (so C)
yet it will compare the line to that if it matches (and it doesn't match
the RHS) it returns True. It continues to return True until the line
matches the RHS. At which point I *think* it resets to Looking for the LHS
and returning False.

The more I think about ff and fff the more I'm mind blown, operators that
remember state? Whacky.

But anyway I hope that helped a bit. The gather example might be closer to
what you're looking for, putting lines into an array for further looking at.

Or Take a look at DOM::Tiny which might also help you out.

Hope that helped, I should get up and start the drive to Scotland soon.

On Sat, 11 Aug 2018, 06:41 ToddAndMargo,  wrote:

> On 08/10/2018 08:59 PM, ToddAndMargo wrote:
> >
> >> On Fri, Aug 10, 2018 at 8:16 PM, ToddAndMargo 
> >> wrote:
> >>> Hi All,
> >>>
> >>> I was thinking of doing a
> >>>
> >>> $ p6 'my $x="a\nb\nc\nd\n"; say "$x\n"; $x ~~ s/ .*?c /c/; say "$x";'
> >>> a
> >>> b
> >>> c
> >>> d
> >>>
> >>>
> >>> c
> >>> d
> >>>
> >>>
> >>> Except the real deal will be across 1460 lines.  Am I pushing the
> >>> limits?
> >>>
> >>> There are other ways of doing what I want.
> >>>
> >>>
> >>> Many thanks,
> >>> -T
> >
> >
> > On 08/10/2018 08:29 PM, yary wrote:
> >  > 1460 lines, at an average of say, oh, 70 characters per line, that's
> >  > oh 100k or so? Sounds like a piece of cake... try it and see
> >  > -y
> >  >
> >  >
> >
> > Hi Yary,
> >
> > I will.
> >
> > This is what I am after:
> >
> >  
> >  Version:*
> >
> >  
> >  
> >   >  >9.2.0.92978.3.6.35572
> >  
> >  
> >  
> >
> >
> > $WebPage ~~ s/ . * ''//;
> > $WebPage ~~ s/ '' .* //;
> >
> >
> > Then
> >
> > ( $NewRev  = $Webpage ) ~~ s/ .*? ' >
> > I may have to fuss with the escapes.
> >
> > I do so adore Perl!
> >
> > :-)
> >
> > -T
>
>
> I have done this with two web pages already.  Perl 6
> eat its lunch!
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>
-- 
Simon Proctor
Cognoscite aliquid novum cotidie


Re: is there a limit to a s/ ?

2018-08-10 Thread ToddAndMargo

On 08/10/2018 08:59 PM, ToddAndMargo wrote:


On Fri, Aug 10, 2018 at 8:16 PM, ToddAndMargo  
wrote:

Hi All,

I was thinking of doing a

$ p6 'my $x="a\nb\nc\nd\n"; say "$x\n"; $x ~~ s/ .*?c /c/; say "$x";'
a
b
c
d


c
d


Except the real deal will be across 1460 lines.  Am I pushing the
limits?

There are other ways of doing what I want.


Many thanks,
-T



On 08/10/2018 08:29 PM, yary wrote:
 > 1460 lines, at an average of say, oh, 70 characters per line, that's
 > oh 100k or so? Sounds like a piece of cake... try it and see
 > -y
 >
 >

Hi Yary,

I will.

This is what I am after:

     
     Version:*


     
     
      >9.2.0.92978.3.6.35572

     
     
     


$WebPage ~~ s/ . * ''//;
$WebPage ~~ s/ '' .* //;


Then

( $NewRev  = $Webpage ) ~~ s/ .*? '


I have done this with two web pages already.  Perl 6
eat its lunch!

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: is there a limit to a s/ ?

2018-08-10 Thread ToddAndMargo

On 08/10/2018 09:22 PM, Simon Proctor wrote:
It's 5am and I should be asleep but I think this is a perfect case for 
ff then.


Check out the docs for it.



Hi Simon,

I am not following.  :'(

https://docs.perl6.org/routine/ff

-T


Re: is there a limit to a s/ ?

2018-08-10 Thread Simon Proctor
It's 5am and I should be asleep but I think this is a perfect case for ff
then.

Check out the docs for it.

On Sat, 11 Aug 2018, 05:01 ToddAndMargo,  wrote:

> On 08/10/2018 08:56 PM, Simon Proctor wrote:
> > If all you are wanting to do is print the lines after a certain point in
> > the file the ff operator might be what you're looking for.
>
> See my response to Yary to see what I am after.
>
> Thank you!
>
-- 
Simon Proctor
Cognoscite aliquid novum cotidie


Re: is there a limit to a s/ ?

2018-08-10 Thread ToddAndMargo

On 08/10/2018 08:56 PM, Simon Proctor wrote:
If all you are wanting to do is print the lines after a certain point in 
the file the ff operator might be what you're looking for.


See my response to Yary to see what I am after.

Thank you!


Re: is there a limit to a s/ ?

2018-08-10 Thread ToddAndMargo




On Fri, Aug 10, 2018 at 8:16 PM, ToddAndMargo  wrote:

Hi All,

I was thinking of doing a

$ p6 'my $x="a\nb\nc\nd\n"; say "$x\n"; $x ~~ s/ .*?c /c/; say "$x";'
a
b
c
d


c
d


Except the real deal will be across 1460 lines.  Am I pushing the
limits?

There are other ways of doing what I want.


Many thanks,
-T



On 08/10/2018 08:29 PM, yary wrote:
> 1460 lines, at an average of say, oh, 70 characters per line, that's
> oh 100k or so? Sounds like a piece of cake... try it and see
> -y
>
>

Hi Yary,

I will.

This is what I am after:


Version:*




>9.2.0.92978.3.6.35572






$WebPage ~~ s/ . * ''//;
$WebPage ~~ s/ '' .* //;


Then

( $NewRev  = $Webpage ) ~~ s/ .*? '

Re: is there a limit to a s/ ?

2018-08-10 Thread yary
1460 lines, at an average of say, oh, 70 characters per line, that's
oh 100k or so? Sounds like a piece of cake... try it and see
-y


On Fri, Aug 10, 2018 at 8:16 PM, ToddAndMargo  wrote:
> Hi All,
>
> I was thinking of doing a
>
> $ p6 'my $x="a\nb\nc\nd\n"; say "$x\n"; $x ~~ s/ .*?c /c/; say "$x";'
> a
> b
> c
> d
>
>
> c
> d
>
>
> Except the real deal will be across 1460 lines.  Am I pushing the
> limits?
>
> There are other ways of doing what I want.
>
>
> Many thanks,
> -T