[16476] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3888 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 2 18:05:49 2000

Date: Wed, 2 Aug 2000 15:05:26 -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: <965253925-v9-i3888@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 2 Aug 2000     Volume: 9 Number: 3888

Today's topics:
        (Off Topic) Sa hohchifo ut Godzilla! <amonotod@netscape.net>
        Advice on processing a file <mark.drummond@rmc.ca>
        Any perl web experts out there - please help (David Krainess)
    Re: Any perl web experts out there - please help (Greg Bacon)
    Re: attribute names in errors in DBI:mysql (Jon Drukman)
        bitwise and decimal number... <jmarsan@my-deja.com>
    Re: bitwise and decimal number... <lr@hpl.hp.com>
    Re: connecting to oracle <makarand_kulkarni@my-deja.com>
    Re: connecting to oracle (Abigail)
    Re: day_of_week() and age() without using Date::Calc ? (Logan Shaw)
    Re: DBI: Same data accessed twice? (Jon Drukman)
    Re: Dec->Hex, how to? <gellyfish@gellyfish.com>
        Deleting files on Windows systems <samara_biz@hotmail.com>
    Re: Deleting files on Windows systems <tina@streetmail.com>
    Re: Deleting files on Windows systems (Greg Bacon)
        DES for PERL won't compile on Solaris 2.6 rkhatri@my-deja.com
        five lines of NQL or 45 lines of Perl  hmmmm...... <Doug_Manney@mail-net.com>
        FormMail.pl problems (Red Jackson)
    Re: Getopts - need to pass info to array. (Brandon Metcalf)
    Re: How to Post a message to a newsgroup using Perl ? <iltzu@sci.invalid>
    Re: How to Post a message to a newsgroup using Perl ? <lauren_smith13@hotmail.com>
    Re: HTTP::Request::Common Help <gisle@ActiveState.com>
    Re: HTTP::Request::Common Help <rudie@wpi.edu>
    Re: HTTP::Request::Common Help rmore1@my-deja.com
    Re: Need to read a html page and save it via perl Unabl <tfm@sei.cmu.edu>
    Re: Need to read a html page and save it via perl Unabl <T.Cockle@staffs.ac.uk>
        Perl CGI on PWS !! puzzlerrr@my-deja.com
    Re: Perl CGI on PWS !! <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: Perl in Windows 2000 <jeff@yoak.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 02 Aug 2000 21:31:02 GMT
From: amonotod <amonotod@netscape.net>
Subject: (Off Topic) Sa hohchifo ut Godzilla!
Message-Id: <8ma3un$fej$1@nnrp1.deja.com>

Ana kostinka istimalpiskássi nia.

Speaking on behalf of some(one)(thing) else...
amonotod

--
    `\|||/                     amonotod@
      (@@)                     netscape.net
  ooO_(_)_Ooo________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 02 Aug 2000 17:34:35 -0400
From: "Mark E. Drummond" <mark.drummond@rmc.ca>
Subject: Advice on processing a file
Message-Id: <398893EB.D7921680@rmc.ca>

I am trying to read in a file, line at a time, and process certain
elements within it. In particular, I am trying to read the a Samba
smb.conf file. I am converting from Samba to PC Netlink and want to
programmatically re-create the shares I have defined in smb.conf as
shares in PC netlink. The file, if you are not familiar with it, starts
with some global definitions and then share specific definitions. Each
section/share definition has a heading enclosed in square brackets:

[global]
	workgroup = blah
 .
 .
# SHARES
[share1]
	comment = blah
	path = /some/path
 .
 .

[share2]
	path = /another/path
 .
 .

I put the "# SHARES" in as a marker, figuring it would be useful. So I
need to search through the file, find where the shares begin (# SHARES)
and then find and pull each share name (only what is between the
brackets) along with it's corrensponding path (only what is after the
"path ="). I figure I can match what I want with:

	/^[(.*)]/;
	$share = $1;
	/^.*path = (.*)/;
	$path = $1;

not working code of course. Anyway, I am a bit lost on how to have my
script grok a "heterogenous" file like this. Any hints? Opinions?

Maybe something like:

while (<FILE> ! /^# PRINTERS/) {
	$share = /^[(.*)]/;		# line 1
	$path  = /^.*path = (.*)/;	# line 2
	if ($path) {
		`net share $share=c:$path`
		undef $share; undef $path;
	}
}

My thought with lines 1 & 2 was that $share and $path would only be
created if the left hand side actually matched. Am I out to lunch or
what?

-- 
Mark Drummond|ICQ#19153754|mailto:mark.drummond@rmc.ca
UNIX System Administrator|Royal Military College of Canada
The Kingston Linux Users Group|http://signals.rmc.ca/klug/
Saving the World ... One CPU at a Time

Please excuse me if I am terse. I answer dozens of emails every day.


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

Date: Wed, 02 Aug 2000 19:14:29 GMT
From: davidkrainess@yahoo.com (David Krainess)
Subject: Any perl web experts out there - please help
Message-Id: <8F84744A4davidkrainessyahooco@38.9.69.2>

Assuming this ludicrously simple perl code run in cgi-bin

/usr/bin/perl -w
use strict;
print "content-type: application/octet-stream";
my $txt = "abcdefg";
print $txt;


What I want is to have a 'save as' box pop up in the client's web browser 
running this script that save "abcedfg" to a txt file on the client's hard 
drive.  If I print a octet content type line before printing $txt, just an 
empty text file is saved.  My goal is to have a dynamic text file sent 
directly to the browser.

Can this be done?

Any help would be greatly appreciated.


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

Date: Wed, 02 Aug 2000 19:18:54 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Any perl web experts out there - please help
Message-Id: <sogt0u7idbm50@corp.supernews.com>

In article <8F84744A4davidkrainessyahooco@38.9.69.2>,
    David Krainess <davidkrainess@yahoo.com> wrote:

: Assuming this ludicrously simple perl code run in cgi-bin
: 
: /usr/bin/perl -w
: use strict;
: print "content-type: application/octet-stream";
: my $txt = "abcdefg";
: print $txt;
: 
: 
: What I want is to have a 'save as' box pop up in the client's web browser 
: running this script that save "abcedfg" to a txt file on the client's hard 
: drive.

Yours is a CGI question.  Please ask CGI questions in a CGI newsgroup
like comp.infosystems.www.authoring.cgi.

Followups set.

Greg
-- 
Our game plan is first year, a .500 season. Second year, a conference
championship. Third year, undefeated. Fourth, a national championship.
And by the fifth year, we'll be on probation, of course.
    -- Bear Bryant


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

Date: Wed, 02 Aug 2000 19:36:31 GMT
From: jsd@cluttered.com (Jon Drukman)
Subject: Re: attribute names in errors in DBI:mysql
Message-Id: <slrn8ogu2f.mfs.jsd@cluttered.com>

On 2 Aug 2000 07:52:24 GMT, Paul J. Lucas <pjl-news@barefooters.org> wrote:
>	I'm using MySQL for a database.  In a given table, there is a
>	UNIQUE constraint on an attribute.  Inserting a duplicate value
>	for said attribute righty causes an error; however, the error is
>	of the form:
>
>		Duplicate '<value>' for key 3
>
>	where <value> is the duplicate value.  The problem is that this
>	error message, as-is, can not be shown to an end user.  What I
>	want is to print the attribute name and not its index, i.e.:
>
>		Duplicate '<value>' for "login"
>
>	There appears to be no way to set this in DBI or DBD:mysql
>	(unless I've missed it).  What can be done is to do a:
>
>		SHOW COLUMNS FROM <table>
>
>	and then read the column information into an array then use the
>	index (-1) as an index into the array to get the attribute name.
>	However, this is really awkward.

it's also wrong, since "key 3" has no relation to the columns of the table.
you'd have to use SHOW KEYS FROM <table> instead.

but i wouldn't bother with that.  just trap the error message and
substitute "login" for "key 3".

-jsd-





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

Date: Wed, 02 Aug 2000 20:16:47 GMT
From: JMarsan <jmarsan@my-deja.com>
Subject: bitwise and decimal number...
Message-Id: <8m9vj9$c1j$1@nnrp1.deja.com>

Hi,

I need to create a decimal number after 2 strings and a bitwise. Here
is what I do:

#!/usr/bin/perl -w

$a = "10000000";
$b = "01000000";
$c = $a | $b;

print $c; # prints 11000000, which is ok

But now I want to transform $c into a decimal number. I tried with pack
and unpack but since I am still a newbie, I haven't succeed.

Please help.

--
J. Marsan
Technician, IT
N.S.D.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 2 Aug 2000 14:00:22 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: bitwise and decimal number...
Message-Id: <MPG.13f22bbe584fe05398ac2a@nntp.hpl.hp.com>

In article <8m9vj9$c1j$1@nnrp1.deja.com> on Wed, 02 Aug 2000 20:16:47 
GMT, JMarsan <jmarsan@my-deja.com> says...

 ...

> print $c; # prints 11000000, which is ok
> 
> But now I want to transform $c into a decimal number. I tried with pack
> and unpack but since I am still a newbie, I haven't succeed.

It takes some time and experimentation to become effective with those 
functions.  But it is worth the effort.

> Please help.

  print unpack C => pack B8 => $c;

Note:  I like to use the 'fat comma' to separate the format argument 
(which is part of the operator, really) from the actual operands.  In 
this case, I also used its magical quoting powers, just for fun.

> --

If you put a magic invisible space after the dashes, newsreaders will 
automatically clip your signature.

 ...

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 02 Aug 2000 14:45:16 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
Subject: Re: connecting to oracle
Message-Id: <3988966C.17AE271@my-deja.com>

> And ... I don't know what I need to connect from the
> first to the second with Perl ???

No need to recompile perl.
You need 

DBD::Oracle
DBI.pm

to compile DBD::Oracle you might need
some Oracle files/libs.

--


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

Date: 02 Aug 2000 22:01:35 GMT
From: abigail@foad.org (Abigail)
Subject: Re: connecting to oracle
Message-Id: <slrn8oh6hg.6n1.abigail@alexandra.foad.org>

Gabriel Euzet (g.euzet@gti-info.com) wrote on MMDXXVIII September
MCMXCIII in <URL:news:8m9f21$c3j$1@reader1.fr.uu.net>:
[] 
[] 
[] We've 2 PC's
[] * Redhat + Perl 5
[] * Redhat + Oracle 8
[] 
[] And ... I don't know what I need to connect from the
[] first to the second with Perl ???

A cable from one PC to the other.

[] I don't know :
[] * if I must compile Perl again,

Maybe.

[] * if a module exists

Yes.

[] * what are the perl functiojns to use

None. You'd use the functionality from the module.



Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54";
print if s/<<EOT/<<EOT/e;
Just another Perl Hacker
EOT


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

Date: 2 Aug 2000 16:59:12 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: day_of_week() and age() without using Date::Calc ?
Message-Id: <8ma5jg$eu8$1@provolone.cs.utexas.edu>

In article <3987e880$1@news.datev.de>,
Guenther Degenfelder <guenther.degenfelder@datev.de> wrote:
>@TageBisErsten=(
> 0,
> 31,
> 31+28,
> 31+28+31,
> 31+28+31+30,
> 31+28+31+30+31,
> 31+28+31+30+31+30,
> 31+28+31+30+31+30+31,
> 31+28+31+30+31+30+31+31,
> 31+28+31+30+31+30+31+31+30,
> 31+28+31+30+31+30+31+31+30+31,
> 31+28+31+30+31+30+31+31+30+31+30,
> 31+28+31+30+31+30+31+31+30+31+30+31
>);

Or, you could write this:

	{
	my $t;
	@TageBisErsten =
		map ($t += $_, qw{ 0 31 28 31 30 31 30 31 31 30 31 30 31 });
	}

  - Logan


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

Date: Wed, 02 Aug 2000 19:58:38 GMT
From: jsd@cluttered.com (Jon Drukman)
Subject: Re: DBI: Same data accessed twice?
Message-Id: <slrn8ogvbl.mfs.jsd@cluttered.com>

On Wed, 02 Aug 2000 03:09:11 GMT, Paul King <pking@idirect.com> wrote:
>The inner loop "foreach" cycles through the message parts, but it seems
>as if
>fetchrow_array() (part of Perl::DBI) fetches the same data twice that is
>passed to the handle. Is this possible? What am I doing wrong here?

try this instead.

>   my $sth2 = $dbh -> prepare (
>            "SELECT * FROM messages
>             WHERE (message_num_m = $message_num)"
>   ) or die "Can't prepare SELECT statement: $DBI::errstr\n";

this is fine but you might want to investigate using a placeholder
in the select instead of putting $message_num in directly.  it's
more flexible, particularly if you want to loop.

also, don't you want to ORDER BY partnum?

also, using * is not a good idea because you are now dependent on
the order in which columns were defined, and if someone drops and
recreates your table, they may be in a different order, immediately
breaking your script.

i would probably do the whole thing like this (i am guessing at
the names of your columns):

my $ref=selectall_arrayref(
          'SELECT clientnum,partnum,of_total,message
           FROM messages WHERE message_num_m = ? ORDER BY $partnum',
          undef, $message_num);

for (@$ref) {
  print <<ROW;
For this row:
clientnum = $_->[0]
partnum = $_->[1]
of_total = $_->[2]
message = $_->[3]
ROW
}


if you don't like all those $_->[0] constructs, you can do:

my ($clientnum,$partnum,$oftotal,$message) = @{$_};

at the top of the block and refer to those variables instead.


-jsd-





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

Date: 2 Aug 2000 22:00:59 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Dec->Hex, how to?
Message-Id: <8ma26b$j2q$1@orpheus.gellyfish.com>

On Tue, 01 Aug 2000 13:11:22 GMT aqutiv@softhome.net wrote:
> Hrrm, I can't seem to find a way to turn a decimal number into an hex
> string with perl... Is it possible? I couldn't find a built-in function
> of sort.. What I need is the reversal operation of hex(xx), and it is
> needed for a query string link.
> 

If you want to url encode a string then you could use something like:

    $string =~ s/([^a-zA-Z0-9])/sprintf "%%%02X",ord($1)/eg;

Or alternatively the facilities offered by CGI.pm .  If you are going
to present the query string as part of a link as you suggest you should
also be looking at encoding the HTML entities appropriately.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Wed, 02 Aug 2000 14:29:56 -0400
From: "Alex T." <samara_biz@hotmail.com>
Subject: Deleting files on Windows systems
Message-Id: <398868A4.1307B684@hotmail.com>

Hi,

I have a question about deleting files using Perl on Windows systems.

I am writing a script which should delete the specified file. The only
way I could find to do it is to use system("erase
path\\to\\file\\$filename").

1. Is this the only way to do so?

2. Am I right in understanding that I have to use backslashes if I call
a windows command, so in this case I have to double them in Perl?

3. Also... I have to negate the values that are returned by the
functions, so the command for deleting files looks like this in my
script:

!system("del $temp_dir\\$temp1") || die ($!);

As I understand that is because system returns whatever is returned by
the windows command, and in this case erase returns 0 for success and 1
for failure, which in case of Perl means exactly opposite. Did I get the
right idea about the whole thing?

Thanks!

Alex



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

Date: 2 Aug 2000 19:08:52 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Deleting files on Windows systems
Message-Id: <8m9rk3$65hnr$4@ID-24002.news.cis.dfn.de>

hi,
Alex T. <samara_biz@hotmail.com> wrote:

> I have a question about deleting files using Perl on Windows systems.

without further reading i would say:
use the unlink function =)

perldoc -f unlink

this works on windows and on other systems.

tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \ _,_\ __/\ __/_| /__/ perception
please no answers via email unless followup is set to poster.


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

Date: Wed, 02 Aug 2000 19:11:37 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Deleting files on Windows systems
Message-Id: <sogsj97cdbm82@corp.supernews.com>

In article <398868A4.1307B684@hotmail.com>,
    Alex T. <samara_biz@hotmail.com> wrote:

: I am writing a script which should delete the specified file. The only
: way I could find to do it is to use system("erase
: path\\to\\file\\$filename").
: 
: 1. Is this the only way to do so?

No.  Perl has an unlink() operator for deleting files.  Find its
documentation in the perlfunc manpage.

: 2. Am I right in understanding that I have to use backslashes if I call
: a windows command, so in this case I have to double them in Perl?

The stoopid Windows command interpreter doesn't understand The One True
Slash.  The library and system calls, however, understand both slashes
as path separators.  If you're going to communicate with the stoopid
Windows command interpreter, then you must double backwhack with
ferocity.

: 3. Also... I have to negate the values that are returned by the
: functions, so the command for deleting files looks like this in my
: script:
: 
: !system("del $temp_dir\\$temp1") || die ($!);
: 
: As I understand that is because system returns whatever is returned by
: the windows command, and in this case erase returns 0 for success and 1
: for failure, which in case of Perl means exactly opposite. Did I get the
: right idea about the whole thing?

Yes.  Most people usually write something like

    @args = ("command", "arg1", "arg2");
    system(@args) == 0
         or die "system @args failed: $?"

Greg
-- 
The magic words are squeamish ossifrage.


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

Date: Wed, 02 Aug 2000 18:28:34 GMT
From: rkhatri@my-deja.com
Subject: DES for PERL won't compile on Solaris 2.6
Message-Id: <8m9p89$6m7$1@nnrp1.deja.com>

I downloaded DES 1.01 from www.perl.com, and I'm
having problems installing it.

We're using Solaris 2.6 on a Sun Ultra 5.10
machine.  The Perl version is 5.6.

After successfully creating the Makefile, I run
make and I get the following errors:

iaf@bell1> make
/usr/local/bin/gcc -c  -fno-strict-aliasing -
I/usr/local/include -D_LARGEFILE_SOURCE -
D_FILE_OFFSET_BITS=64 -O      -DVERSION=\"1.01
\"  -DXS_VERSION=\"1.01\" -fPIC -
I/usr/local/lib/perl5/5.6.0/sun4-solaris/CORE
DES.c

In file included from DES.xs:10:
des.h:3: parse error before `des_user_key'
des.h:3: warning: data definition has no type or
storage class
des.h:4: parse error before `des_cblock'
des.h:4: warning: data definition has no type or
storage class
des.h:5: parse error before `des_ks'
des.h:5: warning: data definition has no type or
storage class
des.h:7: parse error before `in'
des.h:8: parse error before `userKey'
DES.xs: In function `XS_Crypt__DES_expand_key':
DES.xs:20: `des_ks' undeclared (first use in this
function)
DES.xs:20: (Each undeclared identifier is
reported only once
DES.xs:20: for each function it appears in.)
DES.xs:20: parse error before `ks'
DES.xs:26: `u_int8_t' undeclared (first use in
this function)
DES.xs:26: parse error before `)'
DES.xs:28: `ks' undeclared (first use in this
function)
DES.xs: In function `XS_Crypt__DES_crypt':
DES.xs:47: `des_ks' undeclared (first use in this
function)
DES.xs:50: `sv_undef' undeclared (first use in
this function)
DES.xs:57: `u_int32_t' undeclared (first use in
this function)
DES.xs:57: parse error before `)'
*** Error code 1
make: Fatal error: Command failed for target
`DES.o'

Do I need to alter the source code (des.h, des.c)
to make this work?

Thanks for any suggestions!

Raj




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 2 Aug 2000 14:23:01 -0500
From: "Doug Manney" <Doug_Manney@mail-net.com>
Subject: five lines of NQL or 45 lines of Perl  hmmmm......
Message-Id: <8m9s7n$h2n$1@news.jump.net>

Scripters and Programmers,

NQL (Network Query Language) is a dynamic and innovative tool that makes it
possible to retrieve information from any network, organize it in any format
and deploy it across any platform including wireless devices such as the
Palm Pilot VII, digital cellphones and digital pagers.

NQL sets a new standard for developer productivity, saving time and allowing
comprehensive interoperability with all programming and scripting languages.

We are currently seeing an almost 90% purchase rate after companies evaluate
the software including Microsoft and Ingram Micro.

To see the latest information on NQL and download a full version for a free
30 day evaluation visit our website at www.NQLSolutions.com/downloaddirect

Please contact me at 888-816-1930 for questions concerning your companies’
specific needs and how NQL can solve them.

Thank you,

I look forward to doing business with you.

Doug Manney







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

Date: Wed, 02 Aug 2000 19:03:28 GMT
From: redone~nospam~@siteconnect.com (Red Jackson)
Subject: FormMail.pl problems
Message-Id: <39886f39.601404263@news.siteconnect.com>

Hi!
I'm running Formmail.pl  (Ver 1.6) on Apache 1.3.9 with mod_perl built
into Apache. When I send e-mail using the form it somehow never clears
the user input. So the first e-mail from the form is fine. The second
e-mail has all of the first e-mail in it plus the info from the second
post and so on. Which is no good. I'm not sure what's happening any
clues or tips apperciated.

Thanks!

Red Jackson
System Engineer
Cypress Communications
red@nospam.cypresscom.net 


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

Date: 2 Aug 2000 19:10:12 GMT
From: bmetcalf@nortelnetworks.com (Brandon Metcalf)
Subject: Re: Getopts - need to pass info to array.
Message-Id: <8m9rmk$ipv$1@bcrkh13.ca.nortel.com>

tizatron@my-deja.com writes:

 > require 'getopts.pl';
 > use diagnostics;
 > &Getopts('hrmf:v:');

Change this to

use Getopt::Std;
getopts('hr:mf:v');

Options followed by : require an argument.  The others are just boolean
flags.

 > sub setSwitches {
 > 
 >    #
 >    # this seems like a bad way to do this, diagnostics gacks
 >    # and values never seem to get into the array.  How do I pass
 >    # multiple filsystems into the array?????
 >    #
 >    @FileSystems = $opt_f if defined ($opt_f);

Why not specify a list of filesystems separated by say a : and then
split the list into an array.  If your program is myprog, call it with

myprog -f /etc:/usr/lib:/bin

and then your code would be

@filesystems = split /:/ => $opt_f;

 >    # This is like FileSytem, I would like to pass in muliple
 >    # RCS label requests to a full report
 >    # However, no matter what I specify on the command line for -r
 >    # the value is always 1???
 >    @RevisionList = $opt_r if defined ($opt_r);

The reason that it's always 1 is that in your original call to getopts
you didn't follow r with a : , so it's simply a boolean flag.  You can
pass in multiple labels the same way you do for multiple filesystems.

Of course, there are many other ways to accomplish this.

Brandon


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

Date: 2 Aug 2000 18:11:00 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: How to Post a message to a newsgroup using Perl ?
Message-Id: <965239766.13097@itz.pp.sci.fi>

In article <398816c4.674859125@news.telepac.pt>, Rui Anastácio wrote:
> Can anyone tell-me how to post a message a a newsgroup using Per ? 
> Thanks

Like this.

(Sorry - I just couldn't resist..)

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Wed, 2 Aug 2000 13:49:46 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: How to Post a message to a newsgroup using Perl ?
Message-Id: <8ma1fv$m0v$1@brokaw.wa.com>


Rui Anastácio <ranastacio@mail.telepac.pt> wrote in message
news:398816c4.674859125@news.telepac.pt...
>
>  Hi !
>
>  Can anyone tell-me how to post a message a a newsgroup using Per ?
>  Thanks

See the thread titled "posting in newsgroup using perl script?" in this
newsgroup.

Head over to www.deja.com and learn about searching Usenet.  You should be
able to find the noted thread there.

Lauren





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

Date: 02 Aug 2000 21:04:47 +0200
From: Gisle Aas <gisle@ActiveState.com>
Subject: Re: HTTP::Request::Common Help
Message-Id: <m3n1ivpjqo.fsf@eik.g.aas.no>

Brian Murphy <rudie@wpi.edu> writes:

> I'm trying to create a very simple client that will post to a webboard,
> but I want to do it locally.  Here is what I have so far, but there is a
> problem with it (minus the "anonymoused" ip address).
> 
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
> #!/usr/local/bin/perl
> use HTTP::Request::Common qw(POST);
> use LWP::UserAgent;
> use CGI qw(:standard);
> use strict;
> 
> my($ua, $req, $content, $weblocal);
> my $weblocal = "http://xxx.xxx.xxx.xxx/scripts/board.cgi";
> 
> $ua = LWP::UserAgent->new();
> $req = HTTP::Request->new(POST "$weblocal",
         ^^^^^^^^^^^^^^^^^^^
            Remove this

>         [ user    => 'standpipe',
>           name    => 'Brian',
>           email   => '',
>           subject => 'Boring',
>           message => 'Yawn. Start saying funny things now.' ]);
> 
> 
> $content = $ua->request($req)->as_string;
> 
> print "Content-type: text/html\n\n";
> print $content;
> exit(0);
> 
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
> 
> 
> It prints out the following:
> 
> Content-type: text/html
> 
> 400 (Bad Request) URL missing
> 
> 
> This made no sense to me.  So I then tried to use only a GET statement,
> and it printed out the normal html for the situation (you need to enter a
> name, blah, blah).  Can anyone tell me what I'm doing wrong here?  Thanks.

POST() is a function that returns a new HTTP::Request object.  You
should not try to pass this as an argument to the HTTP::Request->new()
method.

-- 
Gisle Aas


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

Date: Wed, 2 Aug 2000 15:18:48 -0400
From: Brian Murphy <rudie@wpi.edu>
Subject: Re: HTTP::Request::Common Help
Message-Id: <Pine.OSF.4.21.0008021518310.25903-100000@grover.WPI.EDU>

On 2 Aug 2000, Gisle Aas wrote:

>Brian Murphy <rudie@wpi.edu> writes:
>
>> I'm trying to create a very simple client that will post to a webboard,
>> but I want to do it locally.  Here is what I have so far, but there is a
>> problem with it (minus the "anonymoused" ip address).
>> 
>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>> #!/usr/local/bin/perl
>> use HTTP::Request::Common qw(POST);
>> use LWP::UserAgent;
>> use CGI qw(:standard);
>> use strict;
>> 
>> my($ua, $req, $content, $weblocal);
>> my $weblocal = "http://xxx.xxx.xxx.xxx/scripts/board.cgi";
>> 
>> $ua = LWP::UserAgent->new();
>> $req = HTTP::Request->new(POST "$weblocal",
>         ^^^^^^^^^^^^^^^^^^^
>            Remove this
>
>>         [ user    => 'standpipe',
>>           name    => 'Brian',
>>           email   => '',
>>           subject => 'Boring',
>>           message => 'Yawn. Start saying funny things now.' ]);
>> 
>> 
>> $content = $ua->request($req)->as_string;
>> 
>> print "Content-type: text/html\n\n";
>> print $content;
>> exit(0);
>> 
>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>> 
>> 
>> It prints out the following:
>> 
>> Content-type: text/html
>> 
>> 400 (Bad Request) URL missing
>> 
>> 
>> This made no sense to me.  So I then tried to use only a GET statement,
>> and it printed out the normal html for the situation (you need to enter a
>> name, blah, blah).  Can anyone tell me what I'm doing wrong here?  Thanks.
>
>POST() is a function that returns a new HTTP::Request object.  You
>should not try to pass this as an argument to the HTTP::Request->new()
>method.
>
>-- 
>Gisle Aas


Ah-hah.  I got it.  Thanks.

Brian



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

Date: Wed, 02 Aug 2000 19:23:38 GMT
From: rmore1@my-deja.com
Subject: Re: HTTP::Request::Common Help
Message-Id: <8m9sfj$9h0$1@nnrp1.deja.com>

In article <Pine.OSF.4.21.0008021319270.18010-100000@grover.WPI.EDU>,
  Brian Murphy <rudie@wpi.edu> wrote:
> Hello,
>
> I'm trying to create a very simple client that will post to a
webboard,
> but I want to do it locally.  Here is what I have so far, but there
is a
> problem with it (minus the "anonymoused" ip address).
>
>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXX
> #!/usr/local/bin/perl
> use HTTP::Request::Common qw(POST);
> use LWP::UserAgent;
> use CGI qw(:standard);
> use strict;
>
> my($ua, $req, $content, $weblocal);
> my $weblocal = "http://xxx.xxx.xxx.xxx/scripts/board.cgi";
>
> $ua = LWP::UserAgent->new();
> $req = HTTP::Request->new(POST "$weblocal",
>         [ user    => 'standpipe',
>           name    => 'Brian',
>           email   => '',
>           subject => 'Boring',
>           message => 'Yawn. Start saying funny things now.' ]);
>
> $content = $ua->request($req)->as_string;
>
> print "Content-type: text/html\n\n";
> print $content;
> exit(0);
>
>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXX
>
> It prints out the following:
>
> Content-type: text/html
>
> 400 (Bad Request) URL missing
>
> This made no sense to me.  So I then tried to use only a GET
statement,
> and it printed out the normal html for the situation (you need to
enter a
> name, blah, blah).  Can anyone tell me what I'm doing wrong here?
Thanks.
>  (Please don't say, "Go check CPAN for the module man file", I already
> have done that, and had no luck getting what I wanted to work.)
>
> Brian
>
>
try this syntax from 'perldoc lwpcook'
===================
       use HTTP::Request::Common qw(POST);
       use LWP::UserAgent;
       $ua = new LWP::UserAgent;

       my $req = POST 'http://www.perl.com/cgi-bin/BugGlimpse',
                     [ search => 'www', errors => 0 ];

       print $ua->request($req)->as_string;
=============================
Richard More
http://www.richmore.com/


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 02 Aug 2000 14:44:39 -0400
From: Ted Marz <tfm@sei.cmu.edu>
Subject: Re: Need to read a html page and save it via perl Unable to Use LWP
Message-Id: <39886C17.2FAD221C@sei.cmu.edu>

I have "installed" perl modules on my local account of a shared
webserver when that server didn't have the module in their standard
distribution, and then included them into @INC, and been quite
successful.

Otherwise, you would have to set up a TCP/IP socket (perhaps using the
telnet module as a shortcut?) and do all of the protocol handling
yourself.

Ted


ken wrote:
> 
> any suggestions on how to read a url, and save the page to a file
> can be accomplished without the use of the lwp module (virtualave have not
> installed that)
> ?
> 
> Thanks for any help


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

Date: Wed, 02 Aug 2000 19:00:44 +0100
From: Tim Cockle <T.Cockle@staffs.ac.uk>
To: ken <kensplace@comport.com>
Subject: Re: Need to read a html page and save it via perl Unable to Use LWP
Message-Id: <398861CC.71D6A7B2@staffs.ac.uk>

If you want to download and save a file it is fairly simple.

You need to
1 open a socket to the local proxy or to the original web sever
2 make request i.e. print $socket 'GET $url HTTP/1.0';
3 read the response to a file i.e while (<$socket>) {print $file $)};

If you don't want the HTTP headers then before step 3 insert:

   while(<$socket>) {
     if ($_ =~ /^[\s\x00]*$/) {
        last;
     }
   }

ken wrote:

> any suggestions on how to read a url, and save the page to a file
> can be accomplished without the use of the lwp module (virtualave have not
> installed that)
> ?
>
> Thanks for any help



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

Date: Wed, 02 Aug 2000 20:20:03 GMT
From: puzzlerrr@my-deja.com
Subject: Perl CGI on PWS !!
Message-Id: <8m9vpd$c3g$1@nnrp1.deja.com>

HI...

i have installed the personal web server on w98 & also installed Perl for
Win32 from activestate under /wwwroot... then i created a virtual dir that
points to the actual dir of perl.exe (say perl56) & assianged appropriate
permissions.. but when i tried to run the simple hello world cgi program, i
always got 500 server error !! (it's fine to run from command prompt
though...no syntax err..) the beginning of my cgi file looks like this...

#!/perl56
use CGI;
print "Content-Type: text/html\n\n";
 .............

so what have i done wrong ?? how come it just couldn't run ??!! can anyone
help me ??

thanx....


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 02 Aug 2000 14:35:57 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Perl CGI on PWS !!
Message-Id: <3988943D.6E668FB@jpl.nasa.gov>

puzzlerrr@my-deja.com wrote:
> i have installed the personal web server on w98 & also installed Perl for
> Win32 from activestate under /wwwroot... then i created a virtual dir that
> points to the actual dir of perl.exe (say perl56) & assianged appropriate
> permissions.. but when i tried to run the simple hello world cgi program, i
> always got 500 server error !! (it's fine to run from command prompt
> though...no syntax err..) the beginning of my cgi file looks like this...
> 
> #!/perl56
> use CGI;
> print "Content-Type: text/html\n\n";
> .............
> 
> so what have i done wrong ?? how come it just couldn't run ??!! can anyone
> help me ??

You will get better help if you ask people who know something about your
server (i.e., not us).  Also read 'perldoc CGI' /CREATING THE HTTP
HEADER.

Jon
-- 
Knowledge is that which remains when what is
learned is forgotten. - Mr. King


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

Date: Wed, 02 Aug 2000 12:18:24 -0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: Perl in Windows 2000
Message-Id: <8m9l6s13od@news1.newsguy.com>

In article <075a8b6f.6fa6bde3@usw-ex0103-086.remarq.com>, Brian
<bmacdonaldNObmSPAM@netstone.com.invalid> wrote:
> Hello, I have used Perl with unix. But in my current job they run all
> windows. And i am not sure how to run Perl scripts. Do i have to change
> my coding at all for windows. And What about a perl intrperter?
> Cheers... Brian

Brian,

	Another quick note:  There is a Perl for Win32 FAQ kicking around.  That
might help you out.  Good luck in the new job and sorry to hear about the
Windows.  :-)  They should tell you these things before they hire you,
huh?

Cheers,
Jeff



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

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 3888
**************************************


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