[28820] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 64 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 23 00:05:51 2007

Date: Mon, 22 Jan 2007 21:05:06 -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, 22 Jan 2007     Volume: 11 Number: 64

Today's topics:
    Re: Could someone help me with this source code? <tadmc@augustmail.com>
        forum perl <john.swilting@wanadoo.fr>
    Re: How to decode javascript encodeURI / encodeURICompo <tadmc@augustmail.com>
        How to decode JavaScript's encodeURIComponent in Perl. <Cloink_Friggson@ntlworld.com>
    Re: How to decode JavaScript's encodeURIComponent in Pe <john@castleamber.com>
    Re: How to decode JavaScript's encodeURIComponent/encod <Cloink_Friggson@ntlworld.com>
    Re: How to decode JavaScript's encodeURIComponent/encod <john@castleamber.com>
    Re: MAC Address Comparison <bik.mido@tiscalinet.it>
    Re: MAC Address Comparison <spamtrap@dot-app.org>
    Re: MAC Address Comparison <bik.mido@tiscalinet.it>
    Re: MAC Address Comparison rkb@i.frys.com
    Re: MAC Address Comparison <john@castleamber.com>
    Re: MAC Address Comparison <jgibson@mail.arc.nasa.gov>
    Re: multiline pattern matching from file <tadmc@augustmail.com>
    Re: Net::FTP::Recursive hangs <vilas_santafe@yahoo.com>
    Re: No backtick shell return value <dbasch@yahoo.com>
    Re: Pattern Matching and Extraction <doni.sekar@gmail.com>
    Re: Pattern Matching and Extraction <purlgurl@purlgurl.net>
    Re: Pattern Matching and Extraction <john@castleamber.com>
    Re: Pattern Matching and Extraction <tadmc@augustmail.com>
    Re: Perl CGI or Something Else CGI? <BLOCKSPAMfishfry@your-mailbox.com>
        perl regexp question <carlston88@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 22 Jan 2007 21:24:08 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Could someone help me with this source code?
Message-Id: <slrneravuo.8dd.tadmc@tadmc30.august.net>

Caduceus <4w2weez02@sneakemail.com> wrote:
> "Sherm Pendley" <spamtrap@dot-app.org> wrote in message 
> news:m2y7nxwkxb.fsf@Sherm-Pendleys-Computer.local...
>>> I need to know how to specify Mozilla thunderbird as the email client


>> what 
>> have
>> you tried so far? What error message and/or unexpected results did you 
>> get?


> What I need to know is that would this unix perl script work as a windows 
> perl scrip.


What happened when you tried it on Windoze?


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


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

Date: Tue, 23 Jan 2007 05:55:43 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: forum perl
Message-Id: <45b59547$0$27387$ba4acef3@news.orange.fr>

Exist you he(it) of the forums perl
There are solutions with php
But I schedule(program) it perl not with php
Sourceforge gives me 3000 solutions
How to choose


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

Date: Mon, 22 Jan 2007 21:20:43 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to decode javascript encodeURI / encodeURIComponent ?
Message-Id: <slrneravob.8dd.tadmc@tadmc30.august.net>

Ian <ianaturner@gmail.com> wrote:

> I won't be coming back


Thank you for improving our newsgroup.


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


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

Date: 22 Jan 2007 16:26:02 -0800
From: "Cloink" <Cloink_Friggson@ntlworld.com>
Subject: How to decode JavaScript's encodeURIComponent in Perl.
Message-Id: <1169511962.457132.272070@s48g2000cws.googlegroups.com>

This is an answer, not a question.  It's an answer for people like me
who struggle with the Perl language and all it's myriad idiosyncracies.

It's simple:-
----------------------
# I believe this package should be in the standard Perl distribution
use Encode;
# emulate =E9, e-acute, as encoded in js: encodeURIComponent('=E9')
my $str =3D '%C3%A9'; # nothing special about this example
$str =3D~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
# DO NOT "print $str;" - "decode" is all important - in the "Encode"
pkg that's been "use"d.
print decode('UTF-8',$str);
----------------------

Now that you know, you are very welcome to stop reading.  I advise it.

First, beware of documentation that refers to the regexp-substitution
WITHOUT the decode.  To my pretty little (ascii) head, once we've done
"$str =3D~ s//", then $str is a string, let's print it and look at it.
NO!!  (And I never use more than one single exclamation mark.)  So if
you don't decode() it, it's wrong.  decode() looks at it as a
BYTE-stream, not as an ascii-character list.

I say it's simple.  It ain't.  It's taken me a lot of heartache to find
someone to speak to me in plain English.  The above example will very
probably do the job unless you are dealing with, ooh, I don't know,
this is where my eyes go hazy and my mind wanders to bikini-clad women.
 Come on Clark, pull yourself together.  I'll say "complicated"
character sets, but I acknowledge that if you *are* dealing with what I
have described as a "complicated" character set, it is almost certainly
very familiar to you and therefore very UN-complicated.

But here's the deal.  What on the face of it seems like a simple
conundrum is actually a complicated conundrum, and Dan Kogai has
presumably put an awful lot of work into the Encode package/module
(sorry if "package" and "module" aren't actually interchangeable words,
in my world they are -- or maybe I meant something else again -- you
get the idea).

So use his module.  Package.  Thing.  It works.  Almost always, but I
can't guarantee it, and I don't think Dan can either - but not because
he doesn't know what he's doing - read on.

Now, thanks to Mark, here is an enormous amount of description as to
exactly why this seemingly simple subject is a very complicated
subject.  (Mark has kindly emailed me and I feel his very useful,
tutoring, you-can-understand-it-if-you-speak-English comments on the
matter deserve a wider audience than moi alone.)

So.  I'm going now, the rest of this is Mark's email to me.  It really
is very elucidating.

Bye!

>From Mark:

Clark, I read you, and to quote a former U.S. president, "I feel your
pain." (in my best Arkansas accent)

I'll look at the documentation for URI::Escape::uri_unescape to see
if it's confused or confusing. It might be an "apples and
oranges" question.

The problem you've found is a tough nut to crack. From the beginning
of time (maybe an exaggeration, at least since the creation of the
Internet), URIs have been an ASCII-only thing. The very name, American
Standard Code for Information Interchange, is insulting to people when
they find they can't use their own native character-set in a URI,
domain name, etc. What kind of "world standard" excludes the
majority of the world's population? I'm not unsympathetic.

So now we have Unicode -- a vastly superior term, to some people,
simply because it does not include the word "American" -- to save
us from ourselves.

Stuff like URI::Escape::uri_unescape was written to support
long-established standards that understand only ASCII. There's a vast
amount of existing software with the same problem. It's not been
updated to allow for Unicode. It's legacy software, but it works, and
it's safe, and secure (mostly). Even with Unicode, the common
language of the Internet name system is still US-ASCII (no pound or
euro characters, please).

Here's the trick... URI encoding is described in RFC 2396 (see
http://rfc.net/rfc2396.html for a printable copy). It defines ASCII as
the valid character set and allows for encoding of single-byte (8 bits)
non-ASCII characters. However, valid Unicode characters can be 2-bytes
or 4-bytes, potentially even more. URI encoding can't handle those
situations. Right now, we're dealing with UTF-8. We can trick URI
encoding into thinking it's dealing with simple ASCII characters when
in fact, the actual characters are Unicode. Here's a web page that
explains UTF-8 in lots of detail.

http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8

Let me digress a little bit. Basic e-mail is text only. It doesn't
allow pictures because they're binary data, not simple text. We can
trick e-mail into thinking a picture is text. The result looks
something like this. You may have seen text like this in the
"source" of an e-mail message.

/9j/4AAQSkZJRgABAQEASABIAAD/4SUmRXhpZgAASUkqAAgAAAAVAA8BAgAYAAAACgEAABABAgAM
AAAAIgEAABIBAwABAAAAAQAkmRoBBQABAAAALgEAABsBBQABAAAANgEAACgBAwABAAAAAgBtGDEB
 .=2E.

As long as the lines stay in the correct order, we can turn the text
back into a picture. Rearrange the lines, and the result is garbage
even if the encoding is correct. URI encoding only works only as it was
designed, but we can trick it into thinking Unicode is ASCII.

With Unicode, the grouping of the bytes is important. For example,
byte-1 must be grouped with byte-2. Left to its own devices, URI
encoding turns valid Unicode into a sequence of encoded, but ungrouped,
single-byte characters. The grouping of bytes that's required for
valid Unicode is lost. Am I making sense... it is confusing. I guess I
should draw a picture (worth many words). The bottom line is, we have
to keep the Unicode bytes in the right groups and in the right
sequence. URI encoding alone destroys valid Unicode.

Ah, ha! (light bulb above my head) I've got an analogy... remember
algebra... (4 * 3) + 5 =3D 17, is different than 4 * (3 + 5) =3D 32. The
numbers are the same, the order is the same, but with different
grouping, the results are different. Unicode is like that. Different
groupings result in a different character set or totally invalid
Unicode. There are ambiguous cases that can't be resolved if one
doesn't know the original sequence and grouping.

Unicode has been sneaking up slowly. Surprisingly, it's not a simple
one-to-one correspondence from URI to Unicode. Consider this URI
(Don't go there! Well, you may if you wish, but there's no need),

http://www.bankofamerica.com/

With strict ASCII, there's no problem. However, if someone uses, for
example, a Cyrillic character set to register the same domain, we run
into trouble. Cyrillic 'a' looks like ASCII 'a' when it's in
a browser address line, but the two characters are entirely different
in Unicode. A single character of Unicode could send Bank of America
customers to a web site in the farthest reaches of Siberia.

See "The Cyrillic Charset Soup" at
http://czyborra.com/charsets/cyrillic.html for an idea of the scope of
the problem. Unicode is intended to fix this mess, but it's a slow,
evolving process.

In general, here's the scheme of things. It's the order that's
important. Using JavaScript with perl adds an extra layer of
complexity. From the perl point-of-view:

   1. Get a fully encoded string
   2. Decode URI encoding
   3. Decode Unicode with error checking
   4. If you expect a particular character set at this point, do a
sanity check
   5. Be happy


If someone wants to slip in a bogus URI, it will most likely include
obscure Unicode characters or entirely invalid Unicode. This is where
David's comments apply. I called it a sanity check. David explained
the same thing in a different way. The Cyrillic character problem with
the letter 'a' is the tip of the iceberg. This is where the trouble
begins. From a pragmatic point of view, it's *probably* sufficient to
error check and do a minimal sanity check if you're working with
URIs. If you're working with form data or text in general, you need
more sanity checking.

Going the other way from valid Unicode to a fully encoded URI looks
like this:

   1. Get a string assuming it's in the correct character set, i.e.,
valid Unicode
   2. Encode Unicode with error checking for good measure
   3. Encode with URI encoding
   4. Pray!


It should work every time, but... If you need to depend on a valid URI
that can't be spoofed, do some error checking. See:

http://search.cpan.org/~dankogai/Encode-2.18/Encode.pm#Handling_Malformed_D=
ata

There are some Unicode "gotchas" lurking in perl. Before version
perl version 5.6, Unicode was a patch-up job. After version 5.6,
Unicode is well supported. In most cases, perl is smart enough to do
the right thing; it makes the right guess; it does what most people
would expect. I suppose it's intuitive in that way. For the complete
story, check "perldoc perlunicode".



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

Date: 23 Jan 2007 03:38:20 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How to decode JavaScript's encodeURIComponent in Perl.
Message-Id: <Xns98C0DC1E82740castleamber@130.133.1.4>

"Cloink" <Cloink_Friggson@ntlworld.com> wrote:

> $str =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;

s/%([0-9a-f]{2}/ chr hex $1 /egi;

Probably better to use URI::Escape.

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: 22 Jan 2007 17:09:25 -0800
From: "Cloink" <Cloink_Friggson@ntlworld.com>
Subject: Re: How to decode JavaScript's encodeURIComponent/encodeURI in Perl.
Message-Id: <1169514565.321759.14090@a75g2000cwd.googlegroups.com>

[The only reason for this reply is so that the post also gets hits if
you search for "encodeURI" (without the the "Component" on the end). I
hope, but I can't tell 'til I post it then google-group it.]



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

Date: 23 Jan 2007 03:35:34 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How to decode JavaScript's encodeURIComponent/encodeURI in Perl.
Message-Id: <Xns98C0DBA6A2809castleamber@130.133.1.4>

"Cloink" <Cloink_Friggson@ntlworld.com> wrote:

> [The only reason for this reply is so that the post also gets hits if
> you search for "encodeURI" (without the the "Component" on the end). I
> hope, but I can't tell 'til I post it then google-group it.]

Don't do that.

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: Tue, 23 Jan 2007 00:05:02 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: MAC Address Comparison
Message-Id: <elgar2tol7lhvui5n1bbeqk0mqacnbe95q@4ax.com>

On 22 Jan 2007 14:10:16 -0800, "doni" <doni.sekar@gmail.com> wrote:

>Here are the ones that I tried where $match variable contains the given
>mac address. The MAC address is available in this format:
>xx:xx:xx:xx:xx:xx
>
>1. if ($words[0] eq $match)

This should be fine, is $words[0] is in the same form of $match.
Incidentally, you may have forgot chomp()ing somewhere, which would
have left an "\n" making your comparison fail. Just guessing...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Mon, 22 Jan 2007 18:14:59 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: MAC Address Comparison
Message-Id: <m264ay1wng.fsf@Sherm-Pendleys-Computer.local>

John Bokma <john@castleamber.com> writes:

> Can't think up why close on read can fail atm, but I always check :-)

Same here, on both counts. I always figure it's better safe than sorry, when
it comes to error checking.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Tue, 23 Jan 2007 00:17:06 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: MAC Address Comparison
Message-Id: <eqgar2du9enm05mnv7dlm6urong7ea37mq@4ax.com>

On 22 Jan 2007 14:24:58 -0800, "doni" <doni.sekar@gmail.com> wrote:

>#! /usr/bin/perl -w

You'd better

  use warnings;  # nowadays, and
  use strict;    # always;

>$ex_data = "stat.txt";
>open (DATA,$ex_data) || die("Cannot Open File");

Which file, and why?!?

Incidentally, there's a predefined DATA filehandle, use another name,
or better yet, use a lexical filehandle...

>### Prompt the User for Input ###
>print "Enter the MAC Address in this format: xx:xx:xx:xx:xx:xx";
>$input = <STDIN>;

I had guessed right in my other post: you didn't chomp() $input.

>while (<DATA>) {
>    chomp;
>    @words = split;

I assume that stat.txt contains various space separated fields of
which the first is in the xx:xx:xx:xx:xx:xx format.

>    if ($words[0] =~ m/^[$input]/) {

This is wrong in several different ways: you introduce a charachter
class. If you really want to do it with a regex, you probablty want

    if ($words[0] =~ m/^\Q$input\E$/) {

But if you don't chomp() $input it will want $words[0] to end with a
"\n"; does the following work?

  #!/usr/bin/perl
  
  use strict;
  use warnings;
  
  my $ex_data = "stat.txt";
  open my $data, '<', $ex_data 
    or die "Can't open `$ex_data'\n";
  
  print "Enter the MAC Address in this format: xx:xx:xx:xx:xx:xx\n";
  chomp(my $input=<STDIN>);
  
  while (<$data>) {
      chomp;
      my $address=(split)[0];
      print $address, "\n" if $address eq $input;
  }
  
  __END__


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 22 Jan 2007 16:27:23 -0800
From: rkb@i.frys.com
Subject: Re: MAC Address Comparison
Message-Id: <1169512043.685583.67600@m58g2000cwm.googlegroups.com>

Michele Dondi wrote:
> On 22 Jan 2007 14:24:58 -0800, "doni" <doni.sekar@gmail.com> wrote:
>
>   while (<$data>) {
>       chomp;
>       my $address=(split)[0];
>       print $address, "\n" if $address eq $input;
>   }
>

As I mentioned earlier, it would be best to make the check case
insensitive.  If the user enters the correct address, but the case is
different than what's in the file, the test will fail.  Also, I'd exit
out of the loop if there is a match.

while (<$data>) {
      chomp;
      my $address=(split)[0];
      print "$address\n" and last if $address =~ /^\Q$input\E$/i;
 }



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

Date: 23 Jan 2007 00:29:13 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: MAC Address Comparison
Message-Id: <Xns98C0BC0ECA59Dcastleamber@130.133.1.4>

Sherm Pendley <spamtrap@dot-app.org> wrote:

> John Bokma <john@castleamber.com> writes:
> 
>> Can't think up why close on read can fail atm, but I always check :-)
> 
> Same here, on both counts. I always figure it's better safe than
> sorry, when it comes to error checking.

Yup, very true. I bumped into the quota issue a few years back (or better: 
a customer did :-)

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: Mon, 22 Jan 2007 17:02:21 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: MAC Address Comparison
Message-Id: <220120071702212571%jgibson@mail.arc.nasa.gov>

In article <1169506463.556295.89700@q2g2000cwa.googlegroups.com>, doni
<doni.sekar@gmail.com> wrote:

> thanks sherm and rkb. I am able to get it working perfectly.
> 
> I am wondering why do I get this "Use of uninitialized value" warning
> message. Can you guys let me know...

Please do not top-post. If you don't know what that means, google for
it.

> > while (<DATA>) {
> >     chomp;
> >     @words = split;
> >     if ($words[0] =~ m/^[$input]/) {
> >         print "$words[0]\n";
> >     }
> > }
> > close(DATA);
> >

You probably have a blank line in your input. Hence, @words will be
empty and $words[0] will be undefined. Test for a blank line before
splitting and comparing strings:

  next if length == 0;

or:

  next if m/^\s*$/;

or (after split):

  next unless @words;

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


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

Date: Mon, 22 Jan 2007 21:14:16 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: multiline pattern matching from file
Message-Id: <slrneravc8.8dd.tadmc@tadmc30.august.net>

Giulio <dongiulio@gmail.com> wrote:

> Each item is composed by several properties, contained on different
> lines of the page,


> how can I do this pattern matching from the file and obtain the full
> multiline pattern?


I'd start with the official answer to your Frequently Asked Question:

    perldoc -q match

       I’m having trouble matching over more than one line.  What’s wrong?


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


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

Date: 22 Jan 2007 16:34:03 -0800
From: "bill" <vilas_santafe@yahoo.com>
Subject: Re: Net::FTP::Recursive hangs
Message-Id: <1169512443.252627.227020@a75g2000cwd.googlegroups.com>

I found the problem. I needed to set the 'Passive => 1' flag in the
new() cmd.
Martin, thanks for pointing me in the right direction.
- Bill

bill wrote:
> Hi Martin,
> thanks for your reply.
> Yes, ftp works fine on the same box from the command line:
>
> ]$ ftp ftp@ftp.ciac.org
> Connected to ciac.org.
> 220 ciac.org FTP server ready.
> 331 Guest login ok, send your complete e-mail address as password.
> Password:
> 230 Guest login ok, access restrictions apply.
> Remote system type is UNIX.
> Using binary mode to transfer files.
> ftp> cd pub
> 250 CWD command successful.
> ftp> dir
> 227 Entering Passive Mode (198,128,39,4,118,187)
> 150 Opening ASCII mode data connection for /bin/ls.
> total 20
> drwxrwsr-x  11 webheads     512 Sep  1  1999 ciac
> drwxrwsr-x   2 webheads     512 Jan 25  2001 demo
> drwxrwsr-x   2 webheads     512 Jan 26  2001 iss
> drwxrwsr-x   2 webheads     512 Mar 18  2003 mptc
> drwxrwsr-x   2 webheads     512 Jan 26  2001 realsecure
> drwxrwsr-x   7 webheads     512 Feb 12  1996 spi
> drwxrwsr-x   3 webheads    1536 Sep 24  1999 spinet
> drwxrwsr-x   3 webheads     512 Dec 11  1997 spint
> drwxrwxr-x   2 webheads     512 Nov 14  2003 ssds
> 226 Transfer complete.
>
> I do use the firewall, with ftp passive mode ON. I do not have any
> proxy servers defined (that I'm aware of). None are set in the network
> manager.
>
> Thanks, Bill
>
>
> Martijn Lievaart wrote:
> > On Mon, 22 Jan 2007 11:55:15 -0800, bill wrote:
> >
> > > Hi All,
> > >
> > > I'm trying to use Net::FTP::Recursive 'rdir' to return recursive
> > > directory listings.
> > > I tried both my own version of a script, and when that did not work, I
> > > tried the script
> > > included in the 2.0 version of Net::FTP::Recursive. I turned on Debug,
> > > and here is the
> > > output (same for both scripts). The script hangs on LIST, then times
> > > out after a few minutes.
> > > I've ftp'ed directory to this site and verified that the directory is
> > > there and has
> > > sub-directories. I've done a little searching for info on the 425 eror
> > > msg, but did not find much useful. I'm running this on Mac OS/X 10.4.8,
> > > perl 5.8.6, Net::FTP::Recursive 2.0.
> > >
> > > Can someone help?
> >
> > "Ftp hangs on LIST command" is 99% of the time related to NAT. Did you do
> > the ftp from the same box? Does that client have any proxy settings?
> >
> > M4
> > --
> > Redundancy is a great way to introduce more single points of failure.



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

Date: 22 Jan 2007 17:13:10 -0800
From: "Derek Basch" <dbasch@yahoo.com>
Subject: Re: No backtick shell return value
Message-Id: <1169514790.068894.91670@s48g2000cws.googlegroups.com>


Michele Dondi wrote:
> On 22 Jan 2007 10:07:11 -0800, "Derek Basch" <dbasch@yahoo.com> wrote:
>
> >Subject: No backtick shell return value
>
> But you're *not* using backticks below...
>
> >However, It just hangs forever after the shell script (2) returns. I
> >cannot figure out what I am doing wrong. Any one have an idea?
> >
> >Here is the Perl script (1):
> >------------------------------------------------------------------------
> >open(COMMAND, "$proxy_dir/proxyctl restart |");
>
> Have you tried testing open() for success as is usually recommended?
>
> Anyway I don't see anything terribly wrong, except that I would use a
> lexical filehandle and the three args form of open():
>
>   open my $cmd, '-|', "$proxy_dir/proxyctl", 'restart'
>     or die "Can't run proxyctl: $!\n";
>
> This way you won't fire up a shell, but directly run the script
> passing to it the 'restart' cmd line argument.
>
> BTW: (do a favour to yourself and)
>
>   use strict;
>   use warnings;
>
> >Here is the bash shell script:
> [snip]
>
> I see this is moderately complex. Have you tried using the above with
> a script that simply does e.g.
>
>   echo 'foo bar baz';
>
> ? If it works, then you may have a problem with your shell script, not
> with the perl one.
>
>
> Michele
> --
> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Shoot. Sorry. My bad. I posted the wrong code. Thanks for the tips
though. I will try them all out and report the results.

Derek



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

Date: 22 Jan 2007 15:16:21 -0800
From: "doni" <doni.sekar@gmail.com>
Subject: Re: Pattern Matching and Extraction
Message-Id: <1169507781.165143.262000@11g2000cwr.googlegroups.com>

thanks a lot Michele, I was able to get the result I wanted using your
method.

doni.


Michele Dondi wrote:
> On 22 Jan 2007 12:08:59 -0800, "doni" <doni.sekar@gmail.com> wrote:
>
> >Here is how the data looks like.
> >
> >Patrick
> >->	2345 CountryLane Houston 77023
> >Craig
> >->	7200 Archstone Apts, #404 San Ramon 94583
> >Bret
> >->	501 TownHouse Apts, #202 Houston 77023
> >Gilbert
> >->	4200 OakView Apts, #6, Nashua 03060
> >
> >So, if the user inputs "Patrick" I should be able to match Patrick in
> >the data file and then print "Houston" and "77023".
>
> Something like the following may come close:
>
>   while (<$fh>) {
>       chomp;
>       next unless $_ eq 'Patrick';
>       defined($_=<$fh>) or last;
>       print "@{[ (split)[-2,-1] ]}";
>   }
>
> Of course in "real" code you would add some check, in particular you
> would make sure that the fields got from split() are defined and
> consistent with what you expect them to be like. OTOH your "format"
> seems inconsistent: it's partly comma separated, partly space
> separated, and differently so on different lines. Moreover some city
> name seem to include space(s). Thus it's hard to say what one should
> really split() on.
>
>
> Michele
> --
> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,



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

Date: Mon, 22 Jan 2007 15:28:29 -0800
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: Pattern Matching and Extraction
Message-Id: <45B5489D.2010201@purlgurl.net>

doni wrote:

> thanks a lot Michele, I was able to get the result I wanted using your
> method.

While Michele's code is good code, decent code, Michele's code
does NOT return correct results.

Purl Gurl

#!perl

while (<DATA>)
  {
   chomp;
   next unless $_ eq 'Craig';
   defined($_=<DATA>) or last;
   print "@{[ (split)[-2,-1] ]}";
  }

__DATA__
Patrick
->	2345 CountryLane Houston 77023
Craig
->	7200 Archstone Apts, #404 San Ramon 94583
Bret
->	501 TownHouse Apts, #202 Houston 77023
Gilbert
->	4200 OakView Apts, #6, Nashua 03060


PRINTED RESULTS:

Ramon 94583



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

Date: 23 Jan 2007 00:25:36 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Pattern Matching and Extraction
Message-Id: <Xns98C0BB716B8B3castleamber@130.133.1.4>

"doni" <doni.sekar@gmail.com> wrote:

> John,
> I cannot change the format as the generated file has data in that
> format.

Then you might have a big problem at hand unless tabs are used to separate 
the fields.

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: Mon, 22 Jan 2007 21:16:55 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Pattern Matching and Extraction
Message-Id: <slrneravh7.8dd.tadmc@tadmc30.august.net>

doni <doni.sekar@gmail.com> wrote:


PLEASE DO NOT TOP-POST!

If you do not know what "top post" means, then you should try to find
out as soon as possible.


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


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

Date: Mon, 22 Jan 2007 19:06:21 -0800
From: fishfry <BLOCKSPAMfishfry@your-mailbox.com>
Subject: Re: Perl CGI or Something Else CGI?
Message-Id: <BLOCKSPAMfishfry-0DB11A.19062122012007@news.giganews.com>

In article <1169214421.662377.24050@l53g2000cwa.googlegroups.com>,
 "Rg" <rg.bacs@gmail.com> wrote:

> Hello everyone,
> 
> I am writing drafts for an online system that must be accessible via
> Web and must make use of some DBMS (probably MySQL). I am planning on
> using Perl CGI, but I can't really make up my mind about that decision.
> 
> The one fact that prevents me from starting to write Perl CGI right
> away is efficency. It worries me that every page hit should have the
> Perl interpreter instantiated and then have it logged into the DBMS.
> Instead, I'd like something that would stay memory-resident and already
> logged into the DBMS. I thought then of using pure C CGI and linking
> page requests with a resident process. But, of course, I can't really
> make up my mind about that decision...
> 
> So, here's the question: should I actually worry about starting up the
> Perl interpreter and then logging into the DBMS at the expense of
> efficiency? Does that really happen or Perl CGI works in some other way
> that I'm just missing here? And, finally, does it pay to use pure C CGI
> or PHP instead of Perl CGI?

Use mod_perl. That's a Perl interpreter imbedded in the Apache 
webserver. Designed to solve the exact problem you describe.


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

Date: 22 Jan 2007 19:34:00 -0800
From: "IcyMint" <carlston88@gmail.com>
Subject: perl regexp question
Message-Id: <1169523240.569007.119630@11g2000cwr.googlegroups.com>

Hi, I'm trying to change the contents of a file base on the substitute
list from the other file. I'd copied my progress over here, albeit with
some changes. The content file format is: #name group OR #name \n+
group
The script is working fine, but I want it to compare if the group name
is correct. If it is incorrect, change it, and count how many times it
had been changed. What I'm trying to do is something like:
while ($content =~ /\n\#(\S+)\b\s+(\S+)/g) {
    my($name,$group) = ($1,$2);
    unless ($group eq $data{$name}) {
        $2 = $data{$name};
        $count{$name}++;
    }
}
It's not a valid code, it gave me errors, but i'm just including it so
that maybe you'll understand what I'm trying to achieve. Can you help
me with this? Thank you!


open(FILE,"content.txt") or die "Cannot open file content.txt~ $!\n";
open(DATA,"data.txt") or die "Cannot open file data.txt~ $!\n";

undef $/;
my $content = <FILE>;
my $data = <DATA>;

while ($data =~ /\nsubstitute\s+(\S+)\s+(\S+)/g) {
    $data{$1} = $2;
}

foreach my $key (keys %data) {
    $content =~ s/\n\#$key\b\s*\S+/\n\#$key $data{$key}/g;
    $content =~ s/\n\#$key\b\s*\n\+\s+\S+/\n\#$key\n\+\s$data{$key}/g;
}


The content.txt(modified version) file looks something like this:

#benjamin TB3
#desmond TG2
#terrence TE1
#abigail_lim_suet_ching
+ KR8



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

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


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