[33044] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4320 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 2 03:09:21 2014

Date: Tue, 2 Dec 2014 00:09:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 2 Dec 2014     Volume: 11 Number: 4320

Today's topics:
        Can you point me in the right direction - accessing a w <jblack@nospam.com>
    Re: Can you point me in the right direction - accessing <gravitalsun@hotmail.foo>
    Re: Can you point me in the right direction - accessing <sbryce@scottbryce.com>
    Re: Can you point me in the right direction - accessing <jblack@nospam.com>
    Re: Can you point me in the right direction - accessing <jblack@nospam.com>
    Re: Can you point me in the right direction - accessing <hjp-usenet3@hjp.at>
    Re: Can you point me in the right direction - accessing <luca_remove@alice.it>
    Re: Can you point me in the right direction - accessing <lws4art@gmail.com>
    Re: Can you point me in the right direction - accessing <jblack@nospam.com>
    Re: Can you point me in the right direction - accessing <jblack@nospam.com>
        Help needed on Regular Expressions clearguy02@yahoo.com
        Help needed on Regular Expressions <hslee911@yahoo.com>
    Re: Help needed on Regular Expressions <gamo@telecable.es>
    Re: Help needed on Regular Expressions clearguy02@yahoo.com
    Re: Help needed on Regular Expressions clearguy02@yahoo.com
    Re: Help needed on Regular Expressions clearguy02@yahoo.com
    Re: How to write an open(GLOB, ...) wrapper? <whynot@pozharski.name>
    Re: How to write an open(GLOB, ...) wrapper? <gravitalsun@hotmail.foo>
    Re: How to write an open(GLOB, ...) wrapper? <h.b.furuseth@usit.uio.no>
    Re: How to write an open(GLOB, ...) wrapper? <rweikusat@mobileactivedefense.com>
        Need to strip off the non wordy characters clearguy02@yahoo.com
    Re: Need to strip off the non wordy characters <kaz@kylheku.com>
    Re: Need to strip off the non wordy characters <gamo@telecable.es>
    Re: Need to strip off the non wordy characters <gravitalsun@hotmail.foo>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 30 Nov 2014 15:28:00 -0600
From: John Black <jblack@nospam.com>
Subject: Can you point me in the right direction - accessing a website
Message-Id: <MPG.2ee547dd87cb44329897fd@news.eternal-september.org>

Hi,

I am relatively good with basic Perl but don't know web stuff.  I don't need to build a 
website (right now).  All I want to do is have a script that accesses a certain webpage, like 
my bank, and logs in via a user id and pwd and then grabs some data like current balance.  I 
know how to make the program run once a day so that my computer can automatically stay on top 
of my account and send me the daily balance or other alerts.  Can someone point me in the 
right direction?  I'd bet there are existing cpan modules that do things like that.  It does 
not have to be specific to any application - just something that can pull in a page and log 
in to it and then navigate around a little to grab info.  Thanks.

John Black



------------------------------

Date: Sun, 30 Nov 2014 23:29:44 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Can you point me in the right direction - accessing a website
Message-Id: <m5g28d$gl0$1@news.ntua.gr>

On 30/11/2014 23:28, John Black wrote:
> Hi,
>
> I am relatively good with basic Perl but don't know web stuff.  I don't need to build a
> website (right now).  All I want to do is have a script that accesses a certain webpage, like
> my bank, and logs in via a user id and pwd and then grabs some data like current balance.  I
> know how to make the program run once a day so that my computer can automatically stay on top
> of my account and send me the daily balance or other alerts.  Can someone point me in the
> right direction?  I'd bet there are existing cpan modules that do things like that.  It does
> not have to be specific to any application - just something that can pull in a page and log
> in to it and then navigate around a little to grab info.  Thanks.
>
> John Black
>


fits WWW-Mechanize to your problem


------------------------------

Date: Sun, 30 Nov 2014 14:49:23 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Can you point me in the right direction - accessing a website
Message-Id: <m5g3co$5um$1@dont-email.me>

On 11/30/2014 2:29 PM, George Mpouras wrote:
> fits WWW-Mechanize to your problem


Or LWP::UserAgent, HTTP::Cookies to handle the inevitable cookies and
HTML::Parser to find the desired information on the page.

And some way to keep this secure if he is really logging into his bank.
I would not put my banking password in a Perl script, no matter how
secure I thought my computer was.



------------------------------

Date: Sun, 30 Nov 2014 16:02:52 -0600
From: John Black <jblack@nospam.com>
Subject: Re: Can you point me in the right direction - accessing a website
Message-Id: <MPG.2ee5500558a65dfa9897fe@news.eternal-september.org>

In article <m5g3co$5um$1@dont-email.me>, sbryce@scottbryce.com says...
> 
> On 11/30/2014 2:29 PM, George Mpouras wrote:
> > fits WWW-Mechanize to your problem
> 
> 
> Or LWP::UserAgent, HTTP::Cookies to handle the inevitable cookies and
> HTML::Parser to find the desired information on the page.

Thanks.

> And some way to keep this secure if he is really logging into his bank.
> I would not put my banking password in a Perl script, no matter how
> secure I thought my computer was.

Its not so much my bank (where my money is).  its the bank that issued my credit card because 
I want the Perl script to stay on top of my credit card balance (since I am not the only one 
using the card).  How else would I do it besides putting the PWD into the script?

John Black


------------------------------

Date: Sun, 30 Nov 2014 16:05:23 -0600
From: John Black <jblack@nospam.com>
Subject: Re: Can you point me in the right direction - accessing a website
Message-Id: <MPG.2ee550a135658ab19897ff@news.eternal-september.org>

In article <m5g28d$gl0$1@news.ntua.gr>, gravitalsun@hotmail.foo says...
> 
> On 30/11/2014 23:28, John Black wrote:
> > Hi,
> >
> > I am relatively good with basic Perl but don't know web stuff.  I don't need to build a
> > website (right now).  All I want to do is have a script that accesses a certain webpage, like
> > my bank, and logs in via a user id and pwd and then grabs some data like current balance.  I
> > know how to make the program run once a day so that my computer can automatically stay on top
> > of my account and send me the daily balance or other alerts.  Can someone point me in the
> > right direction?  I'd bet there are existing cpan modules that do things like that.  It does
> > not have to be specific to any application - just something that can pull in a page and log
> > in to it and then navigate around a little to grab info.  Thanks.
> >
> > John Black
> >
> 
> 
> fits WWW-Mechanize to your problem

This looks promising.  Thanks.

John Black


------------------------------

Date: Mon, 1 Dec 2014 00:44:53 +0100
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: Can you point me in the right direction - accessing a website
Message-Id: <slrnm7navl.rm2.hjp-usenet3@hrunkner.hjp.at>

On 2014-11-30 22:02, John Black <jblack@nospam.com> wrote:
> In article <m5g3co$5um$1@dont-email.me>, sbryce@scottbryce.com says...
>> And some way to keep this secure if he is really logging into his
>> bank.  I would not put my banking password in a Perl script, no
>> matter how secure I thought my computer was.
>
> Its not so much my bank (where my money is).  its the bank that issued
> my credit card because I want the Perl script to stay on top of my
> credit card balance (since I am not the only one using the card).  How
> else would I do it besides putting the PWD into the script?

If your script must run unattended, you have to store the password
somewhere - there is no way around it (if you store it encrypted, you
have to store the key somewhere ...).

It is still a good idea to store the passwords in a configuration file
and not in the script. You may want to share the script, put it on
github, paste it into a usenet posting, ...

        hp


-- 
   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   | hjp@hjp.at         | die Satzbestandteile des Satzes nicht mehr
__/   | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel


------------------------------

Date: Sun, 30 Nov 2014 22:51:03 -0500
From: Luca <luca_remove@alice.it>
Subject: Re: Can you point me in the right direction - accessing a website
Message-Id: <HARew.709089$JH1.493057@fx08.iad>

On 11/30/2014 04:28 PM, John Black wrote:
> Hi,
>
> I am relatively good with basic Perl but don't know web stuff.  I don't need to build a
> website (right now).  All I want to do is have a script that accesses a certain webpage, like
> my bank, and logs in via a user id and pwd and then grabs some data like current balance.  I
> know how to make the program run once a day so that my computer can automatically stay on top
> of my account and send me the daily balance or other alerts.  Can someone point me in the
> right direction?  I'd bet there are existing cpan modules that do things like that.  It does
> not have to be specific to any application - just something that can pull in a page and log
> in to it and then navigate around a little to grab info.  Thanks.

Not really a Perl answer, but...have you considered headless browsers? 
zombie.js and phantom.js come to mind. They are programmable through 
JavaScript. The fact that a real browser rendering engine is running may 
make a few things simpler...




------------------------------

Date: Sun, 30 Nov 2014 23:02:56 -0500
From: "Jonathan N. Little" <lws4art@gmail.com>
Subject: Re: Can you point me in the right direction - accessing a website
Message-Id: <m5gp91$7r1$2@dont-email.me>

John Black wrote:
> In article <m5g3co$5um$1@dont-email.me>, sbryce@scottbryce.com says...
>>
>> On 11/30/2014 2:29 PM, George Mpouras wrote:
>>> fits WWW-Mechanize to your problem
>>
>>
>> Or LWP::UserAgent, HTTP::Cookies to handle the inevitable cookies and
>> HTML::Parser to find the desired information on the page.
>
> Thanks.
>
>> And some way to keep this secure if he is really logging into his bank.
>> I would not put my banking password in a Perl script, no matter how
>> secure I thought my computer was.
>
> Its not so much my bank (where my money is).  its the bank that issued my credit card because
> I want the Perl script to stay on top of my credit card balance (since I am not the only one
> using the card).  How else would I do it besides putting the PWD into the script?

Most banks offer notices for balances either by email or text alerts for 
your phone. A much better and SAFER option.


-- 
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com


------------------------------

Date: Mon, 1 Dec 2014 10:20:41 -0600
From: John Black <jblack@nospam.com>
Subject: Re: Can you point me in the right direction - accessing a website
Message-Id: <MPG.2ee65158ff08401c989800@news.eternal-september.org>

In article <m5gp91$7r1$2@dont-email.me>, lws4art@gmail.com says...
> 
> John Black wrote:
> > In article <m5g3co$5um$1@dont-email.me>, sbryce@scottbryce.com says...
> >>
> >> On 11/30/2014 2:29 PM, George Mpouras wrote:
> >>> fits WWW-Mechanize to your problem
> >>
> >>
> >> Or LWP::UserAgent, HTTP::Cookies to handle the inevitable cookies and
> >> HTML::Parser to find the desired information on the page.
> >
> > Thanks.
> >
> >> And some way to keep this secure if he is really logging into his bank.
> >> I would not put my banking password in a Perl script, no matter how
> >> secure I thought my computer was.
> >
> > Its not so much my bank (where my money is).  its the bank that issued my credit card because
> > I want the Perl script to stay on top of my credit card balance (since I am not the only one
> > using the card).  How else would I do it besides putting the PWD into the script?
> 
> Most banks offer notices for balances either by email or text alerts for 
> your phone. A much better and SAFER option.

Yes, I know thanks.  I was looking to pull more infomation than they send in their alerts and 
I wanted to format the report my own way etc.  Also, it gives me a good excuse to learn how 
to access web sites with Perl.

John Black


------------------------------

Date: Mon, 1 Dec 2014 10:23:13 -0600
From: John Black <jblack@nospam.com>
Subject: Re: Can you point me in the right direction - accessing a website
Message-Id: <MPG.2ee651efd9c42130989801@news.eternal-september.org>

In article <slrnm7navl.rm2.hjp-usenet3@hrunkner.hjp.at>, hjp-usenet3@hjp.at says...
> If your script must run unattended, you have to store the password
> somewhere - there is no way around it (if you store it encrypted, you
> have to store the key somewhere ...).
> 
> It is still a good idea to store the passwords in a configuration file
> and not in the script. You may want to share the script, put it on
> github, paste it into a usenet posting, ...

Yes, I agree.  I am sure I would have done that.  I'll put the sensitive file in a directory 
that only I have permission to.

John Black


------------------------------

Date: Mon, 1 Dec 2014 19:20:10 -0800 (PST)
From: clearguy02@yahoo.com
Subject: Help needed on Regular Expressions
Message-Id: <41e61e77-b957-4472-ba90-e4f69a9ed771@googlegroups.com>


Hi all,

I need to compare two lists (first list has only one entry; second list has=
 a lot more entries and starts with the first list's entry and in addition =
it has two more entries). I need to find out all entries in the second file=
 that contains the single entry in the first file.

First List (it has all special characters such as &, (, ), [, }, $, % etc):

list1.txt
+++++++++++
911 Availability
[SITESPEED]=ADSRP
Accessibility Evaluator
Account Access Provisioning
Activity Stream
++++++++++++++++


Second list:

list2. txt
++++++++++++++++
Twin Towers joseph smith
[SITESPEED]=ADSRP john carter
Election Process lisa chang
911 Availability jim moss
Activity Stream raj gupta
Accessibility Evaluator will stevenson
Account Access Provisioning mike molly
World Trade center chuck davis
+++++++++++++++++

The output should be (sorted by the first entry):
++++++++++++++++++++
911 Availability jim moss
[SITESPEED]=ADSRP john carter
Accessibility Evaluator will stevenson
Account Access Provisioning mike molly
Activity Stream raj gupta
+++++++++++++++++++

I am struggling a lot with hashes and reg expressions. Can you pl. help me =
to get the final output? The first file's each entry can be treated as a wh=
ole line ($_) and it would certainly be the first entry in the second file.=
=20

Thanks a lot in advance!!




------------------------------

Date: Mon, 1 Dec 2014 21:50:12 -0800 (PST)
From: James <hslee911@yahoo.com>
Subject: Help needed on Regular Expressions
Message-Id: <3404dad6-0bfd-42b5-9070-5d7ea4099ad4@googlegroups.com>

($f1, $f2) = @ARGV;
for (`cat $f2`) {
  chomp;
  $h{$_} = 1;
}
for $y (`cat $f1`) {
  chomp $y;
  for $k (keys %h) {
    print "$y\n" if $k =~ /^$y/;
  }
}


------------------------------

Date: Tue, 02 Dec 2014 06:58:09 +0100
From: gamo <gamo@telecable.es>
Subject: Re: Help needed on Regular Expressions
Message-Id: <m5jkdf$tuc$3@speranza.aioe.org>

El 02/12/14 a las 04:20, clearguy02@yahoo.com escribió:
>
> Hi all,
>
> I need to compare two lists (first list has only one entry; second list has a lot more

  entries and starts with the first list's entry and in addition it has 
two more entries).

  I need to find out all entries in the second file that contains the 
single entry in the

  first file.
>
> First List (it has all special characters such as &, (, ), [, }, $, % etc):
>
> list1.txt
> +++++++++++
> 911 Availability
> [SITESPEED]­SRP
> Accessibility Evaluator
> Account Access Provisioning
> Activity Stream
> ++++++++++++++++
>
>
> Second list:
>
> list2. txt
> ++++++++++++++++
> Twin Towers joseph smith
> [SITESPEED]­SRP john carter
> Election Process lisa chang
> 911 Availability jim moss
> Activity Stream raj gupta
> Accessibility Evaluator will stevenson
> Account Access Provisioning mike molly
> World Trade center chuck davis
> +++++++++++++++++
>
> The output should be (sorted by the first entry):
> ++++++++++++++++++++
> 911 Availability jim moss
> [SITESPEED]­SRP john carter
> Accessibility Evaluator will stevenson
> Account Access Provisioning mike molly
> Activity Stream raj gupta
> +++++++++++++++++++
>
> I am struggling a lot with hashes and reg expressions. Can you pl. help me to get the final output?

  The first file's each entry can be treated as a whole line ($_) and it 
would certainly be the first

  entry in the second file.
>
> Thanks a lot in advance!!
>
>

Oops! This sounds like homework!

for $i (@first_list){
	for $j (@second_list){
		if ($j =~ /\Q$i/) {
			print $j;
		}
	}
}			

I left you details to complete.

-- 
http://www.telecable.es/personales/gamo/


------------------------------

Date: Mon, 1 Dec 2014 22:16:34 -0800 (PST)
From: clearguy02@yahoo.com
Subject: Re: Help needed on Regular Expressions
Message-Id: <d2fd47b6-10a7-427f-90bd-a824080e8102@googlegroups.com>

On Monday, December 1, 2014 7:20:17 PM UTC-8, clear...@yahoo.com wrote:
> Hi all,
>=20
> I need to compare two lists (first list has only one entry; second list h=
as a lot more entries and starts with the first list's entry and in additio=
n it has two more entries). I need to find out all entries in the second fi=
le that contains the single entry in the first file.
>=20
> First List (it has all special characters such as &, (, ), [, }, $, % etc=
):
>=20
> list1.txt
> +++++++++++
> 911 Availability
> [SITESPEED]=ADSRP
> Accessibility Evaluator
> Account Access Provisioning
> Activity Stream
> ++++++++++++++++
>=20
>=20
> Second list:
>=20
> list2. txt
> ++++++++++++++++
> Twin Towers joseph smith
> [SITESPEED]=ADSRP john carter
> Election Process lisa chang
> 911 Availability jim moss
> Activity Stream raj gupta
> Accessibility Evaluator will stevenson
> Account Access Provisioning mike molly
> World Trade center chuck davis
> +++++++++++++++++
>=20
> The output should be (sorted by the first entry):
> ++++++++++++++++++++
> 911 Availability jim moss
> [SITESPEED]=ADSRP john carter
> Accessibility Evaluator will stevenson
> Account Access Provisioning mike molly
> Activity Stream raj gupta
> +++++++++++++++++++
>=20
> I am struggling a lot with hashes and reg expressions. Can you pl. help m=
e to get the final output? The first file's each entry can be treated as a =
whole line ($_) and it would certainly be the first entry in the second fil=
e.=20
>=20
> Thanks a lot in advance!!

Thanks James and Gamo...

Here is what I have and I can not find out what is wrong here:

use strict;
use warnings;

my $input1 =3D "output.txt";
open(my $f1, "<", $input1) or die "$0: Can't open input file $input1: $!\n"=
;

my $input2 =3D "AllProjects.txt";
open(my $f2, "<", $input2) or die "$0: Can't open input file $input2: $!\n"=
;

my $i;
my $j;

for $i (@f1)
  {=20
    for $j (@f2)
     {=20
       if ($j =3D~ /\Q$i/)=20
         {=20
           print $j;=20
         }=20
     }=20
  }    


------------------------------

Date: Mon, 1 Dec 2014 22:28:55 -0800 (PST)
From: clearguy02@yahoo.com
Subject: Re: Help needed on Regular Expressions
Message-Id: <2e038345-508e-4e68-b2f8-2fea0e388995@googlegroups.com>

On Monday, December 1, 2014 7:20:17 PM UTC-8, clear...@yahoo.com wrote:
> Hi all,
>=20
> I need to compare two lists (first list has only one entry; second list h=
as a lot more entries and starts with the first list's entry and in additio=
n it has two more entries). I need to find out all entries in the second fi=
le that contains the single entry in the first file.
>=20
> First List (it has all special characters such as &, (, ), [, }, $, % etc=
):
>=20
> list1.txt
> +++++++++++
> 911 Availability
> [SITESPEED]=ADSRP
> Accessibility Evaluator
> Account Access Provisioning
> Activity Stream
> ++++++++++++++++
>=20
>=20
> Second list:
>=20
> list2. txt
> ++++++++++++++++
> Twin Towers joseph smith
> [SITESPEED]=ADSRP john carter
> Election Process lisa chang
> 911 Availability jim moss
> Activity Stream raj gupta
> Accessibility Evaluator will stevenson
> Account Access Provisioning mike molly
> World Trade center chuck davis
> +++++++++++++++++
>=20
> The output should be (sorted by the first entry):
> ++++++++++++++++++++
> 911 Availability jim moss
> [SITESPEED]=ADSRP john carter
> Accessibility Evaluator will stevenson
> Account Access Provisioning mike molly
> Activity Stream raj gupta
> +++++++++++++++++++
>=20
> I am struggling a lot with hashes and reg expressions. Can you pl. help m=
e to get the final output? The first file's each entry can be treated as a =
whole line ($_) and it would certainly be the first entry in the second fil=
e.=20
>=20
> Thanks a lot in advance!!

Thanks James and Gamo..

Gamo,

The below snippet is not working.. where am I doing wrong??

use strict;
use warnings;

open F1, "output.txt" or die $!;
open F2, "AllProjects.txt" or die $!;

my @file1 =3D <F1>;
my @file2 =3D <F2>;

my $i;
my $j;

for $i (@file1)
  {=20
    for $j (@file2)
     {=20
       if ($j =3D~ /\Q$i/)=20
         {=20
           print "$j\n";=20
         }=20
     }=20
  }                        =20

close(F1);
close(F2);


------------------------------

Date: Mon, 1 Dec 2014 22:30:19 -0800 (PST)
From: clearguy02@yahoo.com
Subject: Re: Help needed on Regular Expressions
Message-Id: <5f417963-880e-4965-8cfb-91fc82e3c5ca@googlegroups.com>

On Monday, December 1, 2014 7:20:17 PM UTC-8, clear...@yahoo.com wrote:
> Hi all,
>=20
> I need to compare two lists (first list has only one entry; second list h=
as a lot more entries and starts with the first list's entry and in additio=
n it has two more entries). I need to find out all entries in the second fi=
le that contains the single entry in the first file.
>=20
> First List (it has all special characters such as &, (, ), [, }, $, % etc=
):
>=20
> list1.txt
> +++++++++++
> 911 Availability
> [SITESPEED]=ADSRP
> Accessibility Evaluator
> Account Access Provisioning
> Activity Stream
> ++++++++++++++++
>=20
>=20
> Second list:
>=20
> list2. txt
> ++++++++++++++++
> Twin Towers joseph smith
> [SITESPEED]=ADSRP john carter
> Election Process lisa chang
> 911 Availability jim moss
> Activity Stream raj gupta
> Accessibility Evaluator will stevenson
> Account Access Provisioning mike molly
> World Trade center chuck davis
> +++++++++++++++++
>=20
> The output should be (sorted by the first entry):
> ++++++++++++++++++++
> 911 Availability jim moss
> [SITESPEED]=ADSRP john carter
> Accessibility Evaluator will stevenson
> Account Access Provisioning mike molly
> Activity Stream raj gupta
> +++++++++++++++++++
>=20
> I am struggling a lot with hashes and reg expressions. Can you pl. help m=
e to get the final output? The first file's each entry can be treated as a =
whole line ($_) and it would certainly be the first entry in the second fil=
e.=20
>=20
> Thanks a lot in advance!!

Thanks James and Gamo for your kind responses..

Gamo,=20

The below snippet is not working.. where am I doing wrong??

use strict;
use warnings;

open F1, "output.txt" or die $!;
open F2, "AllProjects.txt" or die $!;

my @file1 =3D <F1>;
my @file2 =3D <F2>;

my $i;
my $j;

for $i (@file1)
  {=20
    for $j (@file2)
     {=20
       if ($j =3D~ /\Q$i/)=20
         {=20
           print "$j\n";=20
         }=20
     }=20
  }                        =20

close(F1);
close(F2);


------------------------------

Date: Sun, 30 Nov 2014 14:42:24 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: How to write an open(GLOB, ...) wrapper?
Message-Id: <slrnm7m45g.1fq.whynot@orphan.zombinet>

with <m5d721$1a9b$1@news.ntua.gr> George Mpouras wrote:
> On 29/11/2014 15:34, Eric Pozharski wrote:
>> with <m5a4q8$26hr$1@news.ntua.gr> George Mpouras wrote:

>> *SKIP*
>> That's what CLPM-people were trying to say you on multiple occasions
>> over a year now -- Make Your Code Readable (For Others)!  This one
>> doesn't compile.
> its pseudocode in case you did not notice; whatever.

I stand corrected:

	Make Your Pseudocode Readable (For Others)

*CUT*

-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


------------------------------

Date: Sun, 30 Nov 2014 21:29:55 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: How to write an open(GLOB, ...) wrapper?
Message-Id: <m5fr7o$318s$1@news.ntua.gr>

On 28/11/2014 16:49, Hallvard Breien Furuseth wrote:
> So, which do I use and what's going on when I use it?  I don't
> trust "seems to work".  Several myopen()ed files will be open at
> the same time, maybe with the same filename and/or local()ized
> glob name.  Leaves room for screwing up if I use globs wrong.



there was a problem with a product (no name) with webgui/database etc.
It was freaking slow when many users submit parallel requests and 
waiting for the reports.

I write a service (in perl) that "rotate" all user requsts 90 degrees to 
vertical data slices with unique time ranges, so all the requests 
scanned the data once even for overlapped time ranges. The results was 
stunned.
The product now was 100 - 200 times faster !!!

For multiplexing user requests, and send demultiplexing results to back 
to the correct users I use the following (instead of sql)

open
{$fh{company}{user}{report}{optomizedsubquery}{filehandle}}, '>',
  $fh{company}{user}{report}{optomizedsubquery}{filename}


your request remind me all these, so it is good for you to know it.


------------------------------

Date: Mon, 01 Dec 2014 12:56:24 +0100
From: Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no>
Subject: Re: How to write an open(GLOB, ...) wrapper?
Message-Id: <hbf.20141201gppz@bombur.uio.no>

Eric Pozharski writes:
> with <hbf.20141128kpjv@bombur.uio.no> Hallvard Breien Furuseth wrote:
>
>> I know the program should have been using $filehandles instead
>> of GLOBs, but such a rewrite would not be amusing at this time.
>
> I think you have a slight bit of misunderstanding.  In Perl filehandles
> are called GLOBs:

Just a problem with terminology.  I'm talking about the programming
style:  open(HANDLE...) vs open($my variable...).

> (I'm pulling out this gun for the first time.)  What is you're trying to
> do?

I have a program doing open(FOO, "<", $filename).  I want to replace
the open() calls to myopen() which does more stuff, without changing
the rest of the program (yet) to use $variable-style filehandles.

So I'M looking for advise from someone who understands what's going on
and what's the difference between these apparently working variants.
I *really* don't trust "it seems to work" on this one, when I don't
understand it.  A lot of magic seems to be going on with this stuff.

-- 
Hallvard


------------------------------

Date: Mon, 01 Dec 2014 15:18:56 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: How to write an open(GLOB, ...) wrapper?
Message-Id: <87sigzmm8v.fsf@doppelsaurus.mobileactivedefense.com>

Eric Pozharski <whynot@pozharski.name> writes:
> with <hbf.20141128kpjv@bombur.uio.no> Hallvard Breien Furuseth wrote:
>
>> I know the program should have been using $filehandles instead
>> of GLOBs, but such a rewrite would not be amusing at this time.
>
> I think you have a slight bit of misunderstanding.  In Perl filehandles
> are called GLOBs:
>
> 	% perl -wle 'print ref \*STDOUT'
> 	GLOB
>
> Before lexical filehandles where made they were global only (clearly,
> that's why they are called GLOBs).

NB: The text below omits various things in the name of simplicity.

In Perl, filehandles are not called 'globs' because globs are what would
be symbols in Lisp --- things which can be stored in a symbol table
which have various 'slots' pointing to other kinds of objects which can
have names,

[rw@doppelsaurus]~#perl -MDevel::Peek -e 'Dump(\*glob)'
SV = IV(0x606988) at 0x606998
  REFCNT = 1
  FLAGS = (TEMP,ROK)
  RV = 0x6238c0
  SV = PVGV(0x65f3f0) at 0x6238c0
    REFCNT = 3
    FLAGS = (MULTI,IN_PAD)
    NAME = "glob"
    NAMELEN = 4
    GvSTASH = 0x606800  "main"
    GP = 0x62b370
      SV = 0x0
      REFCNT = 1
      IO = 0x0
      FORM = 0x0  
      AV = 0x0
      HV = 0x0
      CV = 0x0
      CVGEN = 0x0
      LINE = 1
      FILE = "-e"
      FLAGS = 0xa
      EGV = 0x6238c0    "glob"

(the ones I know of are 'SV' - scalar slot, 'IO' - I/O handle slot, 'FORM'
- format slot, 'AV' - array, 'HV' - hash and 'CV' - subroutine). I/O
handles are not really Perl-level objects, eg, there are no 'I/O
variables' in the way there are 'array variables' and the traditional
way to use a specific I/O handle is to use the name of the glob pointing
to it, eg

perl -e 'print STDERR ("Erare humanum est!\n")'

which prints to the I/O handle associated with the glob named
STDERR. Alternatively, a reference to a glob can be used, eg,

perl -e 'print {\*STDERR} ("Attack of the killer pillows\n")'

Since references to globs can be assigned to scalars, this enables I/O
handle to be passed to subroutines without strict complaing about that,
eg,

this works

perl -e 'sub zsm { print {$_[0]} ("Zahnstocherzerspanungsmaschine\n"); } zsm("STDERR")'

as does this

perl -Mstrict -e 'sub zsm { print {$_[0]} ("Zahnstocherzerspanungsmaschine\n"); } zsm(\*STDERR)'

but this results in an error because of the symbolic reference to the STDERR glob

perl -Mstrict -e 'sub zsm { print {$_[0]} ("Zahnstocherzerspanungsmaschine\n"); } zsm("STDERR")'

Nowadays, the usual way to create a new filehandle is to use a scalar
with undefined value as first argument to open (or similar
subroutines). This will end up creating an anonymous glob whose I/O
handle slot points to the new handle.

perl -MDevel::Peek -e 'open($fh, ">", "/dev/tty"); Dump($fh)'


------------------------------

Date: Mon, 1 Dec 2014 17:05:33 -0800 (PST)
From: clearguy02@yahoo.com
Subject: Need to strip off the non wordy characters
Message-Id: <8210d62e-39ef-4faf-80af-a6a21fbc730c@googlegroups.com>

Hi,

I have the following data:

++++++++++++++
411 Availability 79 0%
[SITESPEED]=ADSRP 1 0%
Accessibility Evaluator 53 0%
Accounting Access Provisioning 6 0%
Activities Stream 1 0%
Adverb Funnel Reporting 14 0%
Adverb Performance Tracking Data Mart 27 65%
Channeling 53 0%
AE =AD Attribute Extraction 113 50%
+++++++++++++++++

Now I want the output to be as follows (Only Ad Name with no numbers and no=
 percentages at the end of the Ad name):

++++++++++
411 Availability
[SITESPEED]=ADSRP
Accessibility Evaluator
Accounting Access Provisioning
Activities Stream
Adverb Funnel Reporting
Adverb Performance Tracking Data Mart
Channeling
AE =AD Attribute Extraction
+++++++++++++

How can I get it?

while (<DATA>)
{
   $_ =3D ($1)\s\d+\s\d+\%;

   print $_;
}

Would the above snippet work? Kindly let me know.



------------------------------

Date: Tue, 2 Dec 2014 01:30:51 +0000 (UTC)
From: Kaz Kylheku <kaz@kylheku.com>
Subject: Re: Need to strip off the non wordy characters
Message-Id: <20141201171944.923@kylheku.com>

On 2014-12-02, clearguy02@yahoo.com <clearguy02@yahoo.com> wrote:
> How can I get it?
>
> while (<DATA>)
> {
>    $_ = ($1)\s\d+\s\d+\%;
>
>    print $_;
> }
>
> Would the above snippet work? Kindly let me know.

The number are always the last two fields in your example data.
This can be chopped off using Awk:

$ awk '{ NF -= 2; print }' yourfile

This will bail, of course, if there are records that don't have at least two
fields, since NF goes negative. There are various ways to deal with that, if
necessary, which depend on your exact data:

# Only ajust and print records that have at least three fields:
$ awk 'NF >= 3 { NF -= 2; print }'

# Adjust records that have at least three fields, but print the others:
$ awk 'NF >= 3 { NF -= 2; print } 1'

# Ignore records which match the /foobar/ regex, adjust and print the rest:
$ awk '/foobar/ { next } { NF -= 2; print }'


------------------------------

Date: Tue, 02 Dec 2014 06:40:50 +0100
From: gamo <gamo@telecable.es>
Subject: Re: Need to strip off the non wordy characters
Message-Id: <m5jjd1$sgj$1@speranza.aioe.org>

El 02/12/14 a las 02:05, clearguy02@yahoo.com escribió:
> Hi,
>
> I have the following data:
>
> ++++++++++++++
> 411 Availability 79 0%
> [SITESPEED]­SRP 1 0%
> Accessibility Evaluator 53 0%
> Accounting Access Provisioning 6 0%
> Activities Stream 1 0%
> Adverb Funnel Reporting 14 0%
> Adverb Performance Tracking Data Mart 27 65%
> Channeling 53 0%
> AE ­ Attribute Extraction 113 50%
> +++++++++++++++++
>
> Now I want the output to be as follows (Only Ad Name with no numbers and no percentages at the end of the Ad name):
>
> ++++++++++
> 411 Availability
> [SITESPEED]­SRP
> Accessibility Evaluator
> Accounting Access Provisioning
> Activities Stream
> Adverb Funnel Reporting
> Adverb Performance Tracking Data Mart
> Channeling
> AE ­ Attribute Extraction
> +++++++++++++
>
> How can I get it?
>
> while (<DATA>)
> {
>     $_ = ($1)\s\d+\s\d+\%;
>
>     print $_;
> }
>
> Would the above snippet work? Kindly let me know.
>

while (<DATA>){
	s/^(.+)(\s\d+)(\s\d+\%)/$1/;
	print;
}	

Untested, prove this.

while (<DATA>){
	@line = split /\s/;
	if (@line >=3){
		$new = join(' ', (@line)[0..$#line-2] );
		print "$new\n";	
	}else { print ; }
		
}					

Or this. TIMTOWTDI

-- 
http://www.telecable.es/personales/gamo/


------------------------------

Date: Tue, 02 Dec 2014 09:22:39 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Need to strip off the non wordy characters
Message-Id: <m5jpb0$27kh$1@news.ntua.gr>

On 2/12/2014 03:05, clearguy02@yahoo.com wrote:
> ++++++++++++++
> 411 Availability 79 0%
> [SITESPEED]­SRP 1 0%
> Accessibility Evaluator 53 0%
> Accounting Access Provisioning 6 0%
> Activities Stream 1 0%
> Adverb Funnel Reporting 14 0%
> Adverb Performance Tracking Data Mart 27 65%
> Channeling 53 0%
> AE ­ Attribute Extraction 113 50%
> +++++++++++++++++


while (<DATA>)
{
/^(.*?)[\d\s%]*$/ or next;
print "$1\n";
}



__DATA__

++++++++++++++
411 Availability 79 0%
[SITESPEED]­SRP 1 0%
Accessibility Evaluator 53 0%
Accounting Access Provisioning 6 0%
Activities Stream 1 0%
Adverb Funnel Reporting 14 0%
Adverb Performance Tracking Data Mart 27 65%
Channeling 53 0%
AE ­ Attribute Extraction 113 50%
+++++++++++++++++



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 4320
***************************************


home help back first fref pref prev next nref lref last post