[21952] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4174 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 25 18:06:44 2002

Date: Mon, 25 Nov 2002 15:05:08 -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           Mon, 25 Nov 2002     Volume: 10 Number: 4174

Today's topics:
    Re: [Q] my vs. our (Mark Jason Dominus)
    Re: A little help on a regex expression please <jane.doe@acme.com>
        Already asking for help.. <extendedpartition@NOSPAM.yahoo.com>
        Bijeenkomst Amsterdam Perl Mongers, Dinsdag 3 december  (Johan Vromans)
        Converting UTF-8 to ISO-8859-1 (Francesco Moi)
        Module creation... (Stefan Adams)
        New to group/introduction <extendedpartition@NOSPAM.yahoo.com>
    Re: Pattern matching, may contain - or . (Tad McClellan)
        Question about IO::Socket Usage... <extendedpartition@NOSPAM.yahoo.com>
        recursive subroutines and global vars problem <isterin@nospam.com>
    Re: recursive subroutines and global vars problem <perl-dvd@ldschat.com>
    Re: recursive subroutines and global vars problem (Malcolm Dew-Jones)
    Re: recursive subroutines and global vars problem <isterin@nospam.com>
    Re: Sending errors to named file as well as stderr <william.cardwell@ericsson.com>
    Re: Sending errors to named file as well as stderr (Tad McClellan)
    Re: Urgent request for help -- posting to a FORM from a (RK)
    Re: Urgent request for help -- posting to a FORM from a (RK)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 25 Nov 2002 21:36:28 +0000 (UTC)
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: [Q] my vs. our
Message-Id: <aru54s$44b$1@plover.com>

In article <4dafc536.0211211047.5da49e9a@posting.google.com>,
 <nobull@mail.com> wrote:
>That document is slightly out-of-date because it pre-dates our().

No fair; I updated it back in January 2000 to mention 'our'.
ALthought I feel there isn't much to say about 'our' that isn't
already taken care of by the "use vars" discussion.

Here's an exception, which I omitted.  Firs you have the following
file, 'MyClass.pm', which defines two classes:

        use strict;
        our(@ISA);

        package MyClass;
        @ISA = ('SomeOtherClass');

        sub new { bless {} => shift() }

        sub mymethod { print "I like pie!\n" }

        package MyModule::Subclass;
        @ISA = ('MyClass');

        sub new { bless {} => shift() }

        1;

Now here's your program:

        use MyModule;
        my $obj = MyModule::Subclass->new or die;
        $obj->mymethod;


When you run this, you get

        Can't locate object method "mymethod" via package
        "MyModule::Subclass" (perhaps you forgot to load
        "MyModule::Subclass"?) at mm.pl line 3.

even though it appears that MyModule::Subclass is going to inherit
'mymethod' from 'MyModule'.  But it doesn't.

Exercise for the reader:  What went wrong?
(Do not post spoilers.  We all know you know.)

>> When to Use my and When to Use local
>> Always use my; never use local.
>> 
>> Wasn't that easy
>
>MJD is being over-simplitic.

I plead guilty.  But I would do it again.  local() should be more or
less stamped out.




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

Date: Mon, 25 Nov 2002 21:22:47 +0100
From: Jane Doe <jane.doe@acme.com>
Subject: Re: A little help on a regex expression please
Message-Id: <4415uukh6icmajtcr7f0nf1u3goqhklu22@4ax.com>

On Mon, 25 Nov 2002 12:58:56 -0600, tadmc@augustmail.com (Tad
McClellan) wrote:
>> s/^.*size="4">(<strong>)?(.+)(<\/strong>)?<\/font>/$2/i;
>                            ^^
>You might want a non-greedy match there instead.
>You might want a s///s option.

Thx for the tips. Like I said, I'm almost there, but there's still the
need to tell Perl to ignore any <strong> and </strong> tags that are
on some lines. 
Someone suggested using the <?:strong>? syntax, but it doesn't work as
intended.

1. Here's a sample:

        <td align="center" width="50%"><p align="center"><font
        color="#0080FF" size="4"><strong>PARIS</strong></font></p>
        </td>
    </tr>
</table>
</center>

<table border="1" width="496">
    <tr>
        <td width="75%"><font size="4">123 rue Dupont </font></td>
    </tr>

2. Here's the regex: 

s/^.*size="4">(<strong>)?(.+)(<\/strong>)?<\/font>/$2/is;

3. Here's the output I get, after adding a trailing \t on each loop to
build a CSV file :

PARIS</strong>    123 rue Dupont    75001   PARIS  01.23.45.67.89
<A Href="mailto:jdoe@acme.comr">jdoe@acme.com</A>

Thx
JD.


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

Date: Mon, 25 Nov 2002 16:57:20 -0600
From: "Extended Partition" <extendedpartition@NOSPAM.yahoo.com>
Subject: Already asking for help..
Message-Id: <3de2ab9d_1@nntp2.nac.net>

Hello Everyone,

Can someone tell me what is wrong with this code (probably EVERYTHING)?
Basically, it is not able to determine the remote host name so it always
fails to connect. What am I doing wrong? Thanks in advance! -- Anthony

#!usr/bin/perl
use IO::Socket;

my ($recip_info, $from_address, $subject, $hostname, $username, $body);


($recip_info = $ARGV[0]) || &usage;
($from_address = $ARGV[1]) || &usage;
($subject = $ARGV[2]) || &usage;
($body = $ARGV[3]) || &usage;

my @reciever_info = split(/\@/, $recip_info);
my @sender_info = split(/\@/, $from_address);

$username = $receiver_info[0];
$hostname = $receiver_info[1];
$my_username = $sender_info[0];
$my_hostname = $sender_info[1];

   print "Connecting to remote mail host $hostname...\n";
   my $sock = new IO::Socket::INET(
            PeerAddr =>'$hostname',
            PeerPort => 25,
            Proto => 'tcp');
   die "Could not initialize socket. Exiting.\n" unless $sock; #This is
always executed when it fails!!
   print "Connected.\n";
   print "Sending mail...\n";
   &send_mail;




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

Date: 25 Nov 2002 18:54:36 +0100
From: jvromans@squirrel.nl (Johan Vromans)
Subject: Bijeenkomst Amsterdam Perl Mongers, Dinsdag 3 december 2002
Message-Id: <m21y59y1pf.fsf@phoenix.squirrel.nl>


[English version follows the dutch text]

Amsterdam.pm staat voor de "Amsterdamse Perl Mongers", een groep van
gebruikers van Perl. In tegenstelling tot wat de naam suggereert is
Amsterdam.pm niet beperkt tot alleen Amsterdam, maar functioneert, tot
er meer gebruikersgroepen in Nederland zijn, als Nederlandse
gebruikersgroep.

Amsterdam.pm organiseert informele bijeenkomsten waar Perl gebruikers
kunnen samenkomen en informatie en gebruikservaringen met betrekking
tot Perl kunnen uitwisselen. Deze bijeenkomsten vinden normaliter
plaats op elke eerste dinsdag van de maand. De voertaal binnen
Amsterdam.pm is in pricipe Nederlands, maar indien nodig zal Engels
worden gebruikt, b.v. om te communiceren met niet-Nederlandssprekende
aanwezigen.

De eerstvolgende bijeenkomst vindt plaats op dinsdag 3 december van
20:00 tot 22:00 uur op het kantoor van XS4All, Eekholt 42, Diemen. 

Voor een routebeschrijving, zie
http://www.xs4all.nl/contact/routebeschrijving.html

Liefhebbers van een etentje vooraf kunnen tussen 17:45 en 18:15
verzamelen. Om 18:15 (écht om 18:15!) zoeken we een restaurantje in de
buurt om een hapje te eten.

Bezoek onze Web site http://amsterdam.pm.org voor meer details.

[English version]

Amsterdam.pm stands for the Amsterdam Perl Mongers. We're basically a
Perl user group. Despite its name, it is not local to the Amsterdam
environment, but it welcomes Perl mongers from all over the
Netherlands.

Amsterdam.pm organises informal meetings where Perl users can meet,
and exchange information and experiences with regard to using Perl.
The meetings are normally held every first Tuesday of the month.
Although the preferred language for communication is Dutch, English
will be spoken if necessary.

Our next meeting is Tuesday December 3rd, from 20:00 till 22:00 at the
office of XS4All, Eekholt 42, Diemen.

See http://www.xs4all.nl/contact/routebeschrijving.html for directions to
get there.

Should you want to join some of us for dinner, please gather between
17:45 and 18:15. At 18:15 sharp we'll leave for a restaurant somewhere
nearby for dinner.

See http://amsterdam.pm.org for more details.

------------------------------------------------------------------------------
Johan Vromans                                             jvromans@squirrel.nl
Squirrel Consultancy                                  Haarlem, the Netherlands
http://www.squirrel.nl                  http://www.squirrel.nl/people/jvromans
PGP Key 2048/4783B14D   KFP = 65 44 CA 66 B3 50 0B 34  CE 0E FB CA 2D 95 34 D0
------------------------ "Arms are made for hugging" -------------------------


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

Date: 25 Nov 2002 14:30:07 -0800
From: francescomoi@europe.com (Francesco Moi)
Subject: Converting UTF-8 to ISO-8859-1
Message-Id: <5b829932.0211251430.45d15ef4@posting.google.com>

Hello.

Does anybody have any routine/function to convert a string from UTF-8
to ISO-8859-1 by using Perl?

Thank u very much.


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

Date: 25 Nov 2002 13:03:49 -0800
From: stefan@borgia.com (Stefan Adams)
Subject: Module creation...
Message-Id: <dcc927de.0211251303.6810f39@posting.google.com>

I've been reading the online docs and O'Reilly books about writing
modules and I still do not have a solid grasp on it.  Perhaps some of
you can help enlighten me.  One of the man pages also said to post a
message to this group with a desired interface for assisstance in
module creation.

Here is my proposed interace:
# Groups, Account, and Access are all names of tables in my database. 
I specify them here because I would like them to be plug-ins.  That
way if I were to create a new table called Profile I could then
specify it below and would have access to its data as well.
    use UnnamedAsOfYet qw{Groups Account Access};

# dbh is the DBI database handler
    my $db = UnnamedAsOfYet->new(dbh=>$dbh);

# Groups is a database table.  Key and groupname are columns.  This
interface allows me to access the groups table and get the groupname
of the key '1'.
    print $db->groups(key => '1')->groupname;

# Groups is a database table.  Key and groupname are columns.  This
interface allows me to access the groups table and get the key of the
groupname 'admin'.
    print $db->groups(groupname => 'admin')->key;

# Account is a database table.  Key and username are columns.  This
interface allows me to access the account table and get the key of the
username 'stefan'.
    print $db->account(key => '1')->username;

# Account is a database table.  Key and username are columns.  This
interface allows me to access the account table and get the username
of the key '1'.
    print $db->account(username => 'stefan')->key;

# Access is a database table.  Script_name and message are columns. 
This interface allows me to access the access table and get the
message of the script_name '/index.mhtml'.  The access method
determines if username 'stefan' has access to script_name
'/index.mhtml' and if not the message column is returned.
    my $user = $db->account(username => 'stefan');
    print $user->access(script_name => '/index.mhtml')->message;

Does this interface make sense?  Is this a good, clear way to design
it?

To support my model of using plug-ins, I have broken the packages into
the following:

(Package
    Method)
UnnamedAsOfYet.pm
    new
UnnamedAsOfYet/Access.pm
    message
UnnamedAsOfYet/Account.pm
    key
    username
UnnamedAsOfYet/Groups.pm
    key
    username

What advice might you have to allow the above proposed interface to
work or what modifications to the interface might you have?

Any help would be greatly appreciated.
I have never really written any modules except from following
tutorials that I have read.  So I think I have a basic understanding
of the theory but I am having a difficult time putting what I have
learned into practice.  I am very interested in learning to write
modules but I need some initial help to get me going.

Thanks for anything you can supply.

Stefan Adams


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

Date: Mon, 25 Nov 2002 15:06:58 -0600
From: "Extended Partition" <extendedpartition@NOSPAM.yahoo.com>
Subject: New to group/introduction
Message-Id: <3de291bc_2@nntp2.nac.net>

Hello Everyone,

My name is Anthony Saffer and I'm new to CLPM.  I'm a fairly experienced
programmer who's just discovered the joy and ease of use of Perl and I am
hungrily learning all I can about the language. I can't believe I've
overlooked it all these years! Anyway, just wanted to introduce myself. Hope
I can contribute something unique, interesting, or helpful to the group and
I look forward to meeting you all.

--
Anthony M. Saffer
SCS Consulting Services
Professional Web, Software, and Database Development
www.safferconsulting.com
ICQ 96698595




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

Date: Mon, 25 Nov 2002 15:23:23 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Pattern matching, may contain - or .
Message-Id: <slrnau556b.2al.tadmc@magna.augustmail.com>

Marc Pelletier <mpelleti@nortelnetworks.com> wrote:
> Hi there,
> 
> I have a program that connects to a device and runs a few commands.  I
> set the prompt for it like so:
> 
> $prompt='\w+\(\w+\)#';

That is the same as:

   $prompt='[a-zA-Z0-9_]+\([a-zA-Z0-9_]+\)#';

only without using the shorthand \w representaion for word characters.

> Recently I've come across people naming (which I have no control over)
> devices with '-' or '.' in the name. 

> Can anyone
> recomment a way around something like this.


If you want to add hyphen to your character classes, then just
add a hyphen to your character classes:

   $prompt='[a-zA-Z0-9_-]+\([a-zA-Z0-9_-]+\)#';
or
   $prompt='[\w-]+\([\w-]+\)#';


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 25 Nov 2002 15:04:31 -0600
From: "Extended Partition" <extendedpartition@NOSPAM.yahoo.com>
Subject: Question about IO::Socket Usage...
Message-Id: <3de29129_1@nntp2.nac.net>

Hello Everyone,

I am writing a socket based program and have run into a small problem. I
will be cycling through a list and sending the contents over a socket. The
problem is, the server will only accept 3-5 sends at a time. So I need a way
to know when the server disconnects my socket so I can force a reconnect.
Here is how I am connecting:

$sock = IO::Socket::INET->new(PeerAddr=>$hostname,
            PeerPort=>9900,
            Proto='tcp');

Then, I am going to place my "sending" code in a while loop. So I know that
code will send my entire list. BUT, how do I test if the socket is still
connected BEFORE I send?  I know this is probably not a general language
question but I hope someone will take the time to answer it anyway!

Thanks,
Anthony M. Saffer
SCS Consulting Services
Professional Web, Software, and Database Development
www.safferconsulting.com
ICQ 96698595




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

Date: Mon, 25 Nov 2002 14:04:38 -0500
From: "Ilya Sterin" <isterin@nospam.com>
Subject: recursive subroutines and global vars problem
Message-Id: <arts87$6vl26@eccws12.dearborn.ford.com>

I have a recursive subroutine that utilizes a global array variable to push
into it while recursing.  The recursion works fine and I can print out
values as needed from it, but something goes on with the way that the global
vars are being cached, since after the recursion occurs, the global array is
still empty.  When doing a dump of the array during recursion, on each
recurse, the array has one value which is pushed, sometimes two values, but
it doesn't persistantly add values to it, must be the way recursive
functions handle globals and variables period.  I couldn't find anything in
docs or books.  Here is the code...

####################################
our @array;
my $dbh = open_connection_dbi();
get_sponsor_id($dbh, $Session->{"Member_ID"}, 0, \@array);

sub get_sponsor_id
{
 my $dbh = shift;
 my $user_id = shift;
 my $level = shift;

 my $sth = $dbh->prepare("select Member_Id from tblMember where Sponsor_Id =
?");
 $sth->execute($user_id);

 while (my $id = $sth->fetchrow_array())
 {
  push(@array, [$id, $level+1]);
  }

 if (@array)
 {
  my $tmp_arr = shift(@array);
  get_sponsor_id($dbh, $tmp_arr->[0], $tmp_arr->[1]);
 }
 return 0;
}
####################################

I'm sure I can probably duplicate that with a few loops, but I'm looking to
use recurse for clarity.  Can anyone please give me some insides on why this
is not working as expected.

@array after the function recurses is totally empty.

Thanks in advance.

Ilya




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

Date: Mon, 25 Nov 2002 12:29:46 -0700
From: "David" <perl-dvd@ldschat.com>
Subject: Re: recursive subroutines and global vars problem
Message-Id: <OLuE9.5561$EY.863@fe01>

"Ilya Sterin" <isterin@nospam.com> wrote in message
news:arts87$6vl26@eccws12.dearborn.ford.com...
> I have a recursive subroutine that utilizes a global array variable to
push
> into it while recursing.  The recursion works fine and I can print out
> values as needed from it, but something goes on with the way that the
global
> vars are being cached, since after the recursion occurs, the global
array is
> still empty.  When doing a dump of the array during recursion, on each
> recurse, the array has one value which is pushed, sometimes two
values, but
> it doesn't persistantly add values to it, must be the way recursive
> functions handle globals and variables period.  I couldn't find
anything in
> docs or books.  Here is the code...
>
> ####################################
> our @array;
> my $dbh = open_connection_dbi();
> get_sponsor_id($dbh, $Session->{"Member_ID"}, 0, \@array);
>
> sub get_sponsor_id
> {
>  my $dbh = shift;
>  my $user_id = shift;
>  my $level = shift;
>
>  my $sth = $dbh->prepare("select Member_Id from tblMember where
Sponsor_Id =
> ?");
>  $sth->execute($user_id);
>
>  while (my $id = $sth->fetchrow_array())
>  {
>   push(@array, [$id, $level+1]);
>   }
>
>  if (@array)
>  {
>   my $tmp_arr = shift(@array);
>   get_sponsor_id($dbh, $tmp_arr->[0], $tmp_arr->[1]);
>  }
>  return 0;
> }
> ####################################
>
> I'm sure I can probably duplicate that with a few loops, but I'm
looking to
> use recurse for clarity.  Can anyone please give me some insides on
why this
> is not working as expected.
>
> @array after the function recurses is totally empty.
>
> Thanks in advance.

Heres your problem:

my $tmp_arr = shift(@array);

shift chops the first element off of the array.  If you want to set
$tmp_arr = the first element of that array and leave that element on the
array, try this instead:

my $tmp_arr = $array[0];


Good luck,
David






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

Date: 25 Nov 2002 13:03:28 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: recursive subroutines and global vars problem
Message-Id: <3de29020@news.victoria.tc.ca>

Ilya Sterin (isterin@nospam.com) wrote:


: ####################################
: our @array;
: my $dbh = open_connection_dbi();
: get_sponsor_id($dbh, $Session->{"Member_ID"}, 0, \@array);

                                                   ^^^^^^^^

Why are you passing a reference to the array which you never use?  I don't
think that causes a problem here, but it is indicative of cloudy thinking
which will undoubtedly lead to bugs in your code later. 

(Don't necessarily take it out though - passing the array as a parameter
is a generically good idea as it decouples the subroutine from the code
that calls it.) 

: sub get_sponsor_id
: {
:  my $dbh = shift;
:  my $user_id = shift;
:  my $level = shift;

my $ary_ref = shift;  # the array might now be accessed as "@{$ary_ref}" 


:  my $sth = $dbh->prepare("select Member_Id from tblMember where Sponsor_Id =
: ?");
:  $sth->execute($user_id);

:  while (my $id = $sth->fetchrow_array())
:  {
:   push(@array, [$id, $level+1]);
:   }

:  if (@array)
:  {
:   my $tmp_arr = shift(@array);
:   get_sponsor_id($dbh, $tmp_arr->[0], $tmp_arr->[1]);
:  }
:  return 0;
: }
: ####################################

: I'm sure I can probably duplicate that with a few loops, but I'm looking to
: use recurse for clarity.  Can anyone please give me some insides on why this
: is not working as expected.

: @array after the function recurses is totally empty.

: Thanks in advance.

: Ilya



--


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

Date: Mon, 25 Nov 2002 16:57:44 -0500
From: "Ilya Sterin" <isterin@nospam.com>
Subject: Re: recursive subroutines and global vars problem
Message-Id: <aru6co$72v22@eccws12.dearborn.ford.com>

ah, what a careless mistake.  I meant to make it a temp array, instead of
shifting the real thing.  Thanks:-)

Ilya

"David" <perl-dvd@ldschat.com> wrote in message
news:OLuE9.5561$EY.863@fe01...
> "Ilya Sterin" <isterin@nospam.com> wrote in message
> news:arts87$6vl26@eccws12.dearborn.ford.com...
> > I have a recursive subroutine that utilizes a global array variable to
> push
> > into it while recursing.  The recursion works fine and I can print out
> > values as needed from it, but something goes on with the way that the
> global
> > vars are being cached, since after the recursion occurs, the global
> array is
> > still empty.  When doing a dump of the array during recursion, on each
> > recurse, the array has one value which is pushed, sometimes two
> values, but
> > it doesn't persistantly add values to it, must be the way recursive
> > functions handle globals and variables period.  I couldn't find
> anything in
> > docs or books.  Here is the code...
> >
> > ####################################
> > our @array;
> > my $dbh = open_connection_dbi();
> > get_sponsor_id($dbh, $Session->{"Member_ID"}, 0, \@array);
> >
> > sub get_sponsor_id
> > {
> >  my $dbh = shift;
> >  my $user_id = shift;
> >  my $level = shift;
> >
> >  my $sth = $dbh->prepare("select Member_Id from tblMember where
> Sponsor_Id =
> > ?");
> >  $sth->execute($user_id);
> >
> >  while (my $id = $sth->fetchrow_array())
> >  {
> >   push(@array, [$id, $level+1]);
> >   }
> >
> >  if (@array)
> >  {
> >   my $tmp_arr = shift(@array);
> >   get_sponsor_id($dbh, $tmp_arr->[0], $tmp_arr->[1]);
> >  }
> >  return 0;
> > }
> > ####################################
> >
> > I'm sure I can probably duplicate that with a few loops, but I'm
> looking to
> > use recurse for clarity.  Can anyone please give me some insides on
> why this
> > is not working as expected.
> >
> > @array after the function recurses is totally empty.
> >
> > Thanks in advance.
>
> Heres your problem:
>
> my $tmp_arr = shift(@array);
>
> shift chops the first element off of the array.  If you want to set
> $tmp_arr = the first element of that array and leave that element on the
> array, try this instead:
>
> my $tmp_arr = $array[0];
>
>
> Good luck,
> David
>
>
>
>




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

Date: Mon, 25 Nov 2002 16:03:08 -0500
From: Will Cardwell <william.cardwell@ericsson.com>
To: Will Cardwell <william.cardwell@ericsson.com>
Subject: Re: Sending errors to named file as well as stderr
Message-Id: <3DE2900C.4461C0E9@ericsson.com>

Thanks so much for these suggestions. Since I don't now have IO::Tee and
am not the admin for my platform, I think I will try the $SIG routine
first.
Best to all,
Will

Will Cardwell wrote:

> I would like to know the easiest way to change a script so that all
> errors that normally go to stderr also go to another file, say
> "myerrfile".
>
> Any ideas appreciated.
>
> Thank you,
> Will Cardwell



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

Date: Mon, 25 Nov 2002 15:28:59 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Sending errors to named file as well as stderr
Message-Id: <slrnau55gr.2al.tadmc@magna.augustmail.com>

Will Cardwell <william.cardwell@ericsson.com> wrote:

> Since I don't now have IO::Tee and
> am not the admin for my platform,


You do not need to be the admin to install Perl modules.

   perldoc -q module

      "How do I keep my own module/library directory?"


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 25 Nov 2002 14:08:38 -0800
From: rizkar@hotmail.com (RK)
Subject: Re: Urgent request for help -- posting to a FORM from a Perl Script
Message-Id: <fbbc3c30.0211251408.2a9f469e@posting.google.com>

> I think you must have overlooked a cookie, sent at the same time as the
> above.

Yes, I did overlook the cookie. I am now using IO::Socket to log in,
and I get the following response:

HTTP/1.1 302 Object moved
Server: Microsoft-IIS/5.0
Date: Mon, 25 Nov 2002 22:03:18 GMT
Location: welcome.asp
Connection: Keep-Alive
Content-Length: 132
Content-Type: text/html
Set-Cookie: ASPSESSIONIDQCSSSBBR=GGJOGDNCHLBPNFDCCCLFDAPF; path=/
Cache-control: private

<head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a
HREF="welcome.asp">here</
a>.</body>

Any idea how I can use the Cookie defined above to GET "welcome.asp"?
I have tried setting $ENV{'HTTP_COOKIE'}, and also parsing out and
printing the cookie line ("Set-Cookie:
ASPSESSIONIDQCSSSBBR=GGJOGDNCHLBPNFDCCCLFDAPF; path=/")
as part of my GET request (right after Content-type: text/html).

Neither of the above worked. Any assistance would be greatly
appreciated.

Kind regards.


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

Date: 25 Nov 2002 14:21:20 -0800
From: rizkar@hotmail.com (RK)
Subject: Re: Urgent request for help -- posting to a FORM from a Perl Script
Message-Id: <fbbc3c30.0211251421.3fc90d88@posting.google.com>

Here is my code:

$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "www.domain.com",
PeerPort => "http(80)",);
unless ($remote) { die "cannot connect to HTTP port"
}
$remote->autoflush(1);
print $remote "GET /usercheck/userloginr.asp HTTP/1.0\r\nContent-type:
application/x-www-form-urlencoded\nContent-length: $length\n\n";
print $remote "$args\n";

while ( <$remote> ) { 
print $_;
if (/Cookie/) { $line = $_; }
}

$remote2 = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "www.domain.com",
PeerPort => "http(80)",);
unless ($remote) { die "cannot connect to HTTP port"
}
$remote2->autoflush(1);
print $remote2 "GET /usercheck/welcome.asp HTTP/1.0\r\nContent-type:
text/html\n$line\n\n";

while ( <$remote2> ) { 
print $_;
}



However, the result of the second request (GET request) is another
"Object Moved"...this time to "userlogin.asp"!

Any ideas of what I'm doing wrong? I'm pretty sure I'm not formatting
the GET request correctly...


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

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.  

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


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