[28564] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9928 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 3 18:05:49 2006

Date: Fri, 3 Nov 2006 15: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           Fri, 3 Nov 2006     Volume: 10 Number: 9928

Today's topics:
    Re: Calling Perl program from Java Script and populatin krakle@visto.com
    Re: Calling Perl program from Java Script and populatin <thepoet_nospam@arcor.de>
    Re: Getting huge data into memory in perl <tzz@lifelogs.com>
    Re: killing processes using perl (artsd) <andreas./@\.poipoi.de>
    Re: killing processes using perl (artsd) <andreas./@\.poipoi.de>
    Re: Mailbox-style directory hashing <hjp-usenet2@hjp.at>
    Re: Masking/Hiding a password in Perl Source <glex_no-spam@qwest-spam-no.invalid>
    Re: Masking/Hiding a password in Perl Source <sigzero@gmail.com>
        Sorted Hash and or Array <bradbrockman@yahoo.com>
    Re: Sorted Hash and or Array <marora@gmail.com>
    Re: Sorted Hash and or Array <bradbrockman@yahoo.com>
    Re: Sorted Hash and or Array charley@pulsenet.com
    Re: Sorting and Writing Effecient Code <uri@stemsystems.com>
    Re: submitting a form with no name attribute with mecha <nospam@home.com>
    Re: submitting a form with no name attribute with mecha <glex_no-spam@qwest-spam-no.invalid>
    Re: trying to use Games::Go::SGF <spam.meplease@ntlworld.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 3 Nov 2006 08:16:07 -0800
From: krakle@visto.com
Subject: Re: Calling Perl program from Java Script and populating the list boxes
Message-Id: <1162570567.599632.176800@f16g2000cwb.googlegroups.com>



On Nov 3, 8:59 am, xhos...@gmail.com wrote:
> "alwaysonnet" <kalyanrajsi...@gmail.com> wrote:
> > Hi all,
>
> > Question 1 - Is it possible to call a perl subroutine from Javascript ?Not directly, ordinarily.  Indirectly, sure.
>

One cheap way is to...

Create a Perl script outputting the JavaScript coding to write the HTML
coding for the list box. Name it blah.js. Then create an .htaccess file
setting .js scripts as executable Perl/CGI scripts. Then use <script
language="JavaScript" src="blah.js"></script> where ever you wish to
have the listbox display in your HTML document...



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

Date: Fri, 03 Nov 2006 19:41:51 +0100
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Calling Perl program from Java Script and populating the list boxes
Message-Id: <454b8d62$0$18851$9b4e6d93@newsspool4.arcor-online.net>

krakle@visto.com wrote:
> On Nov 3, 8:59 am, xhos...@gmail.com wrote:
>> "alwaysonnet" <kalyanrajsi...@gmail.com> wrote:
>>> Hi all,
>>> Question 1 - Is it possible to call a perl subroutine from Javascript
>> Not directly, ordinarily.  Indirectly, sure.
> 
> One cheap way is to...
> 
> Create a Perl script outputting the JavaScript coding to write the HTML
> coding for the list box. Name it blah.js. Then create an .htaccess file
> setting .js scripts as executable Perl/CGI scripts. Then use <script
> language="JavaScript" src="blah.js"></script> where ever you wish to
> have the listbox display in your HTML document...

There's absolutely no need to mess with file extensions on the
server side. Every halfway decent browser will take any extension
the server uses for its CGIs or applications, as long as the
returned Content-Type: header and the HTML attribution for the
script tag are correct.

-Chris


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

Date: Fri, 03 Nov 2006 18:25:13 +0000
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Getting huge data into memory in perl
Message-Id: <g69k62c75h2.fsf@lifelogs.com>

On  3 Nov 2006, rahul.thathoo@gmail.com wrote:

> I have a huge data set with me. Its like over 10000 files each with
> average 50KB of data. Assuming I have sufficient RAM, i need to be able
> to load all this into memory so that when i have to look for it I dont
> have to do an I/O. How do I go about this whole process in perl. 

Call with "program.pl FILE1 FILE2 FILE3"

This is hardly a good use of memory.  You probably want to optimize
this to index keywords, for instance.  Why do you need each file in
memory, are you searching them?

Ted


#!/usr/bin/perl

use warnings;
use strict;
use Data::Dumper;

my %files;
foreach my $file (@ARGV)
{
 open F, '<' . $file or warn "Couldn't open file $file: $!";
 $files{$file} = [(<F>)];
}

print Dumper \%files;


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

Date: Fri, 03 Nov 2006 18:04:16 +0100
From: "andreas" <andreas./@\.poipoi.de>
Subject: Re: killing processes using perl (artsd)
Message-Id: <b8b64$454b7690$5499a50a$20385@news2.eu.disputo.net>

Am Wed, 01 Nov 2006 23:57:14 +0100 schrieb Dr.Ruud:


> perllexwarn
> perlsub (look for "Private Variables" or "lexical")

i did the following: cat $(locate *.pod) | pod2text > perldocs.txt

this doc contanis 684 individual documents, 227818 lines of text and
10.745.665 characters - larger than twice the size of a bible! The
advantage is, one can grep anything out of a single doc. (for 'locate' one
needs the 'findutils' installed.)

thanks!

-andreas


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

Date: Fri, 03 Nov 2006 19:21:40 +0100
From: "andreas" <andreas./@\.poipoi.de>
Subject: Re: killing processes using perl (artsd)
Message-Id: <628df$454b88b4$5499a50a$20385@news2.eu.disputo.net>

Am Wed, 01 Nov 2006 13:35:16 -0600 schrieb Tad McClellan:

> andreas <andreas./@> wrote:
>> Am Wed, 01 Nov 2006 08:44:04 +0100 schrieb Dr.Ruud:
> 
>>> Remove the -w, and add:
>>> 
>>>   use warnings ;
>>>   use strict ;
>>
>> ok - I will look for that and try to figure out why?
> 
> 
> Short version:
> 
>    Because they catch many common programmer mistakes, such as typos.
> 
>

Yes, I'm aware of this, but preferred the shorter form -w simply because I
have to write less. In the meantime I read about the additional
features of using the pragmas 'use warnings', 'use strict' to give more
control about 'what' warning is active and where (scope) it is active. The
pragmas can be switched on an off in an individual block of code - the
command line -w applies to the whole script.

All this has to do with the perl version in use. The new pragmas seem to
start in perl 5.6. -w seems to be more compatible for older versions.
Now I hope at least 50% I have written is true ;-)

-andreas


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

Date: Fri, 3 Nov 2006 23:04:15 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Mailbox-style directory hashing
Message-Id: <slrneknf6v.l3s.hjp-usenet2@yoyo.hjp.at>

On 2006-11-02 18:41, s1037989@gmail.com <s1037989@gmail.com> wrote:
> Peter, thanks for your thoughtful reply!  :)  My response below...
>
> Peter J. Holzer wrote:
>> On 2006-10-31 23:40, s1037989@gmail.com <s1037989@gmail.com> wrote:
>> > I whipped up this quick and ugly script and I wanted to post it for
>> > code review and others' benefit.
>> >
>> > With an array such as:
>> > qw(aaaa aaab aaac bbbb bccc bcdd bcee bcff cccc dddd)
>> >
>> > The program returns:
>> > # perl list2fs.pl 2
>> > /a/aa/aaa/aaaa/aaaa
>> > /a/aa/aaa/aaab/aaab
[...]
>> > /c/cccc
>> > /d/dddd
>> >
>> > Now as you can see, what this program does is take a list of filenames
>> > and "hashifies" it like mailbox storing allowing no more than 2 (or
>> > whatever $ARGV[0] is) filenames to be in a single directory.  The
>> > point, obviously, is if you have 100000 filenames and ext3 won't store
>> > 100000 files in a single directory, you can use this technique to break
>> > them down.
>>
>> Ext3 will happily store 100000 filenames in a directory - it just won't
>> be very quick in retrieving them (Even that isn't true for Linux 2.6 any
>> more - ext3 directories now use a structure called an "htree" to quickly
>> access files in huge directories). But assuming you need to use ext3
>> with older kernel versions or other filesystems with linear directories:
>
> Ok, I didn't know that.  I thought I had read somewhere that the limit
> was 32,000 (and thus the reason for using something like reiserfs), but
> that was apparently an ancient article...  Oops!

AFAIK, there was never a limit on the number of files in an ext2/ext3
directory. 32 k may be the maximum number of subdirectories (because the
link count is 16 bit, and each ".." entry is a link). But you wouldn't
want more than a few 1000 files in a single directory because it was slow.


>> aaab aaac aaad aaae aaa
>>
>> You would need a directory /a/aa/aaa and a file /a/aa/aaa. But you can't
>> have both.
>
> Actually, in this case, aaa the file would go in aaa the directory.

Right. But my gut feeling that you don't handle that case correctly was
right. See below.


>> Do you have all the filenames in advance or is it possible to create new
>> files after the structure has been created? If it is the latter, you
>> proabably will need a way to split an existing directory if the number
>> of files in it becomes too large - what happens when somebody accesses
>> the directory in the middle of the split operation? How do you determine
>> when you have to split? Count files time you create a new file?
>
> I have the majority of the filenames in advance, but unfortunately the
> list will change.  To be more specific about what I'm doing: the URLs
> are blacklisted domains to be used with squid.

Are they URLs or domains? With URLs you may need to be careful because
of '/' and possibly other characters (especially if you access the
filesystem via Windows/Samba).


>> > Now, that said, this is NOT intended for "hashifying" mail storage
>> > dirs.  It IS intended to "hashify" a HUGE list of filenames.
>> > Unfortunately this code is VERY inefficient.
>>
>> How did you determine that is very inefficient?
>
> By running it... :)  It was AWFUL!  I ran it against a file containing
> nearly 600,000 entries.  I never waited long enough for it to finish.

That's probably because it doesn't finish at all if one of the strings
is a prefix of more than $ARGV[0] other strings. Change the
initialization to 

my @list = @_ = qw(aa aaaa aaab aaac bbbb bccc bcdd bcee bcff cccc dddd);

and try it. (It will probably crash pretty soon when it runs out of
memory, but if you had an infinite amount of memory it would run
forever)


>> > So, I post it here so people can see my idea if it helps, and so that
>> > people can maybe direct me to an existing CPAN module that would
>> > accomplish the same thing?
>>
>> When I needed to do similar things I used a hash function (e.g. MD5 or
>> SHA-1) on the key (the filename in your case) to get nice, uniformly
>> distributed constant length filenames and then computed the number of
>> levels from the maximum number of files I had to store. With 256 files
>> per directory, 2 levels would be enough for 16 million files and 3
>> levels would be enough for 4 billion files. I never needed more :-).
>
> This is good information, thanks.  I'll consider it's practical
> purposes, but would defeat the goal of simple blacklist updates via
> Samba.  :(

You want the directory structure to be created with the script anyway,
don't you? Or do you expect Windows users to create and delete
individual files to edit the blacklist?


>> > Or, perhaps someone likes what I've started and wants to help improve
>> > the code?
>>
>> If you avoid copying around huge lists it might be faster. But I'm not
>> sure the code even does what you want - see my questions above.
>
> How could I avoid that?

I was wrong. You are passing the lists by reference, and the hashes 
which you copy needlessly aren't that big (at most 70 elements, assuming
printable ASCII). The problem is that you are calling grep way too often
which also causes the endless recursion (and would be slow even without
that).

Here is my version of your function "a" (you have some talent for
choosing horrible names, btw. I could only figure out what the variables
were supposed to be by reading the code - the names were at best
useless and at worst misleading):

sub a {
	my ($prefix_len, $list) = @_;
	#print " " x $prefix_len, (scalar @$list), " elements\n";
        my %hash = ();
	push @{ $hash{lc(substr($_, 0, $prefix_len))} }, $_ for @$list;
        foreach my $sublist ( values %hash ) {
                if ( @$sublist > $ARGV[0] ) {
                        $sublist = a($prefix_len+1, $sublist);
                } else {
                        $sublist = { map { lc($_) => 1 } @$sublist };
                }
        }
        return \%hash;
}

The biggest change is that I didn't try to figure out the prefixes first
and then find all strings with the same prefix (which caused duplication
and the endless recursion) but do that in one loop - that way each
string can only ever be assigned to one prefix and the lists must get
shorter. The switching between array and hash references is mostly so
that a can be called with an array reference as before. I could have
uses hash references throughout. It also now returns a hash reference
instead of a list-which-is-a-hash, which I consider cleaner.

I didn't have a list of 600000 domain names handy, so I used two lists
with 35000 and 96000 names: The run times (with $ARGV[0] == 1000) were
about 3 and 9 seconds, respectively, on a PIII 850.

	hp

-- 
   _  | Peter J. Holzer    | > Wieso sollte man etwas erfinden was nicht
|_|_) | Sysadmin WSR       | > ist?
| |   | hjp@hjp.at         | Was sonst wäre der Sinn des Erfindens?
__/   | http://www.hjp.at/ |	-- P. Einstein u. V. Gringmuth in desd


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

Date: Fri, 03 Nov 2006 10:14:24 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Masking/Hiding a password in Perl Source
Message-Id: <454b6ad0$0$508$815e3792@news.qwest.net>

Robert Hicks wrote:
> As other have answered there really isn't "a" solution to this. I make
> myself feel better by using the unpack command in my script.
> 
> my $password = unpack "u", qq{&<&QE87-E};
> 
> Sure that isn't any better than any other solution but it isn't "plain"
> text either and that was all I was trying to solve. You could probably
> do some silly obfuscation on it too.

This really is a false sense of security.

If security really is an issue, at all, you should look at more secure 
transport solutions, such as SSH/SCP. and ensuring the machine is
as secure as possible.  Even that might not be enough, however spending
more time in those areas will be much more beneficial, compared to
trying to find different ways to avoid having a password in clear text,
in a script. IMHO.


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

Date: 3 Nov 2006 08:19:15 -0800
From: "Robert Hicks" <sigzero@gmail.com>
Subject: Re: Masking/Hiding a password in Perl Source
Message-Id: <1162570755.356334.187430@f16g2000cwb.googlegroups.com>

J. Gleixner wrote:
> Robert Hicks wrote:
> > As other have answered there really isn't "a" solution to this. I make
> > myself feel better by using the unpack command in my script.
> >
> > my $password = unpack "u", qq{&<&QE87-E};
> >
> > Sure that isn't any better than any other solution but it isn't "plain"
> > text either and that was all I was trying to solve. You could probably
> > do some silly obfuscation on it too.
>
> This really is a false sense of security.
>
> If security really is an issue, at all, you should look at more secure
> transport solutions, such as SSH/SCP. and ensuring the machine is
> as secure as possible.  Even that might not be enough, however spending
> more time in those areas will be much more beneficial, compared to
> trying to find different ways to avoid having a password in clear text,
> in a script. IMHO.

Yep, I thought that was clear in my post. It may be a false sense of
security but it is my false sense of security.  : )

Robert



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

Date: 3 Nov 2006 11:17:37 -0800
From: "banker123" <bradbrockman@yahoo.com>
Subject: Sorted Hash and or Array
Message-Id: <1162581457.842626.76160@m7g2000cwm.googlegroups.com>

I have three variables that are extracted and captured in my perl
program.  I currently write these variables to a report using the perl
format function which works great.  I would now like to sort this data
using a sort table.

Example:  (Read variables into an Array or Hash)
$box=123456                              $box=999999
$job=123456N                             $job=999999N
$file=110306_123456.bdf              $file=110306_999999.bdf

Sort Table (Array or Hash)
Box          Priority
999999     1
123456     2

Output
Sorted array or hash I presume, sorted using the priority column in the
sort table, like this:

999999 999999N 110306_999999.bdf   #Priority #1
123456 123456N 110306_123456.bdf   #Priority #2



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

Date: 3 Nov 2006 12:35:48 -0800
From: "Manish" <marora@gmail.com>
Subject: Re: Sorted Hash and or Array
Message-Id: <1162586148.584120.218100@h54g2000cwb.googlegroups.com>


banker123 wrote:
> I have three variables that are extracted and captured in my perl
> program.  I currently write these variables to a report using the perl
> format function which works great.  I would now like to sort this data
> using a sort table.
>
> Example:  (Read variables into an Array or Hash)
> $box=123456                              $box=999999
> $job=123456N                             $job=999999N
> $file=110306_123456.bdf              $file=110306_999999.bdf
>
> Sort Table (Array or Hash)
> Box          Priority
> 999999     1
> 123456     2
>
> Output
> Sorted array or hash I presume, sorted using the priority column in the
> sort table, like this:
>
> 999999 999999N 110306_999999.bdf   #Priority #1
> 123456 123456N 110306_123456.bdf   #Priority #2

and your question ... is ...



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

Date: 3 Nov 2006 12:45:13 -0800
From: "banker123" <bradbrockman@yahoo.com>
Subject: Re: Sorted Hash and or Array
Message-Id: <1162586713.504977.123970@m73g2000cwd.googlegroups.com>

> and your question ... is ...

How do I sort this data using the sort table as explained in the first
post.  Should I read the variables into an array or hash?  Help with
this is appreciated, I am still new to perl.



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

Date: 3 Nov 2006 13:58:52 -0800
From: charley@pulsenet.com
Subject: Re: Sorted Hash and or Array
Message-Id: <1162591132.228671.29190@i42g2000cwa.googlegroups.com>

banker123 wrote:
> I have three variables that are extracted and captured in my perl
> program.  I currently write these variables to a report using the perl
> format function which works great.  I would now like to sort this data
> using a sort table.
>
> Example:  (Read variables into an Array or Hash)
> $box=123456                              $box=999999
> $job=123456N                             $job=999999N
> $file=110306_123456.bdf              $file=110306_999999.bdf
>
> Sort Table (Array or Hash)
> Box          Priority
> 999999     1
> 123456     2
>
> Output
> Sorted array or hash I presume, sorted using the priority column in the
> sort table, like this:
>
> 999999 999999N 110306_999999.bdf   #Priority #1
> 123456 123456N 110306_123456.bdf   #Priority #2

The data structure you use could determine how you do your problem. The
hash I set up below could be one solution. (I haven't used formats, so
can't help you there)

Chris

#!/usr/bin/perl
use strict;
use warnings;

my %data = (123456 => { job => '123456N',
                        file => '110306_123456.bdf',
                        priority => 2
                      },
            999999 => { job => '999999N',
                        file => '110306_999999.bdf',
                        priority => 1
                       }
            );

for my $box (sort by_priority keys %data) {
    my @data = ($box, @{ $data{$box} }{qw/job file/});
    print "@data\n";
}

sub by_priority {
    $data{$a}{priority} <=> $data{$b}{priority};
}



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

Date: Fri, 03 Nov 2006 12:37:04 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Sorting and Writing Effecient Code
Message-Id: <x78xise8jj.fsf@mail.sysarch.com>

>>>>> "x" == xhoster  <xhoster@gmail.com> writes:

  x> wahab-mail@gmx.net wrote:
  >> Thus spoke Tad McClellan (on 2006-11-03 00:21):
  >> 
  >> >>  # file stuff
  >> >>  foreach my $fname (@files) {
  >> >>     open(my $fh, "$dir$fname") or die "$fname: $!";
  >> >>     ...
  >> >>     ...
  >> >>     close $fh;
  >> >>  }
  >> >>
  >> >> Don't forget to close your files, otherwise
  >> >> your program will fail sensational ...
  >> >
  >> >
  >> > How will it fail?
  >> > Perl closes any open filehandles when it exits anyway.
  >> 
  >> If you have several thousand file names in @files,
  >> the O.P.'s Windows OS should bark after the first
  >> hundred opened - but not closed ...

  x> lexical file handles are automatically closed when they go out of
  x> scope.

as well as localized globs used for handles (which was the best practice
coding before lexical handles came along. also i used Symbol::gensym to
make anon handles for me and those also closed upon exiting scope. so
the whole concept of closing files open automatically has been around in
perl for ages.

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, 03 Nov 2006 17:07:21 GMT
From: "Nospam" <nospam@home.com>
Subject: Re: submitting a form with no name attribute with mechanize
Message-Id: <dHK2h.3099$Ib.1800@newsfe1-gui.ntli.net>


"J. Gleixner" <glex_no-spam@qwest-spam-no.invalid> wrote in message
news:454b675a$0$10298$815e3792@news.qwest.net...
> Nospam wrote:
> > Is there a way to submit a form with no name attribute with mechanize,
when
> > the html is:
> >
> > <INPUT TYPE=submit VALUE="Submit your ad &gt;&gt; ">
> >           <input type="hidden" name="posting_id" value="">
> >    <input type="hidden" name="current_live_date" value="">
>
> Not only does that not have a name, it doesn't even have a form element.
>
> Check the documentation for WWW:Mechanize. See the "form_number"
> attribute for submit_form or the "form" method. If there are multiple
> forms on the page, you'll need to set the number appropriately.

<FORM METHOD="post" ACTION="/cgi-bin/report_posting.pl" name="report">
  <input type="hidden" name="site_id" value="15">
  <INPUT TYPE="hidden" NAME="title" VALUE="Example">
  <INPUT TYPE="hidden" NAME="category_name" VALUE="Wellington friends only">
  <input type="hidden" name="posting_id" value="">
  <input type="hidden" name="display_live_date" value="Thursday 2nd
November">
  <input type="hidden" name="posting_cat" value="323">
  <input type="hidden" name="search_terms" value="keyword">
  <input type="hidden" name="min_price" value="">

  <input type="hidden" name="max_price" value="">
  <input type="hidden" name="min_age" value="">
  <input type="hidden" name="max_age" value="">
  <input type="hidden" name="couple_filter" value="">
</FORM>


<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td align="center">
      <FORM METHOD="post" ACTION="/cgi-bin/add_posting.pl">

        <div align="right"><font face="Verdana, Arial, Helvetica,
sans-serif" size="-1">
          <INPUT TYPE="hidden" NAME="action" VALUE="edit">
          <input type="hidden" name="site_id" value="15">
          <INPUT TYPE="hidden" NAME="title" VALUE="Example">
          <INPUT TYPE="hidden" NAME="day" VALUE="">
          <INPUT TYPE="hidden" NAME="month" VALUE="">
          <INPUT TYPE="hidden" NAME="year" VALUE="">
          <INPUT TYPE="hidden" NAME="day_end" VALUE="">
    <INPUT TYPE="hidden" NAME="month_end" VALUE="">

          <INPUT TYPE="hidden" NAME="year_end" VALUE="">
          <INPUT TYPE="hidden" NAME="description" VALUE="Just checking">
          <INPUT TYPE="hidden" NAME="location" VALUE="Wellington">
          <INPUT TYPE="hidden" NAME="postcode" VALUE="">
          <INPUT TYPE="hidden" NAME="couples" VALUE="">
          <INPUT TYPE="hidden" NAME="price" VALUE="0">
          <INPUT TYPE="hidden" NAME="price_frequency" VALUE="">
          <INPUT TYPE="hidden" NAME="contact_email"
VALUE="example@example.com">
          <INPUT TYPE="hidden" NAME="other_contactable" VALUE="">

          <INPUT TYPE="hidden" NAME="skype_id" VALUE="">
          <INPUT TYPE="hidden" NAME="first_name" VALUE="me">
          <INPUT TYPE="hidden" NAME="last_name" VALUE="me">
          <INPUT TYPE="hidden" NAME="anti_spam" VALUE="Y">
          <INPUT TYPE="hidden" NAME="age" VALUE="">
          <INPUT TYPE="hidden" NAME="agency" VALUE="">
          <INPUT TYPE="hidden" NAME="anonymous_email" VALUE="Y">
          <INPUT TYPE="hidden" NAME="user_email"
VALUE="example@example.com">
          <INPUT TYPE="hidden" NAME="user_phone" VALUE="">

          <INPUT TYPE="hidden" NAME="password" VALUE="example">
          <input type="hidden" name="posting_id" value="">
          <INPUT TYPE="hidden" NAME="posting_cat" VALUE="323">
          <INPUT TYPE="hidden" NAME="premium_service" VALUE="">
          <INPUT TYPE="hidden" NAME="renewal_price" VALUE="">
          <INPUT TYPE="hidden" NAME="changedImages" VALUE="">
          <INPUT TYPE="hidden" NAME="pid" VALUE="30850">
          <input type="hidden" name="current_live_date" value="">

          <INPUT TYPE="submit" name="editagain" VALUE="<< Edit again">

          </font> </div>
      </FORM>
    </td>
    <td align="center">
      <FORM METHOD="post" ACTION="/cgi-bin/add_posting.pl">
        <div align="left"><font face="Verdana, Arial, Helvetica, sans-serif"
size="-1">
          <INPUT TYPE="hidden" NAME="action" VALUE="save">
          <input type="hidden" name="site_id" value="15">

          <INPUT TYPE="hidden" NAME="title" VALUE="Just checking">
          <INPUT TYPE="hidden" NAME="day" VALUE="">
          <INPUT TYPE="hidden" NAME="month" VALUE="">
          <INPUT TYPE="hidden" NAME="year" VALUE="">
          <INPUT TYPE="hidden" NAME="day_end" VALUE="">
    <INPUT TYPE="hidden" NAME="month_end" VALUE="">
          <INPUT TYPE="hidden" NAME="year_end" VALUE="">
          <INPUT TYPE="hidden" NAME="description" VALUE="Just checking">
          <INPUT TYPE="hidden" NAME="location" VALUE="Wellington">

          <INPUT TYPE="hidden" NAME="postcode" VALUE="">
          <INPUT TYPE="hidden" NAME="couples" VALUE="">
          <INPUT TYPE="hidden" NAME="price" VALUE="0">
          <INPUT TYPE="hidden" NAME="price_frequency" VALUE="">
          <INPUT TYPE="hidden" NAME="contact_email"
VALUE="example@example.com">
          <INPUT TYPE="hidden" NAME="other_contactable" VALUE="">
          <INPUT TYPE="hidden" NAME="skype_id" VALUE="">
          <INPUT TYPE="hidden" NAME="first_name" VALUE="Me">
          <INPUT TYPE="hidden" NAME="last_name" VALUE="Me">

          <INPUT TYPE="hidden" NAME="anti_spam" VALUE="Y">
          <INPUT TYPE="hidden" NAME="age" VALUE="">
          <INPUT TYPE="hidden" NAME="agency" VALUE="">
          <INPUT TYPE="hidden" NAME="anonymous_email" VALUE="Y">
          <INPUT TYPE="hidden" NAME="user_email"
VALUE="example@example.com">
          <INPUT TYPE="hidden" NAME="user_phone" VALUE="">
          <INPUT TYPE="hidden" NAME="password" VALUE="example">
          <INPUT TYPE="hidden" NAME="posting_cat" VALUE="323">
          <INPUT TYPE="hidden" NAME="premium_service" VALUE="">

          <INPUT TYPE="hidden" NAME="renewal_price" VALUE="">
          <INPUT TYPE="hidden" NAME="changedImages" VALUE="">
          <INPUT TYPE="hidden" NAME="pid" VALUE="30850">

          <INPUT TYPE=submit VALUE="Submit your ad &gt;&gt; ">
          <input type="hidden" name="posting_id" value="">
   <input type="hidden" name="current_live_date" value="">
          </font> </div>
      </FORM>



Above is the form data, there are three fields, trying
$mech->click_button( number => 1); goes to the first field which is just a
search query, trying $mech->click_button(number => 2); goes to the edit
contents, which is not what I am after, trying $mech->click_button(number =>
3); equally goes to the edit enquiry, I don't see a way of performing
$mech->click("nameofform"); or $mech->submit("nameofform"); btw
$mech->submit(); equally goes to the first form which is the search query,
which is not what I am after




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

Date: Fri, 03 Nov 2006 12:02:30 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: submitting a form with no name attribute with mechanize
Message-Id: <454b8426$0$500$815e3792@news.qwest.net>

Nospam wrote:
> "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid> wrote in message
> news:454b675a$0$10298$815e3792@news.qwest.net...
>> Nospam wrote:
>>> Is there a way to submit a form with no name attribute with mechanize,
> when
>>> the html is:
>>>
>>> <INPUT TYPE=submit VALUE="Submit your ad &gt;&gt; ">
>>>           <input type="hidden" name="posting_id" value="">
>>>    <input type="hidden" name="current_live_date" value="">
>> Not only does that not have a name, it doesn't even have a form element.
>>
>> Check the documentation for WWW:Mechanize. See the "form_number"
>> attribute for submit_form or the "form" method. If there are multiple
>> forms on the page, you'll need to set the number appropriately.
> 

FYI: You don't need to post every piece of HTML.. just the relevant parts.

In short, that'd be:

> <FORM METHOD="post" ACTION="/cgi-bin/report_posting.pl" name="report">
 ... no submit???
> </FORM>
> 
> 
>       <FORM METHOD="post" ACTION="/cgi-bin/add_posting.pl">
>           <INPUT TYPE="submit" name="editagain" VALUE="<< Edit again">
>       </FORM>

>       <FORM METHOD="post" ACTION="/cgi-bin/add_posting.pl">
>           <INPUT TYPE=submit VALUE="Submit your ad &gt;&gt; ">
>       </FORM>

Try using that for the value of the HTML, to make debugging easier.


> Above is the form data, there are three fields, trying
> $mech->click_button( number => 1); goes to the first field which is just a
> search query, trying $mech->click_button(number => 2); goes to the edit
> contents, which is not what I am after, trying $mech->click_button(number =>
> 3); equally goes to the edit enquiry, 

Hu.. I though I pointed out form and form_number already..

>I don't see a way of performing
> $mech->click("nameofform"); or $mech->submit("nameofform"); 

Of course not, because, as you said, they don't have a name.

 >btw
> $mech->submit(); equally goes to the first form which is the search query,
> which is not what I am after

The documentation to the rescue..


" $mech->click_button( ... )


* number => n
            Clicks the nth button in the current form. Numbering starts 
at 1.
"

"Current form" being the important part.


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

Date: 3 Nov 2006 10:57:33 -0800
From: "doolittle" <spam.meplease@ntlworld.com>
Subject: Re: trying to use Games::Go::SGF
Message-Id: <1162580253.445342.215660@h48g2000cwc.googlegroups.com>

The following code shows a workaround. Does anybody know how to change
the Games::Go::SGF module so this is unneccessary?

use Games::Go::SGF;

my $sgf = new Games::Go::SGF('(;GM[1]FF[4]SZ[19];B[pd](;W[cf]))');

my $move_no = 1;
while (my $walker = $sgf->move($move_no++)) {
if (ref($walker) eq 'Games::Go::SGF::Variation'){
my $var = $walker->variation(0);
#uncomment the next line to show unexpected behaviour (bug?)
# print $var->move,"\n";
print ref($var),"\n"; # this is an ARRAY
my @deref = @{$var};
print ref($deref[0]),"\n";
print 'var move '."$move_no: ".$deref[0]->move,"\n";
}
}

prints out:

ARRAY
Games::Go::SGF::Node
var move 3: cf

A similar problem happens with the 'variations' method,which returns an
array of arrays rather than the expected array of Nodes.



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

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


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