[17091] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4503 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 3 06:10:25 2000

Date: Tue, 3 Oct 2000 03:10:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <970567810-v9-i4503@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 3 Oct 2000     Volume: 9 Number: 4503

Today's topics:
    Re: Massive kill Unix and Perl <gdaniell@wt.com.au>
    Re: Massive kill Unix and Perl (Bernard El-Hagin)
    Re: Newbie can't handle the "true"th...  explanation de (Martien Verbruggen)
    Re: Newby questions <philipg@atl.mediaone.net>
    Re: perl as a browser <jim@inatos.com>
    Re: perl as a browser (Rafael Garcia-Suarez)
    Re: Problem with CGI::Cookie <elephant@squirrelgroup.com>
    Re: Re: How do I link a C Library into Perl (Brian Ingerson)
    Re: Regex: Perl5 to Perl4 Problem (Randal L. Schwartz)
    Re: This post should be a bit easier to answer (Michel Dalle)
    Re: upload script <anders@wall.alweb.dk>
    Re: using PGP on a linux server via perl <jim@inatos.com>
    Re: XML::Simple and not well-formed error (Eric Bohlman)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 03 Oct 2000 14:46:31 +0800
From: Graham Daniell <gdaniell@wt.com.au>
Subject: Re: Massive kill Unix and Perl
Message-Id: <39D980C7.E4AA9B05@wt.com.au>

What is TFM and what is 'qx' ?

(Pardon my ignorance :-)

Graham Daniell
----------------------------

"Tony L. Svanstrom" wrote:

> vivekvp <vivekvp@spliced.com> wrote:
>
> > So I would want to kill 1 and 3 - how would I write a Perl script to do
> > this using Unix system commands?
>
> TFM can be your friend...
>
>         qx/STRING/
>
>         `STRING`
>
>                 A string which is interpolated and then executed as a
> system command. The collected standard output of the command is
> returned.  In scalar context, it comes back as a single (potentially
> multi-line) string. In list context, returns a list of lines (however
> you've defined lines with $/ or $INPUT_RECORD_SEPARATOR).
>
>                     $today = qx{ date };
>
>                 See O Operators" in the "I manpage for more discussion.
>
>      /Tony
> --
>      /\___/\ Who would you like to read your messages today? /\___/\
>      \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
>  --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
>    on the verge of frenzy - i think my mask of sanity is about to slip
>  ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
>     \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/



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

Date: 3 Oct 2000 07:16:27 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Massive kill Unix and Perl
Message-Id: <slrn8tj1ua.al8.bernard.el-hagin@gdndev25.lido-tech>

On Tue, 03 Oct 2000 14:46:31 +0800, Graham Daniell <gdaniell@wt.com.au> wrote:
>What is TFM

TFM - the fucking manual.
	
>and what is 'qx' ?

RTFM and you'll find out (perldoc perlop). :) 
e
a
d

>(Pardon my ignorance :-)

Pardon my French.

Cheers,
Bernard
--
perl -le 'open JustAnotherPerlHacker,""or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'


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

Date: Tue, 3 Oct 2000 16:27:47 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Newbie can't handle the "true"th...  explanation desired
Message-Id: <slrn8tirij.jr6.mgjv@martien.heliotrope.home>

On Tue, 03 Oct 2000 01:33:22 -0000,
	Craig Berry <cberry@cinenet.net> wrote:
> Brad Baxter (bmb@ginger.libs.uga.edu) wrote:
> : OTOH, you could do this and just not care what the value actually is,
> : 
> : my $true  = 1==1;
> : my $false = 1==0;
> 
> Or even
> 
>   my $false;             # undef by default, a false value
>   my $true = ! $false;
> 
> This has a certain pleasing austerity to it.

I know the people discussing this already know this, but for the unweary
reader:

I generally have the same reservations about this as 

#define TRUE 1
#define FALSE 0

for the C language. The objections are actually even stronger in Perl
than they are in C. In C false is 0, and true is anything else. In Perl,
there are many different values of false, and many different values of
true.

It invites the unweary programmer to do things like:

if (some_sub_call() == $true)
{
    # do something
}

Of course, that sub may return all kinds of true values. If that true
value happens to be 2, or "hello", then your comparison suddenly stops
working.

In a language where booleans are not a separate type, and where the only
true and false values are booleans, this is all fine. However, in
languages where true is flexible, and especially if false is also
flexible, specific comparisons should be avoided. Just use

if (some_sub_call())
{
	# do whatever you would do on true-ness
}

for the opposite, use one of

if (!some_sub_call()) {}
unless (some_sub_call()) {}

Using true and false as constants should only ever be done as
assignments, never for comparisons. Because it is too easy to forget
that, I generally use the rule that they should not be used at all.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Think of the average person. Half of
Commercial Dynamics Pty. Ltd.   | the people out there are dumber.
NSW, Australia                  | 


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

Date: Tue, 03 Oct 2000 04:09:04 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: Newby questions
Message-Id: <AZcC5.13817$cW3.2298455@typhoon.southeast.rr.com>

Lawrence <lawrencedeans@NoSpam.genie.co.uk> wrote in message
news:39d8de75.5002590@news.freeserve.net...
> Hi
> I hope this is the right place to ask but I've been analysing a few
> scripts. I would like to fully understand, well almost, the paths and
> processes the data follows from input forms. I want to write or at
> least tweak existing scripts for my own use.

To make all this parsing stuff go away, just use CGI.pm.
perldoc CGI



hth,
p




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

Date: Tue, 3 Oct 2000 09:13:20 +0100
From: "Jim Wright" <jim@inatos.com>
Subject: Re: perl as a browser
Message-Id: <lxgC5.573$_B5.5803@NewsReader>

when a client requests something from a web server it sends a request header
(which might contain cookies that have already been set by the server) - the
server responds with its own headers and the page, if it is setting a cookie
it uses the header

Set-Cookie: name=value;

so just catch that header from the response the server makes to your script.

Hope that helps.
Jim





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

Date: Tue, 03 Oct 2000 09:32:52 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: perl as a browser
Message-Id: <slrn8tjaar.rgo.rgarciasuarez@rafael.kazibao.net>

malatov@my-deja.com wrote in comp.lang.perl.misc:
>I am attmepting to enable cookies in my perl script, as if it were a
>browser. I would like to script to "auto-accept" cookies from sites. Is
>this possible? And if so, how can I do this?

If you want to program a web user agent, you should use the LWP suite of
modules. The module HTTP::Cookies is designed to handle setting and
getting cookies in HTTP request and response headers.

A useful source of information is the Book "Web Client Programming with
Perl", which is freely available on-line at:
    http://www.oreilly.com/openbook/webclient/

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Tue, 3 Oct 2000 15:24:04 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Problem with CGI::Cookie
Message-Id: <MPG.1444187c1c29980e9897e3@localhost>

Tan Siow Kiat wrote ..
>Hi there,
>
>I'm new to perl and learning how to set a cookie, so I copied a section off
>the CGI::Cookie documentation (in ActivePerl):
>------------------------------------------------------
>use CGI qw/:standard/;
>use CGI::Cookie;
># Create new cookies and send them
>$cookie1 = new CGI::Cookie(-name=>'ID',-value=>123456);
>$cookie2 = new CGI::Cookie(-name=>'preferences',
>                           -value=>{ font => Helvetica,
>                                     size => 12 }
>                           );
>print header(-cookie=>[$cookie1,$cookie2]);
># fetch existing cookies
>%cookies = fetch CGI::Cookie;
>$id = $cookies{'ID'}->value;
># create cookies returned from an external source
>%cookies = parse CGI::Cookie($ENV{COOKIE});
>------------------------------------------------------
>My questions are:
>1. When I run the script "perl -w cookie.pl", there is an error msg
>        "Can't call method "value" on an undefined value at cookie.pl line
>12."
>What could be wrong?  Isn't $cookie{'ID'} a proper instance of CGI::Cookie?

not when running from the command line .. from the command line there 
are no cookies passed to the script - hence $cookies{'ID'} is undefined 
and so the method call is throwing the appropriate error message

>2. Then I tried commenting out the offending line12.  The code now compiles,
>so I tried running the script http://homepc/cgi-bin/cookie.pl using IE5 in
>Win2000.

only when run through the browser* will these cookies work successfully 
 .. cookies are a browser technology - and it doesn't make any sense to 
have them work outside the browser environment

>But thereafter, I couldn't find a new cookie.txt file created in my
>"Cookies" folder.  Is this behaviour correct?  I mean, why aren't $cookie1
>and $cookie2 settings saved on my PC, whereas other cookies from commercial
>sites are saved correctly?

this 'not saving' problem has nothing to do with the 'from the command 
line' problem .. learn a bit more about cookies before proceeding .. 
this problem is caused by the expiry period of the cookie

here's a URL that describes Netscape's cookie implementation

  http://home.netscape.com/newsref/std/cookie_spec.html


* LDS might have also added some debug ability to fake cookies from the
  command line .. but that's not really what I'm talking about

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 3 Oct 2000 06:32:02 +0200
From: brian@ingerson.com (Brian Ingerson)
Subject: Re: Re: How do I link a C Library into Perl
Message-Id: <39D9617B.E99198CD@ingerson.com>

> > I have a vendor who has a product that wants
> > the library to be linked into a C program. But
> > the application really is a string based application,
> > ideal for perl. If I could link the library into perl
> > then run natively from there it would be perfect.
> 
> Inline.pm is too new for the FAQs, but worth considering
> as well.

I'd be willing to give you a hand doing it with Inline.

Brian (Inline.pm author)

-- 
Brian Ingerson
INGY@cpan.org
perl -le 'print jaxh("Perl");use Inline C=>q|SV*jaxh(char*x){return
newSVpvf("Just Another %s Hacker",x);}|'

--
Posted from w3.zipcon.net [205.199.135.9] 
via Mailgate.ORG Server - http://www.Mailgate.ORG


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

Date: 02 Oct 2000 23:14:23 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Regex: Perl5 to Perl4 Problem
Message-Id: <m1bsx2ladc.fsf@halfdome.holdit.com>

>>>>> "Duke" == Duke Normandin <01031149@3web.net> writes:

Duke> I need to get the following Perl5 code working in Perl4:

My spider sense is tingling.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 03 Oct 2000 09:25:30 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: This post should be a bit easier to answer
Message-Id: <8rc8o4$5du$1@news.mch.sbs.de>

In article <yY8C5.7542$Q66.4510624@nnrp5-w.sbc.net>, "James Bengard" <jbengard@chaincast.com> wrote:
>I posted a question last night which I figured out how to do, I am now left
>with a problem that I can solve:
>
>I am loading the following information into an array:
>
><chain chainid="19-2" broadcasting="yes" streamwidth="3645">
><transmitter numchildren="15" numpending="0" maxchildren="26"
>numfailures="0" nodeid="130.191.77.177:80">
[snip]
>example output for web
>
>chainid="19-2
>IPAddress and port of all transmitters and repeaters for particular chain.
>

With the description (and sample) you've given here, something like
this would be enough :

while (<FILE>) {
        if (/ chainid="([^"]*)"/) {
                print "chainid=$1\n";
        }
        elsif (/ nodeid="([^"]*)"/) {
                ($host,$port) = split(/:/,$1);
                print "$host $port\n";
        }
}

I'm sure you'd want more, though - so you'll have to tell more :)

Michel.


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

Date: Tue, 3 Oct 2000 09:26:15 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: upload script
Message-Id: <rTfC5.2565$Qu1.169062@news000.worldonline.dk>

Peter Tilsted wrote:

> hello there
> 
> I am looking for an perl file upload script that works with a NT server.
> 
> it should work with all kind of filetypes.
> 
> I have been searching various code collections but all samples i have
> found is for Unix, i was hoping somebody had a script they where willing
> to share.
> 
> TIA
> 
> Peter
> 
> 

perldoc CGI

-anders

-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Tue, 3 Oct 2000 09:17:10 +0100
From: "Jim Wright" <jim@inatos.com>
Subject: Re: using PGP on a linux server via perl
Message-Id: <WAgC5.574$_B5.6055@NewsReader>

Sorry, my mistake when I took out my email from the code I forgot to escape
the @ in the pretend email. The code I had been using did have an escape.

So I am still stumped!

Cheers anyway.
Jim




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

Date: 3 Oct 2000 07:28:21 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: XML::Simple and not well-formed error
Message-Id: <8rc1ql$2u65$1@news.enteract.com>

"Thomas Åhlen" <thomas2@dalnet.se> wrote:
> i get the following error parsing my XML file

> not well-formed at line 33657, column 71, byte 3044169:
>       <Planet id="10" alliance="U.V.T/ARK" name="Crudeism" ruler="Wiseguy"
> size="325" score="637036"/>
>       <Planet id="11" alliance="UVT/C46" name="G-spot" ruler="Orgazmo"
> size="203" score="955981"/>
>       <Planet id="12" alliance="U.V.T/C46" name="Obereschingen" ruler="Mr.
> Dummbatz" size="214" score="793690"/>
> =====================================================^
>       <Planet id="13" alliance=" " name="Classic Planet" ruler="Classic
> Killer" size="1" score="14324"/>
>       <Planet id="14" alliance=" " name="Default" ruler="Default" size="6"
> score="49344"/>
>       <Planet id="15" alliance="ARK/FED" name="Water Planet" ruler="Ocaen
> Man" size="90" score="648989"/>
>  at /usr/lib/perl5/site_perl/5.005/i386-linux/XML/Parser.pm line 185

> well under my shell it points to the " in ="Mr

I'm going to take a guess that "Obereschingen" actually includes some
non-ASCII Latin-1 characters and that the XML file lacks an encoding
declaration and is therefore assumed by the parser to be in UTF-8.



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4503
**************************************


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