[30032] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1275 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 13 16:09:49 2008

Date: Wed, 13 Feb 2008 13:09:13 -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           Wed, 13 Feb 2008     Volume: 11 Number: 1275

Today's topics:
        $browser->get($module_form); <gshine@netlink.info>
    Re: Advice about cgi programming <jimsgibson@gmail.com>
        ANNOUNCE: Win32::GUI V1.06 <remay.uk@googlemail.com>
    Re: DBI:mysql how to do multiple inserts/modification? <abigail@abigail.be>
    Re: DBI:mysql how to do multiple inserts/modification? <tch@nospam.syneticon.net>
    Re: Help: Display the specific line in a file <ben@morrow.me.uk>
    Re: Help: Display the specific line in a file <achimpeters@gmx.de>
    Re: Inverted RegEx on list of numbers <damian@tvk.rwth-aachen.de>
    Re: Inverted RegEx on list of numbers <damian@tvk.rwth-aachen.de>
    Re: Inverted RegEx on list of numbers <groups@stephan-mann.de>
        Problems with STDIN and POST data <sergio@warptv.com>
    Re: Problems with STDIN and POST data xhoster@gmail.com
    Re: Problems with STDIN and POST data <sergio@warptv.com>
    Re: Regex /(X*)/ <jl_post@hotmail.com>
    Re: Regex /(X*)/ xhoster@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Feb 2008 16:02:42 -0500
From: "Gary" <gshine@netlink.info>
Subject: $browser->get($module_form);
Message-Id: <IVIsj.1282$f8.720@newsfe23.lga>

Trying to understand what the -> does please.

Cannot find it in the perl docs etc.
Gary 




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

Date: Wed, 13 Feb 2008 10:02:19 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Advice about cgi programming
Message-Id: <130220081002196935%jimsgibson@gmail.com>

In article
<e748a974-5f40-44ee-b1c3-355b98dd299d@i7g2000prf.googlegroups.com>,
newbiegalore <banerjee.anirban@gmail.com> wrote:

> Hello everyone :-) ,
>                              I am a newbie to Perl, but have
> experience with other scripting languages. I am putting up this post
> to ask for advice regarding what skills I would need to get a task
> done. This might not be the most appropriate group, but since Perl is
> used a lot for server back-end scripts, I guess a lot of people have
> experience with using it for building web applications.
> 
> My task: I have bought a domain and now want to set up a website on
> it.
> 
> What will the site do: Accept a string from the user, like Google does
> (A very simple design). Then the site will check this string for the
> presence of a substring. The output will be displayed in a simple text
> box on the main page (to begin with).
> 
> If I have a script that will do this operation, I need to link the
> input string to this script in the background and return the result.
> Is CGI programming used to make this "glue" ? I could ask someone to
> access the script directly on my site like
> 
> http://www.mysite.com/myscript<params> .. but I want to separate the
> interface from my programs. Any advice would be greatly appreciated. I
> know how to code in C, C++,Awk, Bash and some more languages. Sorry if
> my questions seems overly naive :D.

Perl is an excellent choice for writing CGI programs. You can't do the
newer "Web 2.0" with CGI, but you can still do a lot. Even if you are
planning to do the fancy stuff later, it is good to have a good
grounding in CGI.

Consider using the Perl CGI module. It has lots of methods for
generating HTML and also for handling form data. It also has two
different types of interfaces: function calls and object-oriented
methods.

Do 'perldoc CGI' at a command-line prompt to read the documentation on
CGI. It should be installed with most Perls. If not, you can get it
from CPAN <http://www.cpan.org>

My recommendation is to use the object-oriented methods of CGI instead
of the functions. It provides a cleaner interface and is a good
introduction to OO in Perl. For generating HTML, I usually use plain
old print statements rather than the CGI routines, and check out "here"
documents. If you want to generate complex HTML pages, consider using a
templating system (there are several on CPAN) or a content-management
system.

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Wed, 13 Feb 2008 17:31:15 GMT
From: Robert May <remay.uk@googlemail.com>
Subject: ANNOUNCE: Win32::GUI V1.06
Message-Id: <Jw6v28.xL5@zorch.sf-bay.org>

I am please to announce that v1.06 of Win32::GUI is available for
download from SourceForge and CPAN.

Win32::GUI is a Perl extension allowing creation of native Win32 GUI
applications.

MORE INFORMATION

  Project Homepage:
  http://perl-win32-gui.sourceforge.net/

  Project summary:
  http://sourceforge.net/projects/perl-win32-gui/

  Downloads:
  - Source and ActiveState Perl PPM distributions:
    http://sourceforge.net/project/showfiles.php?group_id=16572
  - Source only:
    http://search.cpan.org/~robertmay/Win32-GUI-1.06/

  Release notes:
  https://sourceforge.net/project/shownotes.php?release_id=576262

RELEASE NOTES AND CHANGES

NAME
    Win32::GUI::ReleaseNotes::RN_1_06 - release notes for v1.06 of
    Win32::GUI

Release Date
    13th February, 2008.

Summary of Changes
    This is a summary of changes between V1.05 and V1.06 See the
CHANGELOG
    file in the distribution for the full detail.

    This release is a primarily a bug-fix release addressing the
issues
    below. There are a small number of new features. Minor changes
have been
    made to enable correct building with the new perl 5.10.0

    Please note that this is intended to be the last release that is
    compatible with the Perl 5.6 series.

  New Features
    More constants
        Win32::GUI::Constants now has over 2000 constants. Please keep
        reporting any that you need that are missing.

    Win32::GUI::DC::DrawFrameControl can DFCS_ADJUSTRECT
        DrawFrameControl() will now adjust it's input parameters if
the
        DFCS_ADJUSTRECT flag is set and the input parameters are not
        readonly.

    Dialog navigation for MDI Windows
        Salvadore Oritz submitted a patch to allow 'TAB' navigation
between
        controls of an MDI child window. The '-dialogui' is now
functional
        on MDI child windows.

    Confusion with GetParent() and TreeView windows
        The GetParent() method usually gets the parent window, but for
the
        Treeview class it gets the parent node:

          $parent_node = $tree_view->GetParent($node);

        This made it difficult to get the parent window. Now, if the
        GetParent() method is called without an arguements it returns
the
        parent window:

          $parent_window = $tree_view->GetParent();

  Bug Fixes
    Balloon Tooltip info and warning icons swapped
        The info and warning icon for balloon tooltips were the wrong
way
        round. This is fixed. (Tracker: 1709017)

    Textfield::GetLine() truncates lines
        Textfield::GetLine() has been re-written to stop it truncating
        lines, and to correctly return empty lines.

    '-prompt' option to Textfield
        The '-prompt' option to the Textfield constructor would
generate
        warnings and place the label incorrectly when used to supply a
label
        only:

          -prompt => 'Some Label:',

        This should now be fixed. Note that if you were relying on the
        previouly incorrect placement (always against the left
border), then
        you may need to re-position your labels. (Tracker: 1734697)

    Warning During Global Destruction
        It was common to get a warning like:

          (in cleanup) Can't call method "DELETE" on an undefined
value at C:/Perl
          /site/lib/Win32/GUI.pm line 3451 during global destruction.

        This is now, hopefully, fixed. Please report if you still see
errors
        like this.

    Memory leaks
        Various memory leaks have been resolved.

    Win32::GUI::Scintilla buffer sizes
        There were several places in the Scintilla wrapper code where
        buffers of the wrong sizes were allocated. This has been
fixed.

    Win32::GUI::Scroll return value
        On failure Win32::GUI::Scroll was supposed to return undef,
but was
        returning random garbage. This has been fixed, along with
updates to
        the documentation.

    Win32::GUI::RichEdit::LimitText()
        There was a typo in the function name (LimiteText()). Both
spellings
        are now supported.

    ListView BeginLabelEdit event
        The second argument was being set incorrectly when the
callback was
        made. This is now fixed. (Tracker: 1706901)

    ListView SelectedItems may now return an empty list
        Win32::GUI::ListView::SelectedItems used to return "undef"
when
        there were no items selected. It now returns an empty list, to
        better support things like:

          for my $item ($listview->SelectedItems()) {
            # do something with the selected $item
          }

    TreeView::GetItem may now return an empty list
        Win32::GUI::TreeView::GetItem (and
Win32::GUI::TreeView::ItemInfo)
        used to return "undef" when asked about a non-existing item.
In now
        returns an empty list to better support things like:

          my %node_info = $treeview->GetItem($item);

    Crash when destroying a window during a callback
        It is possible to write code that destroys a window during one
of
        it's one callbacks. This could crash perl. Hopefully this is
now
        fixed.

    All Win32::GUI::DC::Poly* drawing functions broken
        Polygon(), PolyBezier(), PolyBezierTo(), PolyLine() and
PolyLineTo()
        now all work.

    Comboxbox constructor - using multiple types
        The Win32::GUI::Combobox constructor has been updated to
handle the
        '-simple', '-dropdown' and '-dropdownlist' options more
intuatively.
        The docuentation has been updated to explain that only one of
these
        options should be used, and what happens if more than one is
used.

    Win32::GUI::Imagelist::AddMasked broken
        This call should now work. (Tracker: 1734697)

    Win32::GUI::Acceptfiles() generates warning
        The AcceptFiles() method was using some undefined constants.
They
        have been removed.

    Build process fixes
        A number of warnings when building under cygwin were fixed -
patches
        submitted by Reini Urban.

    Win32::GUI::BitmapInline wasn't using a suitable temporary
directory
        Win32::GUI::BitmapInline was always using the current
directory to
        create temporary files. This failed when the current directory
        wasn't writable (likely under limited user accounts in Win2K
and
        above). It now uses "File::Spec->tmpdir()" to get a writable
        temporary directory. (Tracker: 1586643)

        Further, the filename chosen wasn't thread-safe. This
(unlikely)
        race-condition should also be fixed.

    Toolbar Addbitmap can't be called multiple times
        The Win32::GUI::Toolbar::AddBitmap() method failed when called
a
        second time, reporting that you couldn't use it when an
imagelist
        was already assigned (regardless of whether you had assigned
an
        imagelist or not). It may now be called more than once to add
        individual bitmaps to the toolbar.

Deprecated feature status
    This section documents features that have been deprecated in this
    release, or in recent releases, and feature that will be
deprecated in
    up-coming releases.

  Win32::GUI::Constants
    The introduction of Win32::GUI::Constants in v1.04 means that we
now
    have access to a very large number of constants, so the v1.03
behaviour
    of Win32::GUI to export all constants to the calling namespace by
    default is no longer appropriate. So, a bare

      use Win32::GUI;

    now generates a warning that the old default behaviour will be
    deprecated - although the export behaviour of Win32::GUI v1.03 is
    maintained except for this warning.

    To eliminate this warning and correct your script, do one of the
    following:

    If you don't need any constants, use the empty list:
          use Win32::GUI();

    If you need some constants, name them explicitly:
          use Win32::GUI qw(ES_WANTRETURN CW_USEDEFAULT); # Two
constants exported
          use Win32::GUI qw(/^MB_/);   # Export all constants starting
with MB_

    See the Win32::GUI::Constants documentation for the full allowable
    syntax.

    You are advised to fix your scripts now, as a future version will
stop
    exporting any constants by default.

    Although not advised, you can suppress the warnings by turning
    deprecated warnings off:

      no warnings 'deprecated';

    Additionally accessing constants from within the Win32::GUI
namespace is
    deprecated. I.e.

       -addstyle => Win32::GUI::WS_BORDER,

    will generate a warning with this release, and will stop working
with a
    future release. Use one of the following methods instead:

    use the Win32::GUI::Constants namespace instead
          -addstyle => Win32::GUI::Constants::WS_BORDER,

    use any other namespace you fancy
          use Win32::GUI qw(-exportpkg => A::B -autoload);
          ...
          -addstyle => A::B::WS_BORDER,

    maintain compatibility of existing scripts
          use Win32::GUI::Constants qw(-exportpkg =>
Win32::GUI :compatibility_win32_gui);
          ...
          -addstyle => Win32::GUI::WS_BORDER,

  Win32::GUI::NotifyIcon
    It is no longer necessary to use the '-id' option to any of the
    Win32::GUI::NotifyIcon methods. The ID is now entirely handled
    internally. You will receive deprecated warnings if you use it.

    In particular, removing Icons from the system tray should be done
using

      $NI->Remove();

    and not by the (now deprecated)

      $NI->Delete(-id => 1);

    Use of the "-id" option will generate a warning.

Contributors to this release
    Robert May
    Brian Millham
    Glenn Munroe
    George
    Glenn Linderman
    Salvadore Oritz
    Joseph Cordero
    Reini Urban
    Jeremy White




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

Date: 13 Feb 2008 16:10:00 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: DBI:mysql how to do multiple inserts/modification?
Message-Id: <slrnfr65io.t9a.abigail@alexandra.abigail.be>

                                           _
John Bokma (john@castleamber.com) wrote on VCCLXXIX September MCMXCIII in
<URL:news:Xns9A43645D0B6D9castleamber@130.133.1.4>:
^^  Tomasz Chmielewski <tch@nospam.syneticon.net> wrote:
^^  
^^ > How can I do multiple database modifications without writing too much
^^ > code? 
^^ > 
^^ > For a single modification, I would write:
^^ > 
^^ > $SQL = "INSERT INTO aaaaa..";
^^ > $db->do($SQL);
^^ > 
^^ > How can I do it without repeating "$db->do($SQL);" each time?
^^  
^^  prepare the statement, and in a loop do $sth->execute( values )


Can you do that if you're inserting into different tables, which
is what the OP's example seems to imply?


Abigail
-- 
   my $qr =  qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
      $qr =~  s/$qr//g;
print $qr, "\n";


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

Date: Wed, 13 Feb 2008 21:08:00 +0100
From: Tomasz Chmielewski <tch@nospam.syneticon.net>
Subject: Re: DBI:mysql how to do multiple inserts/modification?
Message-Id: <fovin0$orb$1@online.de>

Paul Lalli schrieb:
> On Feb 13, 9:03 am, Tomasz Chmielewski <t...@nospam.syneticon.net>
> wrote:
>> How can I do multiple database modifications without writing too much code?
>>
>> For a single modification, I would write:
>>
>> $SQL = "INSERT INTO aaaaa..";
>> $db->do($SQL);
>>
>> How can I do it without repeating "$db->do($SQL);" each time?
>>
>> Something like this throws an error, so obviously I must be missing
>> something.
>>
>> $SQL = "INSERT INTO aaaaa... ;
>>         INSERT INTO bbbbb... ;
>>         INSERT INTO bbbbb... ;";
>> $db->do($SQL);
> 
> uh.  How about...
> 
> for my $stmt (split /;\n/, $SQL) {
>   $db->do($stmt);
> }

Ah, that simple.
Thanks a lot.


-- 
Tomasz Chmielewski
http://wpkg.org


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

Date: Wed, 13 Feb 2008 16:23:04 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Help: Display the specific line in a file
Message-Id: <84ib85-ukf2.ln1@osiris.mauzo.dyndns.org>


Quoth Achim Peters <achimpeters@gmx.de>:
> 
> How about

Where is

    use strict;
    use warnings;

> $good_book = "Learning Perl";

    my $good_book = ...;

> $preferred_beverage = "Cup o'Tea";
>    # don't wanna recommend Cup o'Java here ...
> 
> open BOOK "<" $good_book or die $!;

You're missing a comma after "<".
You should use lexical filehandles.
You should say what you were trying to open.

    open my $BOOK, '<', $good_book
        or die "can't open '$good_book': $!";

> while (<BOOK>) {

Would you really read a book line-by-line? I would expect to leave at
least a paragraph between sips, so we need

    local $/ = '';

before the while loop.

>   read;

Not enough arguments for read...

You probably want to choose a different sub name.

>   sip($preferred_beverage);
> }

:)

Ben



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

Date: Wed, 13 Feb 2008 17:59:13 +0100
From: Achim Peters <achimpeters@gmx.de>
Subject: Re: Help: Display the specific line in a file
Message-Id: <47B321E1.3010106@gmx.de>

Ben Morrow schrieb:
> Quoth Achim Peters <achimpeters@gmx.de>:
>> How about
> 
> Where is
> 
>     use strict;
>     use warnings;

Who said it was supposed to be perl?

> :)

:-)~

Bye
 Achim


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

Date: Wed, 13 Feb 2008 17:11:23 +0100
From: Damian Lukowski <damian@tvk.rwth-aachen.de>
Subject: Re: Inverted RegEx on list of numbers
Message-Id: <61gj5cF1v9g1pU1@mid.dfncis.de>

Stephan Mann schrieb:
> After yet another hour of reading it became clear to me that there is no
> way to write RegEx like "Match anything but this string" other than with
> look-ahead/-behind.

In case it is an "academic" regular expression (as defined in computer 
science) with no backreferences and zero-width assertions, there is 
always another regex which matches exactly the opposite, as there is an 
algorithm for giving you the complementary regex. If I'm not mistaken 
the complementary regex to /two/ is something like 
/^(?:[^t]|t+[^tw]|(?:t+w)+([^to]|t+[^tw]))*(?:t+w)+o/.

Damian


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

Date: Wed, 13 Feb 2008 17:18:36 +0100
From: Damian Lukowski <damian@tvk.rwth-aachen.de>
Subject: Re: Inverted RegEx on list of numbers
Message-Id: <61gjiuF1vl8a9U1@mid.dfncis.de>

Damian Lukowski schrieb:
> If I'm not mistaken 
> the complementary regex to /two/ is something like 
> /^(?:[^t]|t+[^tw]|(?:t+w)+([^to]|t+[^tw]))*(?:t+w)+o/.
> 
> Damian

Well, I am mistaken here, as I forgot an important step. :)
I won't correct it, because it will be more complicated as it is already. :)


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

Date: Wed, 13 Feb 2008 17:30:40 +0100 (CET)
From: Stephan Mann <groups@stephan-mann.de>
Subject: Re: Inverted RegEx on list of numbers
Message-Id: <fov5vg$q0t$1@aioe.org>

On 2008-02-13, Damian Lukowski wrote:
> Stephan Mann schrieb:
>> After yet another hour of reading it became clear to me that there is no
>> way to write RegEx like "Match anything but this string" other than with
>> look-ahead/-behind.
>
> In case it is an "academic" regular expression (as defined in computer 
> science) with no backreferences and zero-width assertions, there is 
> always another regex which matches exactly the opposite, as there is an 
> algorithm for giving you the complementary regex. If I'm not mistaken 
> the complementary regex to /two/ is something like 
> /^(?:[^t]|t+[^tw]|(?:t+w)+([^to]|t+[^tw]))*(?:t+w)+o/.

Let me rephrase that: There is no way to write _a readable_ RegEx... ;-)

Actually, I thought about this (although I would have failed writing it
down) but this simply isn't applicable for strings longer than five
characters and also doesn't work if your search string is variable. 

Thankfully, my problem was very "practical" :-)

thanks again for your efforts, 
stephan


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

Date: Wed, 13 Feb 2008 11:00:59 -0800 (PST)
From: SergioQ <sergio@warptv.com>
Subject: Problems with STDIN and POST data
Message-Id: <19784205-5318-4ab0-a972-f0218869e2f6@l32g2000hse.googlegroups.com>

Hello all,

Am having some very serious problems reading the POST data that is
being sent to my Perl script.  The full code (minus my email address
is below).  And essentially what I am getting back via email reports
is that that there is data being sent via POST, and tht it has a
length of 1431.   Yet all my attempts to read it are failing
miserably.   If anyone can help me out, I would soooo appreciate it.

Thank you so much.

Here is the FULL CODE:

#!/usr/bin/perl

use strict;
use MainMod;
use HTTP::Request;
use LWP::UserAgent;
use CGI qw(:standard);

my $out_msg = "";
my %variable;
my $serg_bffr;

read STDIN, $serg_bffr, $ENV{'CONTENT_LENGTH'};

my $sendmail = "/usr/sbin/sendmail -t";
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";

print SENDMAIL ---my email address goes here---
print SENDMAIL ---my email address goes here---
print SENDMAIL "Subject: IPN Stuff\n";
print SENDMAIL "\n";
print SENDMAIL "$ENV{REQUEST_METHOD}\n";
print SENDMAIL "$ENV{'CONTENT_LENGTH'}\n";
print SENDMAIL length($serg_bffr) . "\n";
print SENDMAIL "$serg_bffr\n";

close(SENDMAIL);

PrintItOut("done");
exit (0);


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

Date: 13 Feb 2008 19:36:26 GMT
From: xhoster@gmail.com
Subject: Re: Problems with STDIN and POST data
Message-Id: <20080213143628.187$4V@newsreader.com>

SergioQ <sergio@warptv.com> wrote:
> Hello all,
>
> Am having some very serious problems reading the POST data that is
> being sent to my Perl script.  The full code (minus my email address
> is below).  And essentially what I am getting back via email reports
> is that that there is data being sent via POST, and tht it has a
> length of 1431.   Yet all my attempts to read it are failing
> miserably.

"Failing miserably" is about as bad as "doesn't work".  What actually
happens?

Does your hard drive reformat itself and then your cpu set itself on fire?

> Here is the FULL CODE:
>
> #!/usr/bin/perl
>
> use strict;
> use MainMod;
> use HTTP::Request;
> use LWP::UserAgent;
> use CGI qw(:standard);

Since you are using it, why not use CGI to read from STDIN for you?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Wed, 13 Feb 2008 12:25:25 -0800 (PST)
From: SergioQ <sergio@warptv.com>
Subject: Re: Problems with STDIN and POST data
Message-Id: <8017bc25-af08-445f-8c5e-bed7e8f77195@s19g2000prg.googlegroups.com>

On Feb 13, 2:36=A0pm, xhos...@gmail.com wrote:

> "Failing miserably" is about as bad as "doesn't work". =A0What actually
> happens?
I see that there is PPOST data, and it has length, but what I read
back is nothing.



> Since you are using it, why not use CGI to read from STDIN for you?


This is a Perl script for Paypal's IPN.  Below is their sample
script.   And you'll see there's a section "# post back to PayPal
system to validate"  and since I don't know what's coming in, and in
what format, how can I tack it on and send it back?


THIS IS FROM PAYPAL
#!/usr/bin/perl

# read post from PayPal system and add 'cmd'
read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
$query .=3D '&cmd=3D_notify-validate';

# post back to PayPal system to validate
use LWP::UserAgent;
$ua =3D new LWP::UserAgent;
$req =3D new HTTP::Request 'POST','http://www.paypal.com/cgi-bin/
webscr';
# note: if you have SSL encryption Enabled, use <https://
www.paypal.com/cgi-bin/webscr> above
$req->content_type('application/x-www-form-urlencoded');
$req->content($query);
$res =3D $ua->request($req);

# split posted variables into pairs
@pairs =3D split(/&/, $query);
$count =3D 0;
foreach $pair (@pairs) {
($name, $value) =3D split(/=3D/, $pair);
$value =3D~ tr/+/ /;
$value =3D~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$variable{$name} =3D $value;
$count++;
}

# assign posted variables to local variables
# note: additional IPN variables also available -- see IPN
documentation
$item_name =3D $variable{'item_name'};
$receiver_email =3D $variable{'receiver_email'};
$item_number =3D $variable{'item_number'};
$invoice =3D $variable{'invoice'};
$a =3D $variable{'custom'};
$payment_status =3D $variable{'payment_status'};
$payment_gross =3D $variable{'payment_gross'};
$txn_id =3D $variable{'txn_id'};
$payer_email =3D $variable{'payer_email'};
$amount =3D $variable{'amount'};
$on0 =3D $variable{'option_name1'};
$os0 =3D $variable{'option_selection1'};
$status =3D $res->content;
$note =3D $variable{'memo'};


if ($res->is_error) {
# HTTP error
}
elsif ($res->content eq 'VERIFIED') {
# check the payment_status=3DCompleted
# check that txn_id has not been previously processed
# check that receiver_email is an email address in your PayPal account
# process payment
# print to screen the following if the IPN POST was VERIFIED


print "content-type: text/plain\n\nOK\n";
print "<html><head><title>IPN Screendump</title></head>\n";
print "<body>your email address is <b>$payer_email</b>\n";
print "<br>you paid <b>$payment_gross</b>\n";
print "<br>you paid for <b>$item_number</b>\n";
print "<br>the color of your order was <b>$os0</b>\n";
print "<br>the value of custom was <b>$a</b>\n";
print "<br>the status was<b>$status</b>\n";
print "<br>the note said <b>$note</b>\n";
print "<br>the transaction id was <b>$txn_id</b>\n";
print "<br>the payment status was<b>$payment_status</b>\n";
print "</body></html>\n";


}
elsif ($res->content eq 'INVALID') {
# log for manual investigation
# print to screen the following if the IPN POST was INVALID

print "content-type: text/plain\n\nOK\n";

print "<html><head><title>IPN Screendump</title></head>\n";
print "<br>the status was<b>$status</b>\n";
print "</body></html>\n";


}
else {
# error
}




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

Date: Wed, 13 Feb 2008 09:39:16 -0800 (PST)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: Regex /(X*)/
Message-Id: <3d4c6153-33a6-4289-bc7d-1134d2d6cfac@e6g2000prf.googlegroups.com>

On Feb 13, 1:25 am, ulrich_mar...@seznam.cz wrote:
>
> I would like to ask you for help. Could anybody explain me, why regex
> "/(X*)/" is not able to catch X in string "aXXXb". Quantifier "*" in
> this regex is a greedy one and there is not anchor "^", so I would
> expect, that $1 would contain XXX. I know (I have read it), that it is
> possible to use + instead of *, but I would like to know, why the "*"
> quantifier doesn't catch it.
>
> I have found this example in perlretut:
> Finally,
> "aXXXb" =~ /(X*)/; # matches with $1 = ''
> because it can match zero copies of 'X' at the beginning of
> the string.  If you definitely want to match at least one
> 'X', use "X+", not "X*".


   Basically, a lot of people mistakenly think that the greedy '*'
quantifier makes m/(X*)/ match the LONGEST string of Xs.  But in
reality, m/(X*)/ matches AS SOON AS POSSIBLE, and '*' just makes (X*)
gobble as much as it can once a match is found.

   I believe it was the "Learning Perl" (the "llama" book) that said
that if a regular expression can match an empty string, then it will
always return true no matter what string it is given.  And the regular
expression m/(X*)/ does return true when used with an empty string, as
'' has zero-or-more instances of 'X' inside it.  Therefore, even this
match succeeds:

   "ab" =~ /(X*)/;  # $1 gets set to ''

It succeeds because it found zero-or-more Xs at the very beginning of
the string.  Likewise, the match:

   "aXXXb" =~ /(X*)/;  # $1 gets set to ''

also succeeds by finding zero-or-more Xs at the very beginning of the
string.  It stops searching after that because it found a match, and
has no need to continue any further.

   If you really wanted a regular expression that would match at least
one X, then you should use the '+' quantifier instead of '*', like
this:

   "aXXXb" =~ /(X+)/;  # $1 gets set to 'XXX'

but since it still matches as soon as possible, it wouldn't match a
longer string of Xs, as shown here:

   "aXXXbXXXXXc" =~ /(X+)/;  # $1 still gets set to 'XXX'

If you wanted to match the longest string of Xs, you'd have to loop
through all the strings of Xs and record the longest one.  You can do
this with the /g modifier like this:

   my $longestString = '';
   while ( "aXXXbXXXXXcXd" =~ m/(X+)/g )
   {
      $longestString = $1  if length($1) > length($longestString);
   }
   print "$longestString\n";  # prints 'XXXXX'

   So remember, it is a mistake to think that the '*' and '+'
quantifiers match the longest instance of a string; they just match as
much as they can (or "gobble" up as much as they can) once a match has
been found -- even if the match was found at the very beginning of the
string.

   This means that if a regular expression can match an empty string,
then the '*' quantifier will probably match an empty string unless
what it's quantifying happens to be at the beginning of the string.

   I hope this explanation helps.

   -- Jean-Luc


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

Date: 13 Feb 2008 19:14:44 GMT
From: xhoster@gmail.com
Subject: Re: Regex /(X*)/
Message-Id: <20080213141446.525$I6@newsreader.com>

ulrich_martin@seznam.cz wrote:
> Hello,
>
> I would like to ask you for help. Could anybody explain me, why regex
> "/(X*)/" is not able to catch X in string "aXXXb". Quantifier "*" in
> this regex is a greedy one and there is not anchor "^", so I would
> expect, that $1 would contain XXX.

"Greedy" is a term of art in computer science.  It does not have exactly
the same meaning as it does in religion or ethics or Marxism.  Alas,
even the term of art isn't all that unambiguous in this context, either, as
there is no objective way of knowing what "locally optimal" means in the
regex context.  Fortunately the documentation doesn't rely on you knowing
exactly what it means by greedy, it goes on to explain what the behavior
actually is.  So don't get hung on loaded words.  I think the docs should
remove that reference and just stick to describing the behavior explicitly.

> I know (I have read it), that it is
> possible to use + instead of *, but I would like to know, why the "*"
> quantifier doesn't catch it.

Because it doesn't look ahead to see what better thing in the future might
happen, it makes local decisions.  That is what greedy means in the term
of art, but in this case it is applying not to the "*" but to the scanning.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

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 V11 Issue 1275
***************************************


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