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: 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


Re: Need help converting from Perl 5

2018-05-14 Thread Shlomi Fish
Hi Todd,

On Sun, 13 May 2018 22:07:59 -0700
ToddAndMargo  wrote:

> On 05/13/2018 09:41 PM, ToddAndMargo wrote:
> > Hi All,
> > 
> > I can't not remember what I did in Perl 5 here and
> > am not having a good time converting it to Perl 6.
> > 
> > $  perl -e 'my $A="44.rc0"; if ($A ~~ /(^[0-9,.,a,b,rc]+$)/ ) {print 
> > "$1\n";} else {print "\$A = <$A>\n"}'
> > 
> > 44.rc0
> > 
> > The actual code is:
> > if ( $Line2 ~~ /(^[0-9,.]+$)/ ) { push ( @WebVersions, $Line2 ); }
> > 
> > The actual data looks like:
> > 
> > $Line2 = 6.0.1
> > $Line2 = 6.0.2
> > $Line2 = 6.0
> > $Line2 = 6.0b1
> > $Line2 = 6.0b2
> > $Line2 = 6.0b3
> > $Line2 = 6.0b4
> > $Line2 = 6.0b5
> > $Line2 = 60.0
> > $Line2 = 60.0b10
> > $Line2 = 60.0b11
> > $Line2 = 60.0b12
> > 
> > I am trying to exclude things that look like:
> > 
> > $Line2 = bonecho
> > $Line2 = custom-updates
> > $Line2 = deerpark
> > $Line2 = devpreview
> > $Line2 = granparadiso
> > $Line2 = latest-beta
> > $Line2 = latest-esr
> > 
> > 
> > Many thanks,
> > -T  
> 
> perl6.org is down by the way.
> 

https://docs.perl6.org/type.html and https://perl6.org/ seem fine from here now
- please try again.

> Is this right?
> 
> perl6 -e 'my $A="44.rc20"; if $A ~~ m/( \d**1..4 "." ( "a" | "b" | "rc" 
> ) .*$ ) /  {say "$0";} else {say "no match";}'
> 
> 44.rc20
> 
> 
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
Best Introductory Programming Language - http://shlom.in/intro-lang

*Harry*: Yes, it is obvious that this pig is the most beautiful person for
miles.
*Miss Piggy*: Indeed. Candice Swanepoel ain’t got nothing on… Moi!
— http://is.gd/zsmond

Please reply to list if it's a mailing list post - http://shlom.in/reply .


Re: Need help converting from Perl 5

2018-05-14 Thread JJ Merelo
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+ \. .+?) \/};
}
..

Please post also your question to StackOverflow, you might have better
answers there. This one works directly on the HTML source, but you will
just need to take out \> and \/ to use other. Also it's a global one, if
you work by lines it might be simpler.

El lun., 14 may. 2018 a las 11:21, ToddAndMargo ()
escribió:

> >> El lun., 14 may. 2018 a las 7:08, ToddAndMargo ( >> >) escribió:
> >>
> >> On 05/13/2018 09:41 PM, ToddAndMargo wrote:
> >>  > Hi All,
> >>  >
> >>  > I can't not remember what I did in Perl 5 here and
> >>  > am not having a good time converting it to Perl 6.
> >>  >
> >>  > $  perl -e 'my $A="44.rc0"; if ($A ~~ /(^[0-9,.,a,b,rc]+$)/ )
> {print
> >>  > "$1\n";} else {print "\$A = <$A>\n"}'
> >>  >
> >>  > 44.rc0
> >>  >
> >>  > The actual code is:
> >>  > if ( $Line2 ~~ /(^[0-9,.]+$)/ ) { push ( @WebVersions, $Line2 );
> }
> >>  >
> >>  > The actual data looks like:
> >>  >
> >>  > $Line2 = 6.0.1
> >>  > $Line2 = 6.0.2
> >>  > $Line2 = 6.0
> >>  > $Line2 = 6.0b1
> >>  > $Line2 = 6.0b2
> >>  > $Line2 = 6.0b3
> >>  > $Line2 = 6.0b4
> >>  > $Line2 = 6.0b5
> >>  > $Line2 = 60.0
> >>  > $Line2 = 60.0b10
> >>  > $Line2 = 60.0b11
> >>  > $Line2 = 60.0b12
> >>  >
> >>  > I am trying to exclude things that look like:
> >>  >
> >>  > $Line2 = bonecho
> >>  > $Line2 = custom-updates
> >>  > $Line2 = deerpark
> >>  > $Line2 = devpreview
> >>  > $Line2 = granparadiso
> >>  > $Line2 = latest-beta
> >>  > $Line2 = latest-esr
> >>  >
> >>  >
> >>  > Many thanks,
> >>  > -T
> >>
> >> perl6.org  is down by the way.
> >>
> >> Is this right?
> >>
> >> perl6 -e 'my $A="44.rc20"; if $A ~~ m/( \d**1..4 "." ( "a" | "b" |
> "rc"
> >> ) .*$ ) /  {say "$0";} else {say "no match";}'
> >>
> >> 44.rc20
> >>
>
> On 05/13/2018 11:41 PM, JJ Merelo wrote:
> > You want to exclude lines starting with an alphabetic character, or
> > which are composed exclusively by alphabetic characters?
> >
>
>
> I am trying to separate revision numbers (60.0.1, 20.0b5) from
> extraneous directories (latest-esr, 20.0.1-funnelcake22)
>
> You can see a full list before I have at it here:
>
> https://ftp.mozilla.org/pub/firefox/releases/
>
> I just want current releases
>


-- 
JJ


Re: Need help converting from Perl 5

2018-05-14 Thread ToddAndMargo
El lun., 14 may. 2018 a las 7:08, ToddAndMargo (>) escribió:


On 05/13/2018 09:41 PM, ToddAndMargo wrote:
 > Hi All,
 >
 > I can't not remember what I did in Perl 5 here and
 > am not having a good time converting it to Perl 6.
 >
 > $  perl -e 'my $A="44.rc0"; if ($A ~~ /(^[0-9,.,a,b,rc]+$)/ ) {print
 > "$1\n";} else {print "\$A = <$A>\n"}'
 >
 > 44.rc0
 >
 > The actual code is:
 > if ( $Line2 ~~ /(^[0-9,.]+$)/ ) { push ( @WebVersions, $Line2 ); }
 >
 > The actual data looks like:
 >
 > $Line2 = 6.0.1
 > $Line2 = 6.0.2
 > $Line2 = 6.0
 > $Line2 = 6.0b1
 > $Line2 = 6.0b2
 > $Line2 = 6.0b3
 > $Line2 = 6.0b4
 > $Line2 = 6.0b5
 > $Line2 = 60.0
 > $Line2 = 60.0b10
 > $Line2 = 60.0b11
 > $Line2 = 60.0b12
 >
 > I am trying to exclude things that look like:
 >
 > $Line2 = bonecho
 > $Line2 = custom-updates
 > $Line2 = deerpark
 > $Line2 = devpreview
 > $Line2 = granparadiso
 > $Line2 = latest-beta
 > $Line2 = latest-esr
 >
 >
 > Many thanks,
 > -T

perl6.org  is down by the way.

Is this right?

perl6 -e 'my $A="44.rc20"; if $A ~~ m/( \d**1..4 "." ( "a" | "b" | "rc"
) .*$ ) /  {say "$0";} else {say "no match";}'

44.rc20



On 05/13/2018 11:41 PM, JJ Merelo wrote:
You want to exclude lines starting with an alphabetic character, or 
which are composed exclusively by alphabetic characters?





I am trying to separate revision numbers (60.0.1, 20.0b5) from
extraneous directories (latest-esr, 20.0.1-funnelcake22)

You can see a full list before I have at it here:

https://ftp.mozilla.org/pub/firefox/releases/

I just want current releases


Re: Need help converting from Perl 5

2018-05-13 Thread ToddAndMargo

On 05/13/2018 09:41 PM, ToddAndMargo wrote:

Hi All,

I can't not remember what I did in Perl 5 here and
am not having a good time converting it to Perl 6.

$  perl -e 'my $A="44.rc0"; if ($A ~~ /(^[0-9,.,a,b,rc]+$)/ ) {print 
"$1\n";} else {print "\$A = <$A>\n"}'


44.rc0

The actual code is:
if ( $Line2 ~~ /(^[0-9,.]+$)/ ) { push ( @WebVersions, $Line2 ); }

The actual data looks like:

$Line2 = 6.0.1
$Line2 = 6.0.2
$Line2 = 6.0
$Line2 = 6.0b1
$Line2 = 6.0b2
$Line2 = 6.0b3
$Line2 = 6.0b4
$Line2 = 6.0b5
$Line2 = 60.0
$Line2 = 60.0b10
$Line2 = 60.0b11
$Line2 = 60.0b12

I am trying to exclude things that look like:

$Line2 = bonecho
$Line2 = custom-updates
$Line2 = deerpark
$Line2 = devpreview
$Line2 = granparadiso
$Line2 = latest-beta
$Line2 = latest-esr


Many thanks,
-T


perl6.org is down by the way.

Is this right?

perl6 -e 'my $A="44.rc20"; if $A ~~ m/( \d**1..4 "." ( "a" | "b" | "rc" 
) .*$ ) /  {say "$0";} else {say "no match";}'


44.rc20



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


Need help converting from Perl 5

2018-05-13 Thread ToddAndMargo

Hi All,

I can't not remember what I did in Perl 5 here and
am not having a good time converting it to Perl 6.

$  perl -e 'my $A="44.rc0"; if ($A ~~ /(^[0-9,.,a,b,rc]+$)/ ) {print 
"$1\n";} else {print "\$A = <$A>\n"}'


44.rc0

The actual code is:
if ( $Line2 ~~ /(^[0-9,.]+$)/ ) { push ( @WebVersions, $Line2 ); }

The actual data looks like:

$Line2 = 6.0.1
$Line2 = 6.0.2
$Line2 = 6.0
$Line2 = 6.0b1
$Line2 = 6.0b2
$Line2 = 6.0b3
$Line2 = 6.0b4
$Line2 = 6.0b5
$Line2 = 60.0
$Line2 = 60.0b10
$Line2 = 60.0b11
$Line2 = 60.0b12

I am trying to exclude things that look like:

$Line2 = bonecho
$Line2 = custom-updates
$Line2 = deerpark
$Line2 = devpreview
$Line2 = granparadiso
$Line2 = latest-beta
$Line2 = latest-esr


Many thanks,
-T