[11206] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4806 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 2 13:07:12 1999

Date: Tue, 2 Feb 99 10:02:57 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 2 Feb 1999     Volume: 8 Number: 4806

Today's topics:
        Accessing ASP objects from perl spessard@orionsci.com
    Re: advertising script problem <elst.fels@nospam.ping.be>
    Re: Anyone familar with CGI.pm internals? (Bill Moseley)
        are regular expression rationaly designed ? olivier_pelletier@my-dejanews.com
    Re: Comments in Perl code droby@copyright.com
    Re: Copying files in NT (Jan Krynicky)
    Re: debug this script please <elst.fels@nospam.ping.be>
        Determine Country of user <rlally1@nycap.rr.com>
    Re: Determine Country of user <design@raincloud-studios.com>
    Re: Determine Country of user <mike@crusaders.no>
    Re: Determine Country of user (Larry Rosler)
    Re: Filtering... (Larry Rosler)
    Re: Getting the wildcard value <ebohlman@netcom.com>
    Re: Getting the wildcard value <ebohlman@netcom.com>
    Re: Help needed with locking (M.J.T. Guy)
        help with last modified pault2000@my-dejanews.com
    Re: help with last modified (Larry Rosler)
    Re: how to code a between() with regex? <aqumsieh@matrox.com>
        How to kill a running process in win32 using perl medavarm@usa.redcross.org
        Is there an Interactive Debugger for Perl? <no_spam@no_spam.com>
    Re: Is there an Interactive Debugger for Perl? <ludlow@us.ibm.com>
    Re: local($_) - why not "my"? <aqumsieh@matrox.com>
    Re: Match Parens-More Perlish? (Rob Partington)
    Re: modules on NT? (David Cantrell)
        Multicast and Perl (Gaetan Lord)
        Net::FTP help (Zinc Plate)
    Re: Net::FTP help (Sean McAfee)
        newbie having trouble with concatination <eem3gk@ee.surrey.ac.uk>
    Re: opening files by date (Larry Rosler)
    Re: Perl syntax ( URGENT ) (Larry Rosler)
        Program/module to filter/tune/reorganize ASCII Reports? (Gerhard Grasboeck)
    Re: Question about Regular Expression (Larry Rosler)
    Re: Regex for e-mail addresses? (Larry Rosler)
    Re: reused functions. (Larry Rosler)
    Re: reused functions. (Andrew M. Langmead)
    Re: Soft reference question <aqumsieh@matrox.com>
    Re: Statistics for comp.lang.perl.misc (Bart Lateur)
    Re: submit a form and Perl question <vpatricio@abrantina.pt>
    Re: substituting keywords in a string (Andre L.)
    Re: UNC-Path under windows NT ? Don.Carlton@Citadel.edu
    Re: Visual Perl? <svend@lubypublishing.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 02 Feb 1999 16:08:23 GMT
From: spessard@orionsci.com
Subject: Accessing ASP objects from perl
Message-Id: <7977te$9d3$1@nnrp1.dejanews.com>

I am trying to access some of the built in asp objects from perl.  Makely the
session, request, and server objects.  Is there a way to access these objects
from perl 5.0?  I am trying to do a systems integration using some of this
technology.  And no I can not get the client to change web servers and
rewriting half the code is also not an option.


Thanks
Nelson Spessard

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 2 Feb 1999 18:26:33 +0100
From: "myname@mydomain.com" <elst.fels@nospam.ping.be>
Subject: Re: advertising script problem
Message-Id: <797cct$rum$1@news3.Belgium.EU.net>

Yeah good answer, but that wasn't the question was it ?!
Don't be a smartass and let me try to figure this out OK ?
If I only wanted one banner I wouldn't have asked the freaking question !!!



Abigail heeft geschreven in bericht <79322f$hds$6@client2.news.psi.net>...
>myname@mydomain.com (elst.fels@nospam.ping.be) wrote on MCMLXXVIII
>September MCMXCIII in <URL:news:78ubsr$a3f$1@news3.Belgium.EU.net>:
>-- Can anyone give me an idea how to make a script that:
>--
>-- - displays one bannerimage for instance 50% of the time
>--   and other banners at an other percentage of time.
>-- - it is not the idea to show the same banner time and time over till the
50%
>-- is done
>--   it must come between the other banners otherwise the advertising is
not
>-- balanced over time.
>
>There's nothing Perl specific to your question, is there?
>
>
>The easiest solution: don't display banners at all. Then 50% of the shown
>banners are the one banner. And each of the other banners also take 50%
>of the sightings! You can charge your customers more! Each ad is shown
>50% of the times ads are shown!
>
>
>
>Abigail
>--
>perl -we
'$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
>
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
>             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'




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

Date: Tue, 2 Feb 1999 07:27:23 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: Anyone familar with CGI.pm internals?
Message-Id: <MPG.1120b93aa12e01ff989699@nntp1.ba.best.com>

Nope.  I'm not using two CGI objects, nor am I using readparse.

use CGI qw/:standard :html3/;       # Well, because this is a CGI script
my $Query = new CGI;                # Create form object

$CGI::POST_MAX=1024 * 20;
$CGI::DISABLE_UPLOADS = 1;

Is all I'm using.  If I comment the my $Query line out then it won't 
compile.

Clearly, I need to start hacking up my script and see at what point this 
is happening.  I was just wondering if there was something obvious that I 
over looked.

Thanks,


In article <MPG.112023f5271bb517989698@nntp1.ba.best.com>, 
moseley@best.com posted:
> 
> > (offline mode: enter name=value pairs on standard input)
> > 
> > which is normal, but then I press ^Z or ^D (depending on where I'm 
> > running it) and then I get
> > 
> > (offline mode: enter name=value pairs on standard input)
> > 
> > again, a second time.
> 
In article <comdog-ya02408000R0202990035050001@news.panix.com>, > In 
comdog@computerdog.com says...
> do you happen to create two CGI objects in your script?  you'll 
> get one of these promotes each time you call the CGI constructor
> if you don't pass anything (like a saved state) to it.

And

In article <36B70C5B.F78D967A@utk.edu>, fty@utk.edu says...
> Are you using ReadParse() and $q = new CGI; t:whis creates two objects.
> If you are and still want to use OO method calls do the following:
> 
> use CGI qw(:cgi-lib);
> ReadParse();
> $q = $in{CGI};


-- 
Bill Moseley mailto:moseley@best.com


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

Date: Tue, 02 Feb 1999 15:42:00 GMT
From: olivier_pelletier@my-dejanews.com
Subject: are regular expression rationaly designed ?
Message-Id: <7976c6$7t0$1@nnrp1.dejanews.com>

I would like to know if there is a theory hidden behind regular expression
matching ? Could anyone point me out a link to a document explaining this
theory if it exists ? In particular can any pattern be matched by a regular
expression ?

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 02 Feb 1999 16:48:43 GMT
From: droby@copyright.com
Subject: Re: Comments in Perl code
Message-Id: <797a96$bn2$1@nnrp1.dejanews.com>

In article <794p50$3ei@bgtnsc01.worldnet.att.net>,
  "Charles R. Thompson" <design@raincloud-studios.com> wrote:
>
> Depending on the Module in question, we will often install our
> own versions and rip out what we don't need for the same reasons
> described above. I realize alot of purists are cringing at that
> thought, but for us the system works. We just started replacing
> our libraries with Perl modules and often have to install our
> own versions simply because the hosting service doesn't desire
> to use 'cutting edge' (= new, untested on their part) versions
> of modules for security purposes, which is understandable.
>

They won't install new versions of modules because of security.
But they let you remodel the new modules, install them, and run them.
Great security!

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 02 Feb 1999 17:54:16 GMT
From: Jenda@McCann.cz (Jan Krynicky)
Subject: Re: Copying files in NT
Message-Id: <1103_917978056@way>

On Sat, 30 Jan 1999 21:54:11 -0800, mwebster@inetarena.com wrote:
> Any tips on where I can get info on copying files and directories on one
> NTWS to an NT Server?  I've got LPfW32, and I'm already checking the
> www.activestate.com user groups, but I need a solution by Monday
> morning! A simple "open()" isn't working the way it should, but I'm new
> to the language and am still getting a feel...
> 
> Any suggestions??
> 
> mwebster@inetarena.com

I guess for you will be best to use Wi32::FileOp: 

 use Win32::FileOp;

 Copy 'c:\some_dir\*.*' => '\\\\the_server\some_share\some_dir';

This will copy the whole directory even with subdirectories.

You may install Win32::FileOp like this :

 c:\> PPM
 PPM> install /location http://Jenda.Krynicky.cz/perl/ Win32-FileOp

See http://Jenda.Krynicky.cz/

HTH, Jenda
P.S.: This module works of course only on Win95/98/NT !


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

Date: Tue, 2 Feb 1999 18:08:43 +0100
From: "myname@mydomain.com" <elst.fels@nospam.ping.be>
Subject: Re: debug this script please
Message-Id: <797bbg$qo8$1@news3.Belgium.EU.net>

No it is not the same.
By applying other ranges to the different images you can make one image
appear more then another. This feature was important because
I want to determine the percentage of each image.

Thanks anyway,

Peter
Frank de Bot heeft geschreven in bericht <36B707E3.52701C20@xs4all.nl>...
>This would do the same trick:
>#!/usr/bin/perl -w
>use strict;
>srand;
>print "content-type: text/html\n\n";
>print '<img src="',int(rand(4)),'.gif">\n';
>
>In your scripts you had forgotten this: { . You've wrote: if (x=x) do
>this;}
>
>
>"myname@mydomain.com" wrote:
>
>> Can anyone tell me what is wrong with this script ?
>> I really don't get it, I always get an internal server error.
>> I chmod te files read/write/execute
>>
>> Please help,
>>
>> Peter
>>
>> netket@dma.be
>>
>> #!/usr/bin/perl -w
>> use strict;
>> srand;
>> my $whichImg = rand(4);
>> my $img;
>> if ($whichImg < 1)
>>
>> $img = '1.gif';
>> }
>> elsif ($whichImg < 2)
>>
>> $img = '2.gif';
>> }
>> elsif ($whichImg < 4)
>>
>> $img = '3.gif';
>> }
>> print "<img src=\"$img\">\n";
>
>--
>Hi, this piece is put automaticly under every mail from me.
>
>Contact me: debot@xs4all.nl
>Visit my page:  http://www.debot.nl/
>    http://www.geocities.com/SunsetStrip/Frontrow/4346/top50index.html
>
>I've much more homepage. You can just ask for them if you want.
>
>Well, more I havn't to say, so have a nice day :-)
>
>




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

Date: Tue, 02 Feb 1999 16:12:15 GMT
From: "Bob Lally" <rlally1@nycap.rr.com>
Subject: Determine Country of user
Message-Id: <ztFt2.1206$Y_1.19450@typhoon.nycap.rr.com>

Hi:

Is it possible for a perl script to get the IP address of the user and
somehow get the country code?  Possibly using Reverse lookup or something?

Thanks.

Bob




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

Date: 2 Feb 1999 16:59:54 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Determine Country of user
Message-Id: <797aua$6if@bgtnsc01.worldnet.att.net>

>Is it possible for a perl script to get the IP address of the
user and
>somehow get the country code?  Possibly using Reverse lookup or
something?


You are correct. I'm pretty sure there are modules that handle
that messy stuff for you. Look for just about any visitor
logging scripts and you'll find more info on how it's done.

CT




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

Date: 2 Feb 1999 17:06:12 GMT
From: Trond Michelsen <mike@crusaders.no>
Subject: Re: Determine Country of user
Message-Id: <797ba4$cdl$1@romeo.dax.net>

On  2. Feb 17:12, Bob Lally wrote:

> Is it possible for a perl script to get the IP address of the user
> and
> somehow get the country code?  Possibly using Reverse lookup or
> something?

Not really...

If you by "perl script" mean "CGI-script" then the web-server (well,
atleast Apache - I have no experience with anything else) will provide
you with the variables $ENV{REMOTE_ADDR} and $ENV{REMOTE_HOST}.
remote_addr includes the IP-address, remote_host is the host-name (if
"reverse lookup" has been switched on in the web-server config) or the
IP-address if it can't find the hostname.

But, the problem is that there are no clear-cut rules that will tell
you which country a user is in based by either his IP-address or his
top-level domain-name.

Anyway, if a guesstimate is good enough, then you should get hold of a
list of ISO-country codes. This list will match any two-letter
top-level domains.
You could also take a look at various web-log analyzers, as these use
the host-address to determine the country of the visitor in much the
same manner.

-- 
  // Trond Michelsen
\X/  mike@crusaders.no


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

Date: Tue, 2 Feb 1999 09:07:29 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Determine Country of user
Message-Id: <MPG.1120d0acbe7680dd9899f8@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <ztFt2.1206$Y_1.19450@typhoon.nycap.rr.com> on Tue, 02 Feb 
1999 16:12:15 GMT, Bob Lally <rlally1@nycap.rr.com> says...
> Is it possible for a perl script to get the IP address of the user and
> somehow get the country code?  Possibly using Reverse lookup or something?

The 'gethostbyaddr' function will return the fully qualified domain name 
if it can be resolved by reverse DNS lookup.  But most domain names are 
generic geographically in any case.

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


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

Date: Tue, 2 Feb 1999 07:10:15 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Filtering...
Message-Id: <MPG.1120b531aef3d1479899f1@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <jJot2.31$5q4.885@afrodite.telenet-ops.be> on Mon, 1 Feb 1999 
22:08:23 +0100, PsIoNnEkE <bdispa@bigfoot.com> says...
> I have a script that display's all filenames of a dir. Now I want that every file beginning with a '.' (dot) is filtered out... Every file comes in through a variable and is directly printed via the print-command. So no arrays are involved.
> I though of an IF-THEN sequence, but I don't seem to get it work...

Several others have posted regex-based solutions.  Someone should also 
post a substr-based solution, which is significantly faster (if that 
matters in your application):

  if (substr($name, 0, 1) eq '.') { ... }

> (if possible, pls reply via e-mail)

No problem for me, because your address isn't munged.

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


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

Date: Tue, 2 Feb 1999 14:58:35 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Getting the wildcard value
Message-Id: <ebohlmanF6J89n.BwF@netcom.com>

Rick Holt <holt@watson.ibm.com> wrote:
: I am attempting to extract the data from a line of HTML
: using perl.  For example, given the line:

:   <meta name="Author" content="Rick Holt">

: If I want to extract the value of name, I know I can first
: split on "name=" and then split on the double-quote.  But
: it seems like it ought to be possible to use a pattern like

:    /name=".*"/

: and have the value of .* assigned somewhere.

In your case, the pattern will match [Author" content=] which is not what 
you want.  You could fix this case by using non-greedy matching, but 
you're going to keep running into various little pitfalls along the way.  
Familiarize yourself with HTML::Parser, which will very nicely split your 
HTML up into tags and text, and will gather attributes up for you so that 
you can easily access them.




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

Date: Tue, 2 Feb 1999 15:15:21 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Getting the wildcard value
Message-Id: <ebohlmanF6J91L.9o6@netcom.com>

Eric Bohlman <ebohlman@netcom.com> wrote:

: In your case, the pattern will match [Author" content=] which is not what 

Oops, that should be [Author" content="Rick Holt].


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

Date: 2 Feb 1999 17:36:57 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Help needed with locking
Message-Id: <797d3p$3k6$1@pegasus.csx.cam.ac.uk>

In article <795stc$4p5$1@nnrp1.dejanews.com>,  <mkshanx@ust.hk> wrote:
>
>Without the FLOCK the above program works like a charm. I guess they are using
>Sun OS in the university (my ISPs!), and Perl 5.001. Is that a problem? Is it
>that Perl 5.001 does not support flocking?

Perl 5.001 is prehistoric.    I wouldn't expect it to support anything
much.     Get a modern Perl.


Mike Guy


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

Date: Tue, 02 Feb 1999 15:17:21 GMT
From: pault2000@my-dejanews.com
Subject: help with last modified
Message-Id: <7974tm$6ku$1@nnrp1.dejanews.com>

Sorry to hassle this group twice in one day but I seem to have failed with
something that should be simple.

The script below should print the file names in a given folder as long as
they are no older than today. My plan is for the line below to skip the older
files:

next if -M $file > 1;

No Luck! I get an unitialised value error,

I have added the whole script below,

Thanks in Advance (again),

Regards,

Paul


#!/usr/local/bin/perl -w
#
require "cgi-lib2.pl";
print "Content-type: text/html\n\n";


#open and read directory

opendir (DIR, "/export/thelawyer/webpages/") or die "cannot open directory
$!";

#chuck filenames into filenames array

@filenames = readdir (DIR);
closedir (DIR);

#do the hard stuff

foreach $file (@filenames){

next if -M $file > 1; # skip files modified before today
next if ($file =~ /^\.\.?$/); # Skip . and ..
next if ($file =~ /bak?$/); # Skip bak folder

print "$file\n";

};

print "finished";

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 2 Feb 1999 08:53:35 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: help with last modified
Message-Id: <MPG.1120cd635486c0c59899f7@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7974tm$6ku$1@nnrp1.dejanews.com> on Tue, 02 Feb 1999 
15:17:21 GMT, pault2000@my-dejanews.com <pault2000@my-dejanews.com> 
says...
 ...
> opendir (DIR, "/export/thelawyer/webpages/") or die "cannot open directory
> $!";
> 
> #chuck filenames into filenames array
> 
> @filenames = readdir (DIR);
> closedir (DIR);
> 
> #do the hard stuff
> 
> foreach $file (@filenames){
> 
> next if -M $file > 1; # skip files modified before today

This interprets the filename relative to the current directory, whatever 
it happens to be.  You must either chdir to the directory you are 
reading (ahead of this loop), or prepend the absolute path to the 
filename.  (This error is on my "Top 10" list for c.l.p.misc!)

> next if ($file =~ /^\.\.?$/); # Skip . and ..
> next if ($file =~ /bak?$/); # Skip bak folder

These work OK because they just use the filename as a string.

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


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

Date: Tue, 2 Feb 1999 11:06:39 -0500 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: how to code a between() with regex?
Message-Id: <x3yiudkn62b.fsf@tigre.matrox.com>


Steve Palincsar <palincss@his.com> writes:

> 
> Duane Lunday wrote:
> > 
> > 
> > My $var = "    3] (Kinda_Weird_Filename) With Some Spaces.EXE     :::SIZE 1024k"
> 
> $var =~ m|\]\s*(\(.+\.EXE)|;
                  ^^
                  ^^
Just to make the solution more generic, I would not match a literal
open bracket here. There are paratheses in the given example, but I
suspect that is only part of the "pseudo-code" and that the weird file
name does not have to start with a "(". Maybe .. maybe not.

> $NewVar = $1;

Ala



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

Date: Tue, 02 Feb 1999 16:35:25 GMT
From: medavarm@usa.redcross.org
Subject: How to kill a running process in win32 using perl
Message-Id: <7979gc$b0f$1@nnrp1.dejanews.com>

I have and read all the documentation for Win32::Process at different sites
and they all seem to say that I have to create a process and kill it. But
what if I have a process already running? How can I kill it?

Anybody out there with ideas or sample scripts, let me know.

email: medavarm@usa.redcross.org

Moorthy

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 2 Feb 1999 10:04:24 -0600
From: "Ban Spam Now" <no_spam@no_spam.com>
Subject: Is there an Interactive Debugger for Perl?
Message-Id: <7977r6$pvi@sjx-ixn6.ix.netcom.com>

I am learning Perl and am used to languages which have an interactive
debugger.  At the moment I'm putting print statements everywhere.  Is there
an Interactive Debugger for Perl, or a slicker way than using prints?




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

Date: Tue, 02 Feb 1999 10:42:25 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Is there an Interactive Debugger for Perl?
Message-Id: <36B72AF1.EFF52BF0@us.ibm.com>

Ban Spam Now wrote:
> 
> I am learning Perl and am used to languages which have an interactive
> debugger.  At the moment I'm putting print statements everywhere.  Is there
> an Interactive Debugger for Perl, or a slicker way than using prints?

This is a FAQ, see www.perl.com or the faq that came with your
distribution of perl.

$ perldoc perldebug

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: Tue, 2 Feb 1999 11:31:26 -0500 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: local($_) - why not "my"?
Message-Id: <x3yg18on4wx.fsf@tigre.matrox.com>


rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:

> In perl4, 'my $_;' is a syntax error.
> 
> The original poster was correct; "currently" means that in some later
> version of Perl this could change.  But right now, all special variables
> are stored in the symbol table.  And because they're special, they can't
> just be yanked out of the symbol table to allow for lexical special
> variables.
> 
> I think "currently" is sort of the opposite of "deprecated"; this
> feature will be added in some future, unspecified version of Perl.  :-0

But won't that break any existing code?
I can't really think of a case where declaring $_ (or any other
special variable) as lexical would break something, but maybe someone
else can. After all, this is a major change in the nature of the Perl
special variables. Furthermore, "if it ain't broke, why fix it?"
 ... what are the potential advantages/disadvantages of yanking the
special variables out of the symbol table? For one, would that make
them undefined if I just used them without any declarations? what
would happen to their default values then?

curious Ala



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

Date: 2 Feb 1999 16:52:09 GMT
From: news@browser.org (Rob Partington)
Subject: Re: Match Parens-More Perlish?
Message-Id: <slrn7beb9p.ams.news@riffraff.plig.net>

On Tue, 02 Feb 1999 12:47:40 GMT, 
   Bart Lateur <bart.lateur@skynet.be> wrote:
>
>It can't be done with regular expressions alone, because recursively
>defined structures are more powerful than regular expressions. As thy
>say, "you need a parser". Here's a simple one (but untested).

>[perl code snip]

If you're just testing whether they match, what about...

 #! /usr/bin/perl -w

 my $text=join('',<>);
 1 while $text=~s/^(.*)\((.*)\)(.*)$/$1$2$3/; 
 print $text=~m/\(|\)/,"\n";

rjp@localhost> echo "This (s)((() a)() t))est" | perl -w brack.pl
1
rjp@localhost> echo "This ((s)((() a)() t))est" | perl -w brack.pl
rjp@localhost> echo "(simple)" | perl -w brack.pl
rjp@localhost> echo "((wrong)" | perl -w brack.pl
1
rjp@localhost> echo "(()right)" | perl -w brack.pl
rjp@localhost> echo "((l(i(s(p(y)))))" | perl -w brack.pl
1
rjp@localhost> echo "((l(i(s(p(y))))))" | perl -w brack.pl

Not much use if you want to do anything with the contents of the
brackets, mind.
-- 
rob partington


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

Date: Tue, 02 Feb 1999 17:43:51 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: modules on NT?
Message-Id: <36b73919.443114635@thunder>

On 1 Feb 1999 16:10:41 GMT, dsi@smart.net (Decision Systems Inc)
enlightened us thusly:

>Has anyone else had a problem using modules in NT?
>I have printed the @INC array and I know that this is the problem, for
>some reason it is pointing to the D:.  Is there any way to change this?  I
>have tried use lib to set the library path but this hasn't worked.
>
>Any suggestions?  

The default @INC is stored in the registry.  Search through the
registry for 'perl' and you'll eventually find it.  Be warned -
searching for that will also find things like 'hyperlink', and the key
you need to change occurs several times, so keep going until you reach
the end of the registry.

[Copying newsgroup posts to me by mail is considered rude]

-- 
David Cantrell, part-time Unix/perl/SQL/java techie
                full-time chef/musician/homebrewer
                http://www.ThePentagon.com/NukeEmUp


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

Date: 2 Feb 1999 15:54:48 GMT
From: gaetan@gotlib.montreal.sgi.com (Gaetan Lord)
Subject: Multicast and Perl
Message-Id: <slrn7be7qd.k87.gaetan@gotlib.montreal.sgi.com>

Hi
    
I'm about to start a new project, and I will need to broadcast via multicast. I
look on deja news, for similar Q, but a lots of questions without any
response.
    
So, could it be possible to do multicast with perl, and is there is any
examples available on the web. This could be helpful to give me some idea on
the way I could create my applications.
    
Thank everybody
    


-- 
--
 ----------------------------------------------------------------------
 Gaetan Lord - FTA - gaetan@sgi.com - SGI - Montreal, Canada
 pager:  gaetan_p@montreal.sgi.com  (200 car. max)
 "There is no future in time traveling"
 ----------------------------------------------------------------------


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

Date: 2 Feb 1999 16:04:11 GMT
From: zincplate@aol.com (Zinc Plate)
Subject: Net::FTP help
Message-Id: <19990202110411.02264.00000342@ng-cg1.aol.com>

I like using Net::FTP, but I haven't figured out how to send commands that are
NOT currently specified.  In particular, I want to send a "prompt" command, and
I want to send an "mget" command, but I can't do either.  

(i.e. I'd like to be able to say $ftp->mget("*.txt"); ) # doesn't work

Is there a way to either send these commands through the FTP module or by some
other means?     

Please help!


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

Date: Tue, 02 Feb 1999 17:01:24 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Net::FTP help
Message-Id: <EbGt2.5270$Ge3.21539728@news.itd.umich.edu>

In article <19990202110411.02264.00000342@ng-cg1.aol.com>,
Zinc Plate <zincplate@aol.com> wrote:
>I like using Net::FTP, but I haven't figured out how to send commands that are
>NOT currently specified.  In particular, I want to send a "prompt" command, and
>I want to send an "mget" command, but I can't do either.  
>(i.e. I'd like to be able to say $ftp->mget("*.txt"); ) # doesn't work

>Is there a way to either send these commands through the FTP module or by some
>other means?     

"prompt" isn't necessary in a noninteractive environment.  As for mget,
it's easy enough to get the same functionality (written verbosely for
clarity):

@files = $ftp->ls;
@textfiles = grep /\.txt$/ => @files;
foreach $file (@textfiles) {
    $ftp->get($file);
}

I would write the same code like this, though:

get $ftp $_ foreach grep /\.txt$/ => ls $ftp;

This approach is more general than mget.  For example, I've written
code that needs to download files that are newer than one week old, the
date being part of the filename.

use Date::Calc qw(Delta_Days Today);

foreach $file ($ftp->ls) {
    next unless $file =~ /^..(\d\d)(\d\d)(\d\d)\.DAT$/;
    next unless Delta_Days(1900 + $1, $2, $3, Today) <= 7;
    $ftp->get($file);
}

(Don't anyone bother pointing out the very obvious Y2K issues; I'm not
responsible for generating the files.)

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Tue, 02 Feb 1999 14:34:28 +0000
From: Gavin Ian Andrew Kenny <eem3gk@ee.surrey.ac.uk>
Subject: newbie having trouble with concatination
Message-Id: <36B70CF4.3AB3@ee.surrey.ac.uk>

Hi sorry to ask a dumb question,
but I've only been using Perl for a
few months. 

I'm writing a script that reads a VHDL text file
and pulls out data from it.

Part of the problem is that lines are longer than 
a single line. Also the text is pretty haphazardly formatted.
So I wrote the following code to go through the file line by line
and put all the lines I'm interested in, into a single string so I could
then split it up
and count things.
 

 ....

$line =~ /\s*(\S+.*)$/; # this gets rid of tab at the start and \n
at 					# the end
$clean_line = $1;

$port = join ' ',$port,$clean_line; # $port is an earlier line "cleaned"
					# in exaclty the same way.

 ...

The trouble is, instead of the new $port being a concatenation of the
two strings, it just overlays them one on top of the other and makes
a right mess.

can anyone point out where I'm going wrong

ta

Gavin


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

Date: Tue, 2 Feb 1999 07:17:20 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: opening files by date
Message-Id: <MPG.1120b6ddd5fe70d79899f2@nntp.hpl.hp.com>

In article <m1n22xdkae.fsf@halfdome.holdit.com> on 02 Feb 1999 05:09:29 
-0800, Randal L. Schwartz <merlyn@stonehenge.com> says...
 ...
> If your definition includes anything with the word "creation" in it,
> you won't have an answer. :)

You will have a usable answer on Windows/DOS systems!  (No inodes, you 
know.)

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


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

Date: Tue, 2 Feb 1999 07:38:46 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl syntax ( URGENT )
Message-Id: <MPG.1120bbd7769789359899f5@nntp.hpl.hp.com>

In article <36B70A1C.CC892B70@xs4all.nl> on Tue, 02 Feb 1999 15:22:21 
+0100, Frank de Bot <debot@xs4all.nl> says...
 ...
> Chop get the \n of a string. chop($var);

Wrong.  It chops the last character, whatever it is.  You are thinking 
of 'chomp' (which is almost always the right function to use in any 
case).

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


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

Date: Tue, 02 Feb 1999 16:09:32 GMT
From: ggrasboeck@unisys.co.at (Gerhard Grasboeck)
Subject: Program/module to filter/tune/reorganize ASCII Reports?
Message-Id: <36b722af.15970213@nntp.unisys.co.at>

Hi to all of you perl hackers out there!

I've repeatedly run into the same requirement within my perl projects
over the last months. Given some kind of tabular ASCII report with one
ore more segments, each segment with some header fields, summary
fields and detail records, i have to extract and reorganize some part
of this report to produce another more compact and readable report.

Until now i have written a new perl script for every new input report,
so it would save me much time to have some kind of perl module to
define
	a) the structure of the input report,
	b) the structure of the output report and
	c) rules to get from a) to b).

Onfortunately i could not find anything useful at CPAN and on the rest
of the net.

Does anybody know of such a program/module?
I would gladly appreciate any hints to some existing source.

-------------
Gerhard Grasboeck



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

Date: Tue, 2 Feb 1999 07:27:41 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question about Regular Expression
Message-Id: <MPG.1120b949f8c755479899f3@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <796tue$67$1@nnrp1.dejanews.com> on Tue, 02 Feb 1999 13:18:13 
GMT, kaz@eudoramail.com <kaz@eudoramail.com> says...
> A part of my CGI get a value of referer.  I am trying to take out only the
> middle part of each value.  Ex.  if
> http://www.example.com/yyyy/zzzz/index.html, I need only the part of
> yyyy/zzzz.
 ...

  m#^http://[^/]+/(.*)/#;

The part you want is now in $1.

Here it is in detail:

  m#^http://      # literal match at beginning of string (in $_)
    [^/]+/        # match the domain name (no /'s and a /)
    (.*)          # remember in $1 as much as follows
    /#x;          #   up to but not including the last /

`perldoc perlre` is your friend.

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


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

Date: Tue, 2 Feb 1999 07:50:52 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regex for e-mail addresses?
Message-Id: <MPG.1120bebb8babe6a29899f6@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7972n5$4ac$1@news1.Radix.Net> on 2 Feb 1999 14:39:33 GMT, Ed 
Hitler <revjack@radix.net> says...
> Is there a single perl regular expression that will allow me to extract the
> e-mail addresses from the following header lines? 
 ...
> Right now I'm doing something like this:
> 
> $_ =~ s/^.*[ <(]([^ ]+\@[^ ]+)[ >)].*/$1/;
> $_ =~ s/From: //;
> 
> There's got to be a better way.

perlfaq9:  "How do I check a valid mail address?"  says this:

<QUOTE>
Many are tempted to try to eliminate many frequently-invalid mail 
addresses with a simple regexp, such as /^[\w.-]+\@([\w.-]\.)+\w+$/. 
It's a very bad idea. However, this also throws out many valid ones, and 
says nothing about potential deliverability, so is not suggested.
</QUOTE>

Personally, I think a reasonable regex covers most of the real-life 
cases just fine.  But the FAQ says "It's a very bad idea."  You pays yer 
money and you takes yer choice.
 
-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 2 Feb 1999 07:32:58 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: reused functions.
Message-Id: <MPG.1120ba83b7e5eb239899f4@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <Pine.HPP.3.96.990202154133.11239D-
100000@tlhuph48.elex.co.il> on Tue, 2 Feb 1999 13:47:08 GMT, SHILUV 
Ishay Azoulay 2801 <ishay@cpm.elex.co.il> says...
 ...
> I need help on reused functions.
> Few functions are used many times in many script.
> How do I reuse these functions without copying
> their code everywhere.

Put them into a file, say 'common.pl', then use:

   require 'common.pl';

to include them in each program where you want them.  End the file with

   1;

to indicate success of the 'require'.

> =F8=A4=BA=B0`=B0=BA=A4=F8,=B8=B8,=F8=A4=BA=B0`=B0=BA=A4=F8,=B8=F8=A4=BA=B0`=
> =B0=BA=A4=F8,=B8=B8,=F8=A4=BA=B0`=B0
> 
>     Regards,    Ishay
>     Phone   :           2801  08-9134734
>     Mail_to : ishay.azoulay@telrad.co.il
> 
> =F8=A4=BA=B0`=B0=BA=A4=F8,=B8=B8,=F8=A4=BA=B0`=B0=BA=A4=F8,=B8=B8,=F8=A4=BA=
> =B0`=B0=BA=A4=F8,=B8,=F8=A4=BA=B0`

What the heck is all that line noise?  Use a simple standard .sig:  
start with a string "-- \n" (see below) and keep it to four or fewer 
lines.

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


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

Date: Tue, 2 Feb 1999 15:33:06 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: reused functions.
Message-Id: <F6J9v7.990@world.std.com>

SHILUV Ishay Azoulay 2801 <ishay@cpm.elex.co.il> writes:

>Few functions are used many times in many script.
>How do I reuse these functions without copying
>their code everywhere.

This is what libraries and modules are for. Take a group of
subroutines that logically (thinking-wise, not mathematically) belong
together and decide a name for them. Then run the command 
"h2xs -AX -n ModuleName" create the template of the module. (But
replacing ModuleName with the name you wish to give the module) Next
put the modules subroutines in this file. Finally decide which
subroutines you want to automatically appear (export into the caller's
package) and which you want to appear only on request. For the
subroutines that you want to appear automatically, put their names in
the @EXPORT array created for you in the template. The others put in
the @EXPORT_OK array. For subroutines that you don't need called
directly, but are used by the subroutines that are called don't put
them anywhere.

Then to make these subroutines available to you're script, say:

    use ModuleName;

To get the automatically exported routines or 

    use ModuleName qw(sub1 sub2 sub3);

To get only the three named subroutines. (Again, replace ModuleName
with you're name for the module, and this time replace "sub1", "sub2",
and "sub3" with the names of your subroutines. And please, please,
please, choose better names for your subroutines than sub1, sub2, and
sub3.)

The man pages perlmod and perlmodlib are a little hairy at times, but
you might want to take a look at them and grasp whatever you can.

If you don't have permission to modify perl's directories, take a look
at the FAQ entry "How do I keep my own module/library directory?" in
perlfaq8.
-- 
Andrew Langmead


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

Date: Tue, 2 Feb 1999 11:17:17 -0500 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Soft reference question
Message-Id: <x3yhft4n5ki.fsf@tigre.matrox.com>


louie@visca.com (Louie) writes:

> my $upload = $q->param('upload');

[snip]

> open (UPLOAD, ">$updir") or die $!;
> my ($Buffer);
> while (read($upload,$Buffer,8192)) {
             ^^^^^^^^^

Your bug is here .. the first argument for read is a filehandle. You
are using a variable. Although it is possible to use a variable as a
filehandle, strict will not allow you to do that. Anyway, your script
does not work even if you don't use strict because the read will fail.

perldoc -f read

> understand where my soft reference is in this script. (The error
> message says "line 20", which is the "close UPLOAD or die $!;" line.)

That number is not necessarily the correct line number. In addition,
you should check a few lines before the reported number to exactly
find the location of the problem.

> Thank-you
> Lou Hevly
> http://www.visca.com

Welcome,
Ala



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

Date: Tue, 02 Feb 1999 14:38:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <36b70dc3.326584@news.skynet.be>

Greg Bacon wrote:

>OCR      orig /  body  Posts  Address

>0.964  ( 32.9 / 34.1)     54  abigail@fnx.com

No way that Abigail has a 96.4% OCR. 20% would be more like it.

But, I think I'm having a Dija Vue.

	Bart.


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

Date: 2 Feb 1999 17:07:50 GMT
From: "Vasco Patrmcio" <vpatricio@abrantina.pt>
Subject: Re: submit a form and Perl question
Message-Id: <01be4ece$d4f04c20$3f0a0a0a@vpatricio2>

> Is it possible to submit the form content by clicking on a
> simple HTML link ?
> (NOT a classic input submit button)

Yes, but all the data you submit must be static, that is, must be
explicited on the HTML page and cannot vary.

For example:

<a
href="http://www.yourserver/yourcgi-bindir/diropen.cgi?dir=images/">OpenDire
ctoryLabel</a>

Of course, you cannot alter the value of 'dir' dinamically.

>V<


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

Date: Tue, 02 Feb 1999 10:55:23 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: substituting keywords in a string
Message-Id: <alecler-0202991055230001@dialup-646.hip.cam.org>

In article <ebohlmanF6IJ22.3y9@netcom.com>, Eric Bohlman
<ebohlman@netcom.com> wrote:

[...]
> Your problem is that after you do a substitution, you rescan the 
> (now-transformed) string from the beginning, thus matching text that was 
> already substituted.
> 
> What you need to do is harness the power of regexps to do your 
> substitutions in parallel rather than in series:
> 
> @keyword = ("to", "be","or");
> $kwstring = join('|',@keyword);
> 
> $string = "To be or not to be, that is the question";
> $string =~ s/($kwstring)/<font color=darkred>$1<\/font>/gi;
> print $string;

Exactly right. May I suggest a variation? (Thanx Abigail.)

   @keywords = ('to', 'be', 'or');

   { local $" = '|';
     $string =~ s/(@keywords)/<font color="darkred">$1<\/font>/gi;
   }

Safer:

   { local $" = '|';
     $string =~ s[(@{[ map {quotemeta} @keywords ]})]
                 [<font color="darkred">$1</font>]gi;
   }

Andre


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

Date: Tue, 02 Feb 1999 16:10:21 GMT
From: Don.Carlton@Citadel.edu
Subject: Re: UNC-Path under windows NT ?
Message-Id: <797814$9fo$1@nnrp1.dejanews.com>

I believe the problem is that after the first line $ggg contains
"\\hal\change" when your opendir command is called it ends up trying to open
\hal\change and this is of course not what you want. I would use forward
slashes instead: $ggg = "//hal/change"; In article
<794do5$ac1$1@black.rmc.de>,  "Christian Pothmann" <Pothmann@liquidvision.de>
wrote:

> Hi,
> how can I access UNC-Paths like: (doesn't work)
>
> $ggg = "\\\\hal\\change";
> opendir(DIR, $ggg);
> @cfiles=readdir(DIR);
> close(DIR);
> print "Inhalt: @cfiles";
>
> Thank you !
>
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 02 Feb 1999 10:14:26 -0600
From: Sven Davies <svend@lubypublishing.com>
Subject: Re: Visual Perl?
Message-Id: <36B72461.5CFF@lubypublishing.com>

Charles R. Thompson wrote:
> 
> >>Yeah, this reminds me of a popular program called GirlFriend
> 1.0. It
> >>doesn't always know what you want either.  But then again, I
> don't think
> >>it is a Perl Script.
> >
> >My license expired :(
> 
> Hmm.. obviously, you didn't agree with the licensing terms. Too
> bad MS didn't make Girlfriend, or you could get your money back.
> :)

If Microsoft made GirlFriend, it would be huge and require all my
resources just to run.  I much prefer the optimized UNIX version of
Girlfriend.  It multi-tasks better.

YoUrs,
-- 
========================================================
Sven T. Davies			http://www.lubypublishing.com  | 
On-Line Coordinator		http://www.billiardsdigest.com |	
Luby Publishing			http://www.bowlersjournal.com  |	
========================================================


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4806
**************************************

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