Re: Is there a backward "for @"

2018-05-15 Thread ToddAndMargo

On 05/15/2018 05:32 PM, Brock Wilcox wrote:

Slightly more idiomatic might be `next unless $line`.


Interesting!  Thank you!


Re: Is there a backward "for @"

2018-05-15 Thread ToddAndMargo

On 05/15/2018 04:34 PM, ToddAndMargo wrote:

On 05/15/2018 03:49 PM, Larry Wall wrote:

On Tue, May 15, 2018 at 03:31:07PM -0700, ToddAndMargo wrote:
: Hi All,
:
: This seems like a trivial question, but I really adore
: the "for" loops.  Is there a way to do the backwards?
: In other words, start at the end of the array and loop
: to the beginning?  Does the "next" and "last" work in
: this?

Just use the reverse method:

 > my @foo = ;
 [a b c]
 > for @foo.reverse { .say }
 c
 b
 a

or (as in Perl 5) the reverse function:

 > for reverse @foo { .say }
 c
 b
 a

and yes, "next" and "last" work for those loops too, since they are
controlled by the "for", not by the expression you feed to the "for".

Larry



Hi Larry,

Awesome.  I just copied your response down into my "loops"
keeper file.

I use loops and loops with split "a lot".

Thank you!

-T



It is annoying when I read something back from Linux
and they use a  at the start and stop of a
string (the Secondary Clipboard for instance).

But I just use `if not $line {next}` to jump over it.

-T

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


Re: Is there a backward "for @"

2018-05-15 Thread ToddAndMargo

On 05/15/2018 03:49 PM, Larry Wall wrote:

On Tue, May 15, 2018 at 03:31:07PM -0700, ToddAndMargo wrote:
: Hi All,
:
: This seems like a trivial question, but I really adore
: the "for" loops.  Is there a way to do the backwards?
: In other words, start at the end of the array and loop
: to the beginning?  Does the "next" and "last" work in
: this?

Just use the reverse method:

 > my @foo = ;
 [a b c]
 > for @foo.reverse { .say }
 c
 b
 a

or (as in Perl 5) the reverse function:

 > for reverse @foo { .say }
 c
 b
 a

and yes, "next" and "last" work for those loops too, since they are
controlled by the "for", not by the expression you feed to the "for".

Larry



Hi Larry,

Awesome.  I just copied your response down into my "loops"
keeper file.

I use loops and loops with split "a lot".

Thank you!

-T

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


Re: Is there a backward "for @"

2018-05-15 Thread Larry Wall
On Tue, May 15, 2018 at 03:31:07PM -0700, ToddAndMargo wrote:
: Hi All,
: 
: This seems like a trivial question, but I really adore
: the "for" loops.  Is there a way to do the backwards?
: In other words, start at the end of the array and loop
: to the beginning?  Does the "next" and "last" work in
: this?

Just use the reverse method:

> my @foo = ;
[a b c]
> for @foo.reverse { .say }
c
b
a

or (as in Perl 5) the reverse function:

> for reverse @foo { .say }
c
b
a

and yes, "next" and "last" work for those loops too, since they are
controlled by the "for", not by the expression you feed to the "for".

Larry


Re: number of letters question

2018-05-15 Thread ToddAndMargo

On 05/15/2018 10:05 AM, Larry Wall wrote:

On Tue, May 15, 2018 at 12:44:12AM -0700, ToddAndMargo wrote:
: "abcrd-12.3.4"  would be five letters, six numbers, and one
: I don't care.

Here's another approach:

 $ p6 '"abcrd-12.3.4".comb.classify(*.uniprop).say'
 {Ll => [a b c r d], Nd => [1 2 3 4], Pd => [-], Po => [. .]}

 $ p6 '"abcrd-12.3.4".comb.map(*.uniprop).Bag.say'
 Bag(Ll(5), Nd(4), Pd, Po(2))

 $ p6 '"abcrd-12.3.4".comb.map(*.uniprop).Bag.say'
 (5 4 2)

Whenever you want a histogram, consider using classify or bags.

It's a bit odd to count dots as numbers, so Unicode counts it as
Punctionation Other, but if you assume there or no other characters in
the Po category than dot, you can just add the Po to the Nd total.

Otherwise you might need to use classify and grep out the dots from the
Po category to count them.  (You can't use a bag for that approach since
it throws away the information on which Po character it saw.)

Alternately, you could just make a bag of the raw characters and then
use slicing to define each the category and add up the values for each
character

 $ p6 '"abcrd-12.3.4".comb.Bag{"a"..."z"}.sum.say'
 5
 $ p6 '"abcrd-12.3.4".comb.Bag{"0"..."9", "."}.sum.say'
 6

That's more ASCII friendly, but ASCII is not always your friend.  :-)

Larry



Hi Larry,

Thank you!

I am going to have to read it over several time!  But
I will get there!

-T


Re: Need match character help

2018-05-15 Thread ToddAndMargo

On 05/15/2018 07:05 AM, Timo Paulssen wrote:

On 15/05/18 13:49, ToddAndMargo wrote:

Hi All,

This should be a "no".  What am I doing wrong?

$ perl6 -e 'my $x="rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say
"yes"}else{say "no"}'
yes


Many thanks,
-T


what you've put in your regex here is a character class combined of four
individual ones "added together";

it matches a single letter that is either an "r", a "c", an "a", a "b",
or a ".". Character classes always match only a single character, if you
want it to match more, you will have to use a quantifier, like "+", "*",
or "**". Since your regex is not anchored, it will accept any of those
characters in any spot, so strings like "hello a" will match, too.

It seems like what you want is actually this:

/rc | a | b | "."/

which matches if either "rc", "a", "b" or "." exist somewhere in the string.

If you want to accept only if the full string is "rc", "a", "b" or ".",
you'll have to put anchors in the front and back, and put brackets
around the inner part, so that the ^ and $ refer to the whole
alternation, not just the ^ to the first variant and $ to the last variant.




Thank you!


Re: Need match character help

2018-05-15 Thread ToddAndMargo

On 05/15/2018 07:06 AM, Timo Paulssen wrote:

On 15/05/18 14:03, ToddAndMargo wrote:

On 05/15/2018 04:49 AM, ToddAndMargo wrote:

Hi All,

This should be a "no".  What am I doing wrong?

$ perl6 -e 'my $x="rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say
"yes"}else{say "no"}'
yes


Many thanks,
-T


And how do I turn this into a yes.  I am look for
any instance of d through z

$ perl6 -e 'my $x="f"; if $x~~/<[d.z]>/ {say "yes"}else{say "no"}'
no


The syntax you're looking for is <[d..z]> rather than <[d.z]>. <[d.z]>
is a character class that will match a d, a "." or a z, where as
<[d..z]> is a character class that matches anything in the range of d to z.



Thank you!

What would the syntax be for d..z, but not g or m?


Re: number of letters question

2018-05-15 Thread Andy Bach
> though from the problem question it sounds a lot more like what todd
wants is

my $input = "abcrd-12.3.4";
my $letters = $input.comb(/<[a..z]>/);
my $numbers = $input.comb(/<[a..z 0..9 .]>/);
say "the string $input has $letters letters and $numbers numbers and
periods.";
Just a note, I had to add a "+" to those assignments

my $letters = +$input.comb(/<[a..z]>/);
my $numbers = +$input.comb(/<[a..z 0..9 .]>/);

or otherwise I got a string of the "combed" chars:
the string abcrd-12.3.4 has a b c r d letters and a b c r d 1 2 . 3 . 4
numbers and periods.

On Tue, May 15, 2018 at 9:10 AM, Timo Paulssen  wrote:

> I'd suggest combing for the regex instead of combing and then grepping
> with the regex:
>
> say + "abcrd-12.3.4".comb(//);
>
> though from the problem question it sounds a lot more like what todd wants
> is
>
> my $input = "abcrd-12.3.4";
> my $letters = $input.comb(/<[a..z]>/);
> my $numbers = $input.comb(/<[a..z 0..9 .]>/);
> say "the string $input has $letters letters and $numbers numbers and
> periods.";
>
> On 15/05/18 09:57, JJ Merelo wrote:
>
> Well,
> say + "abcrd-12.3.4".comb.grep: //
> will give you that, but
> say + "abcñé-12.3.4".comb.grep: //
> will yield the same result.
> Roman or other kind of numerals are excluded, though...
>
>
> El mar., 15 may. 2018 a las 9:44, ToddAndMargo ()
> escribió:
>
>> On 05/15/2018 12:37 AM, JJ Merelo wrote:
>> > Hi,
>> >
>> > El mar., 15 may. 2018 a las 9:31, ToddAndMargo (> > >) escribió:
>> >
>> >  >> El mar., 15 may. 2018 a las 8:32, ToddAndMargo
>> > (
>> >  >> >>)
>> > escribió:
>> >  >>
>> >  >> Hi All,
>> >  >>
>> >  >> Do we have one of those sweet functions that will
>> >  >> allow us to look at a string and give us back the
>> >  >> count of how many "letters" and/or "numbers" are
>> >  >> in a string?
>> >  >>
>> >  >> And are decimal points considered numbers or letters?
>> >  >>
>> >  >> Many thanks,
>> >  >> -T
>> >  >>
>> >
>> > On 05/14/2018 11:44 PM, JJ Merelo wrote:
>> >  > IN Perl 6, it's a bit more complicated. Do you want to count
>> > graphemes
>> >  > or codepoints?
>> >  >
>> >
>> > I want to know the number of letters A..Z (ascii 65..90), a..z
>> > (ascii 97..122),
>> >
>> > and the numbers of numbers 0..9 (ascii 48..57) and decimal points
>> > (ascii 46).
>> >
>> >
>> > Once again, that's not so simple. You don't want other kind of numbers?
>> > Would á count as one a and one '?
>> >
>> >
>> > I won't have an weird characters in these stings, such as !@#$^&%(
>> >
>> >
>> > Whoa, whoa, whoa, you calling á and ñ weird?
>> >
>> > Anyway, if that's what you want, just filter those precise graphemes
>> and
>> > count the number of graphemes.
>> >
>> > Cheers
>> >
>> > JJ
>>
>> "abcrd-12.3.4"  would be five letters, six numbers, and one
>> I don't care.
>>
>
>
> --
> JJ
>
>
>


-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: number of letters question

2018-05-15 Thread Larry Wall
On Tue, May 15, 2018 at 12:44:12AM -0700, ToddAndMargo wrote:
: "abcrd-12.3.4"  would be five letters, six numbers, and one
: I don't care.

Here's another approach:

$ p6 '"abcrd-12.3.4".comb.classify(*.uniprop).say'
{Ll => [a b c r d], Nd => [1 2 3 4], Pd => [-], Po => [. .]}

$ p6 '"abcrd-12.3.4".comb.map(*.uniprop).Bag.say'
Bag(Ll(5), Nd(4), Pd, Po(2))

$ p6 '"abcrd-12.3.4".comb.map(*.uniprop).Bag.say'
(5 4 2)

Whenever you want a histogram, consider using classify or bags.

It's a bit odd to count dots as numbers, so Unicode counts it as
Punctionation Other, but if you assume there or no other characters in
the Po category than dot, you can just add the Po to the Nd total.

Otherwise you might need to use classify and grep out the dots from the
Po category to count them.  (You can't use a bag for that approach since
it throws away the information on which Po character it saw.)

Alternately, you could just make a bag of the raw characters and then
use slicing to define each the category and add up the values for each
character

$ p6 '"abcrd-12.3.4".comb.Bag{"a"..."z"}.sum.say'
5
$ p6 '"abcrd-12.3.4".comb.Bag{"0"..."9", "."}.sum.say'
6

That's more ASCII friendly, but ASCII is not always your friend.  :-)

Larry


Re: number of letters question

2018-05-15 Thread Timo Paulssen
I'd suggest combing for the regex instead of combing and then grepping
with the regex:

say + "abcrd-12.3.4".comb(//);

though from the problem question it sounds a lot more like what todd
wants is

    my $input = "abcrd-12.3.4";
    my $letters = $input.comb(/<[a..z]>/);
    my $numbers = $input.comb(/<[a..z 0..9 .]>/);
    say "the string $input has $letters letters and $numbers numbers and
periods.";


On 15/05/18 09:57, JJ Merelo wrote:
> Well,
> say + "abcrd-12.3.4".comb.grep: //
> will give you that, but
> say + "abcñé-12.3.4".comb.grep: //
> will yield the same result.
> Roman or other kind of numerals are excluded, though...
>
>
> El mar., 15 may. 2018 a las 9:44, ToddAndMargo ( >) escribió:
>
> On 05/15/2018 12:37 AM, JJ Merelo wrote:
> > Hi,
> >
> > El mar., 15 may. 2018 a las 9:31, ToddAndMargo
> (
> > >>)
> escribió:
> >
> >      >> El mar., 15 may. 2018 a las 8:32, ToddAndMargo
> >     (
> >
> >      >>     >     escribió:
> >      >>
> >      >>     Hi All,
> >      >>
> >      >>     Do we have one of those sweet functions that will
> >      >>     allow us to look at a string and give us back the
> >      >>     count of how many "letters" and/or "numbers" are
> >      >>     in a string?
> >      >>
> >      >>     And are decimal points considered numbers or letters?
> >      >>
> >      >>     Many thanks,
> >      >>     -T
> >      >>
> >
> >     On 05/14/2018 11:44 PM, JJ Merelo wrote:
> >      > IN Perl 6, it's a bit more complicated. Do you want to count
> >     graphemes
> >      > or codepoints?
> >      >
> >
> >     I want to know the number of letters A..Z (ascii 65..90), a..z
> >     (ascii 97..122),
> >
> >     and the numbers of numbers 0..9 (ascii 48..57) and decimal
> points
> >     (ascii 46).
> >
> >
> > Once again, that's not so simple. You don't want other kind of
> numbers?
> > Would á count as one a and one '?
> >
> >
> >     I won't have an weird characters in these stings, such as
> !@#$^&%(
> >
> >
> > Whoa, whoa, whoa, you calling á and ñ weird?
> >
> > Anyway, if that's what you want, just filter those precise
> graphemes and
> > count the number of graphemes.
> >
> > Cheers
> >
> > JJ
>
> "abcrd-12.3.4"  would be five letters, six numbers, and one
> I don't care.
>
>
>
> -- 
> JJ



Re: Need match character help

2018-05-15 Thread Timo Paulssen
On 15/05/18 14:03, ToddAndMargo wrote:
> On 05/15/2018 04:49 AM, ToddAndMargo wrote:
>> Hi All,
>>
>> This should be a "no".  What am I doing wrong?
>>
>> $ perl6 -e 'my $x="rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say
>> "yes"}else{say "no"}'
>> yes
>>
>>
>> Many thanks,
>> -T
>
> And how do I turn this into a yes.  I am look for
> any instance of d through z
>
> $ perl6 -e 'my $x="f"; if $x~~/<[d.z]>/ {say "yes"}else{say "no"}'
> no

The syntax you're looking for is <[d..z]> rather than <[d.z]>. <[d.z]>
is a character class that will match a d, a "." or a z, where as
<[d..z]> is a character class that matches anything in the range of d to z.


Re: Need match character help

2018-05-15 Thread Timo Paulssen
On 15/05/18 13:49, ToddAndMargo wrote:
> Hi All,
>
> This should be a "no".  What am I doing wrong?
>
> $ perl6 -e 'my $x="rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say
> "yes"}else{say "no"}'
> yes
>
>
> Many thanks,
> -T

what you've put in your regex here is a character class combined of four
individual ones "added together";

it matches a single letter that is either an "r", a "c", an "a", a "b",
or a ".". Character classes always match only a single character, if you
want it to match more, you will have to use a quantifier, like "+", "*",
or "**". Since your regex is not anchored, it will accept any of those
characters in any spot, so strings like "hello a" will match, too.

It seems like what you want is actually this:

/rc | a | b | "."/

which matches if either "rc", "a", "b" or "." exist somewhere in the string.

If you want to accept only if the full string is "rc", "a", "b" or ".",
you'll have to put anchors in the front and back, and put brackets
around the inner part, so that the ^ and $ refer to the whole
alternation, not just the ^ to the first variant and $ to the last variant.


Re: Need match character help

2018-05-15 Thread ToddAndMargo

On 05/15/2018 04:49 AM, ToddAndMargo wrote:

Hi All,

This should be a "no".  What am I doing wrong?

$ perl6 -e 'my $x="rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say "yes"}else{say 
"no"}'

yes


Many thanks,
-T


And how do I turn this into a yes.  I am look for
any instance of d through z

$ perl6 -e 'my $x="f"; if $x~~/<[d.z]>/ {say "yes"}else{say "no"}'
no


Need match character help

2018-05-15 Thread ToddAndMargo

Hi All,

This should be a "no".  What am I doing wrong?

$ perl6 -e 'my $x="rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say "yes"}else{say 
"no"}'

yes


Many thanks,
-T


Re: number of letters question

2018-05-15 Thread ToddAndMargo

On 05/15/2018 02:45 AM, Brent Laabs wrote:
 /<+alnum-[_]>/. 


What does the `+` do?

Is there a was to write that to include decimal points
(or any other weird character)?


Re: number of letters question

2018-05-15 Thread ToddAndMargo

On 05/15/2018 02:45 AM, Brent Laabs wrote:
Just a quick reminder that  matches the underscore, because 
 also does.  If you want to exclude underscores, you can match 
against /<+alnum-[_]>/.  That adds the alnum character class, but 
subtracts underscores from it.   Decimal points are definitely not 
alphanumeric, though.


Thank you!

Is there a list of these somewhere?


Re: number of letters question

2018-05-15 Thread Brent Laabs
Just a quick reminder that  matches the underscore, because 
also does.  If you want to exclude underscores, you can match against
/<+alnum-[_]>/.  That adds the alnum character class, but subtracts
underscores from it.   Decimal points are definitely not alphanumeric,
though.

On Tue, May 15, 2018 at 1:22 AM, JJ Merelo  wrote:

>
>
> El mar., 15 may. 2018 a las 10:17, ToddAndMargo ()
> escribió:
>
>> On 05/15/2018 12:57 AM, JJ Merelo wrote:
>> > Well,
>> > say + "abcrd-12.3.4".comb.grep: //
>> > will give you that, but
>> > say + "abcñé-12.3.4".comb.grep: //
>> > will yield the same result.
>> > Roman or other kind of numerals are excluded, though...
>>
>>
>> $ perl6 -e 'say + "abcrd-12.3.4".comb.grep: //;'
>> 9
>>
>> I don't understand.
>>
>> What does `//` do?  Is that a regex?
>>
>
> Correct. It's the alphanumeric character class.
>
>
> --
> JJ
>


Re: number of letters question

2018-05-15 Thread JJ Merelo
El mar., 15 may. 2018 a las 10:17, ToddAndMargo ()
escribió:

> On 05/15/2018 12:57 AM, JJ Merelo wrote:
> > Well,
> > say + "abcrd-12.3.4".comb.grep: //
> > will give you that, but
> > say + "abcñé-12.3.4".comb.grep: //
> > will yield the same result.
> > Roman or other kind of numerals are excluded, though...
>
>
> $ perl6 -e 'say + "abcrd-12.3.4".comb.grep: //;'
> 9
>
> I don't understand.
>
> What does `//` do?  Is that a regex?
>

Correct. It's the alphanumeric character class.


-- 
JJ


Re: number of letters question

2018-05-15 Thread ToddAndMargo

On 05/15/2018 12:57 AM, JJ Merelo wrote:

Well,
say + "abcrd-12.3.4".comb.grep: //
will give you that, but
say + "abcñé-12.3.4".comb.grep: //
will yield the same result.
Roman or other kind of numerals are excluded, though...



$ perl6 -e 'say + "abcrd-12.3.4".comb.grep: //;'
9

I don't understand.

What does `//` do?  Is that a regex?


Re: number of letters question

2018-05-15 Thread JJ Merelo
Well,
say + "abcrd-12.3.4".comb.grep: //
will give you that, but
say + "abcñé-12.3.4".comb.grep: //
will yield the same result.
Roman or other kind of numerals are excluded, though...


El mar., 15 may. 2018 a las 9:44, ToddAndMargo ()
escribió:

> On 05/15/2018 12:37 AM, JJ Merelo wrote:
> > Hi,
> >
> > El mar., 15 may. 2018 a las 9:31, ToddAndMargo ( > >) escribió:
> >
> >  >> El mar., 15 may. 2018 a las 8:32, ToddAndMargo
> > (
> >  >> >>)
> > escribió:
> >  >>
> >  >> Hi All,
> >  >>
> >  >> Do we have one of those sweet functions that will
> >  >> allow us to look at a string and give us back the
> >  >> count of how many "letters" and/or "numbers" are
> >  >> in a string?
> >  >>
> >  >> And are decimal points considered numbers or letters?
> >  >>
> >  >> Many thanks,
> >  >> -T
> >  >>
> >
> > On 05/14/2018 11:44 PM, JJ Merelo wrote:
> >  > IN Perl 6, it's a bit more complicated. Do you want to count
> > graphemes
> >  > or codepoints?
> >  >
> >
> > I want to know the number of letters A..Z (ascii 65..90), a..z
> > (ascii 97..122),
> >
> > and the numbers of numbers 0..9 (ascii 48..57) and decimal points
> > (ascii 46).
> >
> >
> > Once again, that's not so simple. You don't want other kind of numbers?
> > Would á count as one a and one '?
> >
> >
> > I won't have an weird characters in these stings, such as !@#$^&%(
> >
> >
> > Whoa, whoa, whoa, you calling á and ñ weird?
> >
> > Anyway, if that's what you want, just filter those precise graphemes and
> > count the number of graphemes.
> >
> > Cheers
> >
> > JJ
>
> "abcrd-12.3.4"  would be five letters, six numbers, and one
> I don't care.
>


-- 
JJ


Re: number of letters question

2018-05-15 Thread ToddAndMargo

On 05/15/2018 12:37 AM, JJ Merelo wrote:

Hi,

El mar., 15 may. 2018 a las 9:31, ToddAndMargo (>) escribió:


 >> El mar., 15 may. 2018 a las 8:32, ToddAndMargo
(
 >> >>)
escribió:
 >>
 >>     Hi All,
 >>
 >>     Do we have one of those sweet functions that will
 >>     allow us to look at a string and give us back the
 >>     count of how many "letters" and/or "numbers" are
 >>     in a string?
 >>
 >>     And are decimal points considered numbers or letters?
 >>
 >>     Many thanks,
 >>     -T
 >>

On 05/14/2018 11:44 PM, JJ Merelo wrote:
 > IN Perl 6, it's a bit more complicated. Do you want to count
graphemes
 > or codepoints?
 >

I want to know the number of letters A..Z (ascii 65..90), a..z
(ascii 97..122),

and the numbers of numbers 0..9 (ascii 48..57) and decimal points
(ascii 46).


Once again, that's not so simple. You don't want other kind of numbers? 
Would á count as one a and one '?



I won't have an weird characters in these stings, such as !@#$^&%(


Whoa, whoa, whoa, you calling á and ñ weird?

Anyway, if that's what you want, just filter those precise graphemes and 
count the number of graphemes.


Cheers

JJ


"abcrd-12.3.4"  would be five letters, six numbers, and one
I don't care.


Re: number of letters question

2018-05-15 Thread JJ Merelo
Hi,

El mar., 15 may. 2018 a las 9:31, ToddAndMargo ()
escribió:

> >> El mar., 15 may. 2018 a las 8:32, ToddAndMargo ( >> >) escribió:
> >>
> >> Hi All,
> >>
> >> Do we have one of those sweet functions that will
> >> allow us to look at a string and give us back the
> >> count of how many "letters" and/or "numbers" are
> >> in a string?
> >>
> >> And are decimal points considered numbers or letters?
> >>
> >> Many thanks,
> >> -T
> >>
>
> On 05/14/2018 11:44 PM, JJ Merelo wrote:
> > IN Perl 6, it's a bit more complicated. Do you want to count graphemes
> > or codepoints?
> >
>
> I want to know the number of letters A..Z (ascii 65..90), a..z
> (ascii 97..122),
>
> and the numbers of numbers 0..9 (ascii 48..57) and decimal points
> (ascii 46).
>

Once again, that's not so simple. You don't want other kind of numbers?
Would á count as one a and one '?


> I won't have an weird characters in these stings, such as !@#$^&%(
>

Whoa, whoa, whoa, you calling á and ñ weird?

Anyway, if that's what you want, just filter those precise graphemes and
count the number of graphemes.

Cheers

JJ
-- 
JJ


Re: number of letters question

2018-05-15 Thread ToddAndMargo
El mar., 15 may. 2018 a las 8:32, ToddAndMargo (>) escribió:


Hi All,

Do we have one of those sweet functions that will
allow us to look at a string and give us back the
count of how many "letters" and/or "numbers" are
in a string?

And are decimal points considered numbers or letters?

Many thanks,
-T



On 05/14/2018 11:44 PM, JJ Merelo wrote:
IN Perl 6, it's a bit more complicated. Do you want to count graphemes 
or codepoints?




I want to know the number of letters A..Z (ascii 65..90), a..z
(ascii 97..122),

and the numbers of numbers 0..9 (ascii 48..57) and decimal points
(ascii 46).

I won't have an weird characters in these stings, such as !@#$^&%(


Re: Need help converting from Perl 5

2018-05-15 Thread JJ Merelo
As far as I understand it, HTTP::UserAgent is preferred over LWP::Simple.
It does work to spec now, so I'm using it...

El mar., 15 may. 2018 a las 8:44, ToddAndMargo ()
escribió:

> On 05/14/2018 02:42 AM, JJ Merelo wrote:
> > Maybe this will work
> >
> > use HTTP::UserAgent;
> >
> > my $ua = HTTP::UserAgent.new;
> > $ua.timeout = 10;
> >
> > my $response = $ua.get("https://ftp.mozilla.org/pub/firefox/releases/;);
> >
> > if $response.is-success {
> >  say $response.content ~~ m:g{\> (\d+ \. .+?) \/};
> > }
>
> Hi JJ,
>
> Thank you for the regex!  There are 1001 way to do things
> in Perl!
>
> I tested HTTP::UserAgent months ago.  I don't remember exactly
> what did not work right, but I wound up writing myself
> a module to interface with "curl", where there are no issues
> with redirects, user agent stings, cookies, and such.
>
> My curl module also allows me to send eMail, including SSL
> and one attachment.
>
> The one drawback of Perl 6 over Perl 5 is the lack of
> mature module support, but things are always improving!
>
> :-)
>
> -T
>


-- 
JJ


Re: number of letters question

2018-05-15 Thread JJ Merelo
IN Perl 6, it's a bit more complicated. Do you want to count graphemes or
codepoints?

El mar., 15 may. 2018 a las 8:32, ToddAndMargo ()
escribió:

> Hi All,
>
> Do we have one of those sweet functions that will
> allow us to look at a string and give us back the
> count of how many "letters" and/or "numbers" are
> in a string?
>
> And are decimal points considered numbers or letters?
>
> Many thanks,
> -T
>


-- 
JJ


Re: Need help converting from Perl 5

2018-05-15 Thread ToddAndMargo

On 05/14/2018 02:42 AM, JJ Merelo wrote:

Maybe this will work

use HTTP::UserAgent;

my $ua = HTTP::UserAgent.new;
$ua.timeout = 10;

my $response = $ua.get("https://ftp.mozilla.org/pub/firefox/releases/;);

if $response.is-success {
     say $response.content ~~ m:g{\> (\d+ \. .+?) \/};
}


Hi JJ,

Thank you for the regex!  There are 1001 way to do things
in Perl!

I tested HTTP::UserAgent months ago.  I don't remember exactly
what did not work right, but I wound up writing myself
a module to interface with "curl", where there are no issues
with redirects, user agent stings, cookies, and such.

My curl module also allows me to send eMail, including SSL
and one attachment.

The one drawback of Perl 6 over Perl 5 is the lack of
mature module support, but things are always improving!

:-)

-T


number of letters question

2018-05-15 Thread ToddAndMargo

Hi All,

Do we have one of those sweet functions that will
allow us to look at a string and give us back the
count of how many "letters" and/or "numbers" are
in a string?

And are decimal points considered numbers or letters?

Many thanks,
-T