[23966] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6167 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 19 21:05:36 2004

Date: Thu, 19 Feb 2004 18:05:07 -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           Thu, 19 Feb 2004     Volume: 10 Number: 6167

Today's topics:
    Re: Beginner question on @INC <uri@stemsystems.com>
        FORM POST submission <cenxnfu@rpr.nevmban.rqh>
    Re: FORM POST submission <pobugfix@peterlink.ru>
    Re: FORM POST submission <nospam@bigpond.com>
    Re: FORM POST submission <pobugfix@peterlink.ru>
    Re: FORM POST submission <pobugfix@peterlink.ru>
    Re: FORM POST submission <cenxnfu@rpr.nevmban.rqh>
    Re: FORM POST submission <cenxnfu@rpr.nevmban.rqh>
    Re: how can a daemon output to console <bik.mido@tiscalinet.it>
    Re: map, for, and while (Anno Siegel)
    Re: more stripping <hillmw@ram.lmtas.lmco.com>
    Re: newbie: inheritance <usenet@morrow.me.uk>
    Re: newbie: inheritance (Anno Siegel)
    Re: OPEN( , Get , or slurping problem <bik.mido@tiscalinet.it>
    Re: OPEN( , Get , or slurping problem <jwkenne@attglobal.net>
    Re: perl controlling samba permissions? (Anthony Boyd)
    Re: perl controlling samba permissions? <usenet@morrow.me.uk>
    Re: Replacing all "special characters" with code <bik.mido@tiscalinet.it>
    Re: testing for directories/files fails <bik.mido@tiscalinet.it>
        The DATA filehandle and utf8 <flavell@ph.gla.ac.uk>
    Re: TMTOWTDI (Anno Siegel)
    Re: TMTOWTDI <uri@stemsystems.com>
    Re: Unexplained output for PERL print statement <bik.mido@tiscalinet.it>
    Re: what is ^K? (Anno Siegel)
    Re: Win32::Clipboard() and Excel <mikeflan@earthlink.net>
        XML to Class::Struct <pobugfix@peterlink.ru>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 20 Feb 2004 01:23:01 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Beginner question on @INC
Message-Id: <x7znbemtmz.fsf@mail.sysarch.com>

>>>>> "ES" == Eric Schwartz <emschwar@pobox.com> writes:

  ES> You may be right, but when I ask a question, I will say, "I read
  ES> the docs for the Illudium Q-36 Explosive Space Modulator, and the
  ES> section on Coping with Earth-based Rabbits completely makes no
  ES> sense.  I don't understand the directions to 'RUN AWAY'."  I will
  ES> not say, "How do I use this thing again?", or even "I want to
  ES> destroy the Earth, with Perl.  Pls advice."

you maroon!! that is because the docs for that are written in fuddese!

i think it is time to hydrate some martians.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 19 Feb 2004 16:56:58 -0700
From: Cognition Peon <cenxnfu@rpr.nevmban.rqh>
Subject: FORM POST submission
Message-Id: <Pine.GSO.4.50.0402191646280.9167-100000@shellfish.ece.arizona.edu>


Hi,

I have followed the example in the perlfaq to automate
a post form submission:

#!/usr/bin/perl

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

$ua = LWP::UserAgent->new();
my $req = POST 'http://68.0.148.101:8055/login.html',
  [ userid => 'File', password => 'pass'];
$content = $ua->request($req)->as_string;

HTML for the form is in the following file
http://68.0.148.101:8055/login.html

upon submission it must goto
http://68.0.148.101:8055/index.html

I am expecting the $content variable to have
the content of index.html but its getting login.html

I didn't find anybody who had similar problem.. and
its quite frustrating because it is a very simple
form submission page.

Thanks,
Prakash.

-- 
echo cenxnfu@rpr.nevmban.rqh | perl -pe 'y/a-z/n-za-m/'

Off the keyboard, over the bridge, past the hub, thru the
router, down the line, ....nothing but net!!
-------------------------------------
Printed using 100% recycled electrons


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

Date: Fri, 20 Feb 2004 03:21:25 +0300
From: "Andrew V. Tkachenko" <pobugfix@peterlink.ru>
Subject: Re: FORM POST submission
Message-Id: <c13jtu$lr3$1@news.rol.ru>


If you will check source of http://68.0.148.101:8055/login.html
you will see that 'action' is not 'http://68.0.148.101:8055/login.html'
but 'http://68.0.148.101:8055/index.html'


my $req = POST 'http://68.0.148.101:8055/index.html',
    [ userid => 'File', password => 'pass'];



Cognition Peon wrote:
> Hi,
> 
> I have followed the example in the perlfaq to automate
> a post form submission:
> 
> #!/usr/bin/perl
> 
> use HTTP::Request::Common qw(POST);
> use LWP::UserAgent;
> 
> $ua = LWP::UserAgent->new();
> my $req = POST 'http://68.0.148.101:8055/login.html',
>   [ userid => 'File', password => 'pass'];
> $content = $ua->request($req)->as_string;
> 
> HTML for the form is in the following file
> http://68.0.148.101:8055/login.html
> 
> upon submission it must goto
> http://68.0.148.101:8055/index.html
> 
> I am expecting the $content variable to have
> the content of index.html but its getting login.html
> 
> I didn't find anybody who had similar problem.. and
> its quite frustrating because it is a very simple
> form submission page.
> 
> Thanks,
> Prakash.
> 



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

Date: 20 Feb 2004 00:55:25 GMT
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: FORM POST submission
Message-Id: <4859562.qyQKmpib56@GMT-hosting-and-pickle-farming>

Andrew V. Tkachenko wrote:

> 
> If you will check source of http://68.0.148.101:8055/login.html
> you will see that 'action' is not 'http://68.0.148.101:8055/login.html'
> but 'http://68.0.148.101:8055/index.html'
> 
> 
> my $req = POST 'http://68.0.148.101:8055/index.html',
>     [ userid => 'File', password => 'pass'];
> 

And even its it its POST, you can often get away with
http://68.0.148.101:8055/index.html?userid=XXX&password=YYYY

gtoomey


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

Date: Fri, 20 Feb 2004 04:05:02 +0300
From: "Andrew V. Tkachenko" <pobugfix@peterlink.ru>
Subject: Re: FORM POST submission
Message-Id: <c13mfo$mpu$1@news.rol.ru>

I'm not sure its a good idea to pass passwords through GET method. They
may be viewed in log files either by admin or by successfull hacker :) 
Also, in our case putting GET instead of POST looks like a dirty hack :)



Gregory Toomey wrote:
> Andrew V. Tkachenko wrote:
> 
> 
>>If you will check source of http://68.0.148.101:8055/login.html
>>you will see that 'action' is not 'http://68.0.148.101:8055/login.html'
>>but 'http://68.0.148.101:8055/index.html'
>>
>>
>>my $req = POST 'http://68.0.148.101:8055/index.html',
>>    [ userid => 'File', password => 'pass'];
>>
> 
> 
> And even its it its POST, you can often get away with
> http://68.0.148.101:8055/index.html?userid=XXX&password=YYYY
> 
> gtoomey



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

Date: Fri, 20 Feb 2004 04:06:43 +0300
From: "Andrew V. Tkachenko" <pobugfix@peterlink.ru>
Subject: Re: FORM POST submission
Message-Id: <c13mis$mpu$2@news.rol.ru>

Heh. forget it. POST queries are also visible in logs .

Andrew V. Tkachenko wrote:
> I'm not sure its a good idea to pass passwords through GET method. They
> may be viewed in log files either by admin or by successfull hacker :) 
> Also, in our case putting GET instead of POST looks like a dirty hack :)
> 
> 
> 
> Gregory Toomey wrote:
> 
>> Andrew V. Tkachenko wrote:
>>
>>
>>> If you will check source of http://68.0.148.101:8055/login.html
>>> you will see that 'action' is not 'http://68.0.148.101:8055/login.html'
>>> but 'http://68.0.148.101:8055/index.html'
>>>
>>>
>>> my $req = POST 'http://68.0.148.101:8055/index.html',
>>>    [ userid => 'File', password => 'pass'];
>>>
>>
>>
>> And even its it its POST, you can often get away with
>> http://68.0.148.101:8055/index.html?userid=XXX&password=YYYY
>>
>> gtoomey
> 
> 



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

Date: Thu, 19 Feb 2004 18:22:06 -0700
From: Cognition Peon <cenxnfu@rpr.nevmban.rqh>
Subject: Re: FORM POST submission
Message-Id: <Pine.GSO.4.50.0402191819100.1816-100000@shelltoe.ece.arizona.edu>


Thanks for your response... but I always thought that action should point
to the page where form data will be submitted to.. Upon submission I want
the login.html page to goto index.html

you can test its behaviour at http://68.0.148.101:8055/login.html
it goes to index.html upon entering a random username and password.

Thanks.
Prakash.

Tomorrow, IP packets from Andrew V. Tkachenko delivered:

>
> If you will check source of http://68.0.148.101:8055/login.html
> you will see that 'action' is not 'http://68.0.148.101:8055/login.html'
> but 'http://68.0.148.101:8055/index.html'
>
>
> my $req = POST 'http://68.0.148.101:8055/index.html',
>     [ userid => 'File', password => 'pass'];
>
>
>
> Cognition Peon wrote:
> > Hi,
> >
> > I have followed the example in the perlfaq to automate
> > a post form submission:
> >
> > #!/usr/bin/perl
> >
> > use HTTP::Request::Common qw(POST);
> > use LWP::UserAgent;
> >
> > $ua = LWP::UserAgent->new();
> > my $req = POST 'http://68.0.148.101:8055/login.html',
> >   [ userid => 'File', password => 'pass'];
> > $content = $ua->request($req)->as_string;
> >
> > HTML for the form is in the following file
> > http://68.0.148.101:8055/login.html
> >
> > upon submission it must goto
> > http://68.0.148.101:8055/index.html
> >
> > I am expecting the $content variable to have
> > the content of index.html but its getting login.html
> >
> > I didn't find anybody who had similar problem.. and
> > its quite frustrating because it is a very simple
> > form submission page.
> >
> > Thanks,
> > Prakash.
> >
>
>

-- 
echo cenxnfu@rpr.nevmban.rqh | perl -pe 'y/a-z/n-za-m/'

Fashion is a form of ugliness so intolerable that we have
to alter it every six months.  -- Oscar Wilde (1854 - 1900)
-------------------------------------
Printed using 100% recycled electrons


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

Date: Thu, 19 Feb 2004 18:25:22 -0700
From: Cognition Peon <cenxnfu@rpr.nevmban.rqh>
Subject: Re: FORM POST submission
Message-Id: <Pine.GSO.4.50.0402191824090.1816-100000@shelltoe.ece.arizona.edu>


Please ignore my last question.. Thanks for the help.. Now I understood
after testing it on apage which accepts form variables submitted from
login.html

Thanks,
prakash

6:22pm, IP packets from Cognition Peon delivered:

>
> Thanks for your response... but I always thought that action should point
> to the page where form data will be submitted to.. Upon submission I want
> the login.html page to goto index.html
>
> you can test its behaviour at http://68.0.148.101:8055/login.html
> it goes to index.html upon entering a random username and password.
>
> Thanks.
> Prakash.
>
> Tomorrow, IP packets from Andrew V. Tkachenko delivered:
>
> >
> > If you will check source of http://68.0.148.101:8055/login.html
> > you will see that 'action' is not 'http://68.0.148.101:8055/login.html'
> > but 'http://68.0.148.101:8055/index.html'
> >
> >
> > my $req = POST 'http://68.0.148.101:8055/index.html',
> >     [ userid => 'File', password => 'pass'];
> >
> >
> >
> > Cognition Peon wrote:
> > > Hi,
> > >
> > > I have followed the example in the perlfaq to automate
> > > a post form submission:
> > >
> > > #!/usr/bin/perl
> > >
> > > use HTTP::Request::Common qw(POST);
> > > use LWP::UserAgent;
> > >
> > > $ua = LWP::UserAgent->new();
> > > my $req = POST 'http://68.0.148.101:8055/login.html',
> > >   [ userid => 'File', password => 'pass'];
> > > $content = $ua->request($req)->as_string;
> > >
> > > HTML for the form is in the following file
> > > http://68.0.148.101:8055/login.html
> > >
> > > upon submission it must goto
> > > http://68.0.148.101:8055/index.html
> > >
> > > I am expecting the $content variable to have
> > > the content of index.html but its getting login.html
> > >
> > > I didn't find anybody who had similar problem.. and
> > > its quite frustrating because it is a very simple
> > > form submission page.
> > >
> > > Thanks,
> > > Prakash.
> > >
> >
> >
>
>

-- 
echo cenxnfu@rpr.nevmban.rqh | perl -pe 'y/a-z/n-za-m/'

Off the keyboard, over the bridge, past the hub, thru the
router, down the line, ....nothing but net!!
-------------------------------------
Printed using 100% recycled electrons


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

Date: Fri, 20 Feb 2004 00:52:05 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: how can a daemon output to console
Message-Id: <u6ia30d30vp25mmdqefo0jjde161cch96v@4ax.com>

On 18 Feb 2004 22:57:44 -0800, yf110@vtn1.victoria.tc.ca (Malcolm
Dew-Jones) wrote:

>One option would be Sys::Syslog.  I think you'll find that one of the
>logging options is to send the message to the console, but sending it to a
>log file (see /etc/syslog.conf maybe?) may be even better, since if it's a
>daemon then what "user" will actually be examining the console?

Personally, as a user of some machines of which I was not the admin,
I've always been annoyed by system error messages appearing on the
console at any time (I remember a particularly annoying one about
/dev/hdb4 iirc, probably from the kernel itself), but OTOH it is also
true that at least with some of these errors, if common users would
have not warned the wise admins about "Hey, what's up here? Did I do
something wrong?!?", then the wise admins probably would have never
known that there was something going wrong...

Who knows?!?


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: 19 Feb 2004 23:31:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: map, for, and while
Message-Id: <c13h01$al1$1@mamenchi.zrz.TU-Berlin.DE>

Brian McCauley  <nobull@mail.com> wrote in comp.lang.perl.misc:
> J Krugman <jill_krugman@yahoo.com> writes:
> 
> > With map, one can streamline for-loops like this one:
> > 
> >   my @array_2;
> >   push @array_2, some_sub($_) for @array_1;
> > 
> > into a single assignment:
> > 
> >   my @array_2 = map some_sub($_), @array_1;
> > 
> > Is there a way (not necessarily using map) to streamline while-loops
> > like this one:
> > 
> >   my @array;
> >   push @array, some_other_sub() while some_condition();
> > 
> > into a single assignment to @array?
> 
> I don't think you'll find a way that's more efficient.

I think it's more convenience than efficiency what Jill(?) is after.
Also, some_other_sub() and some_condition() are probably just examples
for arbitrary expressions.

I guess the idea is the mythical "map ... while", which would allow the
above to be written

    map some_other_sub() while some_condition();

(Obviously, "map ... while" is a syntactical construct whose behavior
can't be derived from the normal behavior of "map" and "while".)

> Anyhow, the subroutine-call overhead (let alone whatever's in the

[snip benchmark which compared these:]

> 	push @array, some_other_sub() while some_condition();
> 	push @array, 1 while $i--;

        my @array = map 1 while $i--;

That would beat them all :)

Anno


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

Date: Thu, 19 Feb 2004 18:45:08 -0600
From: Michael Hill <hillmw@ram.lmtas.lmco.com>
To: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: more stripping
Message-Id: <40355894.98456116@ram.lmtas.lmco.com>



> 
> Again, I posted in this thread because security aspects were mentioned
> in such a way that you falsely could get the impression that using
> CGI.pm automatically takes care of them. If those comments hadn't been
> posted, I would have kept my mouth shut this time. ;-)
> 

And this was why I asked about security because it didn't seem correct.


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

Date: Thu, 19 Feb 2004 23:34:01 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: newbie: inheritance
Message-Id: <c13h59$euc$1@wisteria.csv.warwick.ac.uk>


anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> Eric Schwartz  <emschwar@pobox.com> wrote in comp.lang.perl.misc:
> > Ben Morrow <usenet@morrow.me.uk> writes:
> > > Randal's argument is that the semantics of $obj->new are unclear: does
> > > this copy the object, or create a new clean one? Given that, the former
> > > should be handled with a ->clone instance method, and the latter with
> > > (ref $obj)->new, neither of which is ambiguous.
> > 
> > That makes perfect sense, thanks.  I agree completely now that you've
> > explained it that way.
> 
> If god had intended "new" to work this way, "bless" would accept an object
> as its second parameter and bless into its class.

FVO God == Larry, of course :)

Ben

-- 
   Razors pain you / Rivers are damp
   Acids stain you / And drugs cause cramp.                    [Dorothy Parker]
Guns aren't lawful / Nooses give
  Gas smells awful / You might as well live.                   ben@morrow.me.uk


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

Date: 19 Feb 2004 23:42:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: newbie: inheritance
Message-Id: <c13hkt$al1$2@mamenchi.zrz.TU-Berlin.DE>

Ben Morrow  <usenet@morrow.me.uk> wrote in comp.lang.perl.misc:
> 
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

> > If god had intended "new" to work this way, "bless" would accept an object
> > as its second parameter and bless into its class.
> 
> FVO God == Larry, of course :)

An author of apocalypses...

Anno


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

Date: Fri, 20 Feb 2004 00:52:06 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <9fia301vsdamn2utnlhoum5odora8g4105@4ax.com>

On Wed, 18 Feb 2004 23:16:49 +0000 (UTC), "David H. Adler"
<dha@panix.com> wrote:

>> Yeah, I do know that Perl == CGI returns false (or doesn't
>> compile...). ;-)
>
>Ahem.
>
>~ 18:13:43% perl -e 'print "yikes!\n" if Perl == CGI';
>yikes!
>
>eq, however, is a different matter entirely... :-)

FWIW I realized I should have written 'eq' in the first place soon
after sending my post. I half-heartily (<OT>BTW: is this idiomatically
correct in English?</OT>) wanted to post an amendment to it, but
eventually didn't: had I actually known that 'Perl' == 'CGI' returns
true (which I didn't!), I would have certainly done that! Just too
joke-prone not to take advantage of it myself!!


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Fri, 20 Feb 2004 01:18:38 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <OfdZb.7376$ya.2494558@news4.srv.hcvlny.cv.net>

Michele Dondi wrote:
> I half-heartily (<OT>BTW: is this idiomatically
> correct in English?</OT>)

It is not incorrect, but "half-heartedly" is the usual form.

-- 
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
   -- Charles Williams.  "Judgement at Chelmsford"


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

Date: 19 Feb 2004 16:54:50 -0800
From: usenet@outshine.com (Anthony Boyd)
Subject: Re: perl controlling samba permissions?
Message-Id: <cebfe83a.0402191654.7e456a6b@posting.google.com>

Ben Morrow <usenet@morrow.me.uk> wrote:
> usenet@outshine.com (Anthony Boyd) wrote:
> > 
> > I wanted to have a PHP script read the Samba permissions set on each
> > file, and display that via a Web page.  PHP doesn't appear up to the
> > task (but it can get/set Linux permissions OK).
> > 
> > Can Perl handle this?
> 
> I don't think the two sets of permissions are distinct...

Ben, thanks for the reply.  I must be really confused, although it
wouldn't be the first time.  I've created a screenshot, here:

http://www.outshine.com/permissions.jpg

It shows a shared folder, and in that shared folder, I selected a file
and clicked into the permissions for that file.  Under Windows XP, I
am able to assign multiple groups and people to that file, with
various levels of access.  I need Perl to read that list and display
it via the Web.  When I use Perl to get permissions thus far, all I'm
getting is the Unix/Linux permissions, which has 1 owner and 1 group
(usually me, since I shared out the directory in the first place).

In other words, after I share out a directory, people on Windows might
add files and set fairly unique and specific permissions file-by-file.
 How does my Linux box "see" that info, and can Perl get it?  Or are
you suggesting that Samba simply won't save/allow for the
Windows-style permissions.

-Anthony


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

Date: Fri, 20 Feb 2004 01:19:24 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: perl controlling samba permissions?
Message-Id: <c13nas$jev$1@wisteria.csv.warwick.ac.uk>


usenet@outshine.com (Anthony Boyd) wrote:
> Ben Morrow <usenet@morrow.me.uk> wrote:
> > usenet@outshine.com (Anthony Boyd) wrote:
> > > 
> > > I wanted to have a PHP script read the Samba permissions set on each
> > > file, and display that via a Web page.  PHP doesn't appear up to the
> > > task (but it can get/set Linux permissions OK).
> > > 
> > > Can Perl handle this?
> > 
> > I don't think the two sets of permissions are distinct...
> 
<snip>
> In other words, after I share out a directory, people on Windows might
> add files and set fairly unique and specific permissions file-by-file.
>  How does my Linux box "see" that info, and can Perl get it?  Or are
> you suggesting that Samba simply won't save/allow for the
> Windows-style permissions.

The samba docs I have (for version 2.2.8a) clearly say that the only
permissions you will in fact be able to set through that dialog are
those corresponding to user, group and world Unix permissions. The
relevant document is full_docs/htmldocs/NT_Security.html (wherever
you've got the samba docs installed).

Certainly, your screenshot seems to imply that more permissions can be
set... maybe things have changed. Anyway, this belongs on a Samba list:
you ask the Samba folks how you'd get the info in C, we'll tell you how
to get it in Perl. :)

Ben

-- 
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk


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

Date: Fri, 20 Feb 2004 00:52:04 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Replacing all "special characters" with code
Message-Id: <96ia30l80u3eb04835ju1av4pf14ksnsrp@4ax.com>

On 18 Feb 2004 19:32:06 -0800, csdude@hotmail.com (Mike) wrote:

>I'm currently changing all of my "special characters," like &, ",
>whitespace, etc to their HTML counterparts manually (&amp; &quot;
>$nbsp;). The problem is, there could be several that I'm forgetting.

Even if it does just the opposite transformation, you may be
interested in giving a peek into Tom Christiansen script mentioned at
'perldoc -q HTML'!


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Fri, 20 Feb 2004 00:52:04 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: testing for directories/files fails
Message-Id: <o3ia309a4okmqsimcopqemn531b4ar9gi3@4ax.com>

On Wed, 18 Feb 2004 16:35:07 -0700, Ravi Parimi
<parimi@none.nowhere.com> wrote:

>>         foreach my $ls (readdir DH) {
>>                 next if -d $ls;
                   ^^^^^^^^^^^^^^
>>                 print "$ls\n";
>>         }
[snip]
>foreach my $ls (readdir DH) {
>	my $abs_file = File::Spec::Unix->rel2abs($ls,"/var/www/cgi-bin/results");
>
>works as expected. Can anyone explain why all entries are interpreted as
>files?

Because they are not! You just say to skip over to the next iteration
of the loop if(f) the argument (exists and) is a directory. In the
code above (when run as CGI) $ls doesn't exist, so a priori it is not
a directory and you do not skip over to the next item, period!

In other words

  (!-d && -f) != 1;

[In the sense that (! -d && -f) is not guaranteed to be *always* true]

As an aside you may think of passing from "$ls\n" to doing something
useful with $\;


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Thu, 19 Feb 2004 23:28:08 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: The DATA filehandle and utf8
Message-Id: <Pine.LNX.4.53.0402192308150.32079@ppepc56.ph.gla.ac.uk>


In response to an emailed question which I received from a contributor
here[1], which involved the DATA filehandle, with some character data
provided in utf-8, I have noticed that if I "use utf8;" in the
program, then it appears that the DATA filehandle is treated as utf8
also; if I don't "use utf8;" in the code, then I can still get the
DATA filehandle treated as utf8 if I issue an appropriate binmode() on
it, such as:

binmode DATA, ':utf8';  # if one follows the documentation
binmode DATA, ':encoding(utf8)'; # if one follows Ben Morrow[2]

[2] for well-argued reasons, I should add!

In this particular case, the Perl source code is in us-ascii, so
the distinction between utf-8 and iso-8859-1 is invisible; but I
suppose it would not always be so.

I don't recall reading any guidance on correct use of these features.
It might be over-ambitious to try to have program code containing
actual high-half iso-8859-1 characters, followed by DATA containing
utf-8 encoded data, and hoping to process both correctly?  Anyone
familiar with this area please?

[1]p.s
To my email correspondent - both of the addresses I have for you are
spitting back my email to you today, with some confused babble about
address error or virus.  I haven't got a virus, I assure you, though
maybe they have!!!


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

Date: 19 Feb 2004 23:06:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: TMTOWTDI
Message-Id: <c13fi9$85m$3@mamenchi.zrz.TU-Berlin.DE>

Graham Gough  <graham@cs.man.ac.uk> wrote in comp.lang.perl.misc:
> I have been trying to solve a problem in which I wish to substitute
> for *almost* all occurrences of a regular expression. For example all
> occurrences of \d\d\d\d except some specific ones. I ended up with
> using the e modifier and code like that given below, but had a nagging
> felling that there was probably some more elegant method. Anyone any
> suggestions?

Unless the exceptions can be reasonably described through a regex,
the /e modifier is bound to crop up.  Nothing wrong with that.

> $text =~ s/(\d\d\d\d)/&choose($1,"1234")/ge;
> 
> sub choose {
>     my $val = shift;
>     my $notpat = shift;
>     my $ret=$val;
>     if (!($val =~ /$notpat/)) {
>       $ret = "XX" . $ret . "XX";
>     }
>     return $ret;
>   }

There are a few keywords that make a Perl programmer think "Hash!", and
one of them is "a few exceptions".  (Another such keyword is "unique").
In that vein, I'd go for (leaving out the obvious setup of %exceptions,
and untested)

    s/(\d{4})/exists $exceptions{ $1} ? $1 : "XX$1XX"/ge;

Anno


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

Date: Fri, 20 Feb 2004 01:27:58 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: TMTOWTDI
Message-Id: <x7wu6imtep.fsf@mail.sysarch.com>

>>>>> "GJ" == Glenn Jackman <xx087@freenet.carleton.ca> writes:

  >> How about
  >> 
  >> $text =~ s/(?!1234)(\d{4})/XX$1XX/g;

  GJ> Depending on the OP's data, may have undesired matches, for example, if
  GJ> $text="12345"

  GJ> Perhaps, if the OP only cares about 4 digit numbers, and suppose he
  GJ> doesnt want to match 1234 or 6789 or 4242:
  GJ>     $text =~ s/(^|\D)(?!1234|6789|4242)(\d{4})(\D|$)/$1<<$2>>$3/g;

i would still go with /e but just be simpler than the OP's code.

	$text =~ s/(\d{4})/ $1 eq '1234' ? $1 : "XX$1XX" /eg;

if you need to exclude many sets of 4 digits, put them in a hash:

	my %keepers = map { $_ => 1 } qw( 1234 5678 9012 ) ;

	$text =~ s/(\d{4})/ $keepers{$1} ? $1 : "XX$1XX" /eg;

that is clear, fast and modifiable by others.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 20 Feb 2004 00:52:03 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Unexplained output for PERL print statement
Message-Id: <2v8a30lf99438bha1v80jr2kec7hbpk1if@4ax.com>

On Thu, 19 Feb 2004 00:30:02 -0700, Scott Bryce
<sbryce@scottbryce.com> wrote:

>Chop removes the last character in a string. Chomp removes all trailing 
>newline characters.

In a OS independent way too! Modulo Tad's explanation, of course...


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: 19 Feb 2004 23:11:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: what is ^K?
Message-Id: <c13frp$85m$4@mamenchi.zrz.TU-Berlin.DE>

Brian McCauley  <nobull@mail.com> wrote in comp.lang.perl.misc:

>     tr/\cK//d;

Funny way of spelling "trAcKEd".

Anno


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

Date: Fri, 20 Feb 2004 01:38:31 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Win32::Clipboard() and Excel
Message-Id: <40356523.61A3A635@earthlink.net>


Brian Helterline wrote:

> If you want text, specify it:
> $text = $clip->GetText();
>
> according to the docs,
>
> Get()
>
> Returns the clipboard content; note that the result depends on the nature of
> clipboard data; to ensure that you get only the desired format, you should
> use GetText(), GetBitmap() or GetFiles() instead. Get() is in fact
> implemented as:
>         if(    IsBitmap() ) { return GetBitmap(); }
>         elsif( IsFiles()  ) { return GetFiles();  }
>         else                { return GetText();   }
>
> and if you had tried $clip->IsBitmap(), you would have seen that it returned
> true
> so it treated the Excel cell information as a bitmap.
>
> -brian

Thank you very much.  I really appreciate the response.
Your suggestion works perfectly.

I did do some research on this and didn't come up with
any of that.  Unfortunately, I went to:
http://secu.zzu.edu.cn/book/Perl/Perl%20Bookshelf%20%5B3rd%20Ed%5D/perlnut/ch22_01.htm#perlnut2-CHP-22-SECT-1

and
http://www.cpan.org/modules/by-authors/id/ACALPINI/Win32-Clipboard-0.50.readme
via a Google search.

I have now repaired my link to CPAN, and will . . .

Well, now I can't even find the module on CPAN.  I used to go to
"all modules" and find everything I needed, but that was on a
site mirror that no longer exists (404).  The "all modules" I see
now is at:
http://www.perl.com/CPAN/modules/01modules.index.html
and it has no clipboard module I can see.

Sometimes I think Perl is just trying to make me look stupid  :-)


Mike




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

Date: Fri, 20 Feb 2004 02:42:33 +0300
From: "Andrew V. Tkachenko" <pobugfix@peterlink.ru>
Subject: XML to Class::Struct
Message-Id: <c13hl2$l6k$2@news.rol.ru>

Hello.

Does anybody know about existing module wich can do such a trick ?
I mean, converting XML tree into pre-defined Class::Struct ?

Thanks for advance,

Andrew.



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

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:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#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 V10 Issue 6167
***************************************


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