[17474] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4894 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 15 14:06:03 2000

Date: Wed, 15 Nov 2000 11:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974315112-v9-i4894@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 15 Nov 2000     Volume: 9 Number: 4894

Today's topics:
    Re: "chown" of symlink instead of linked file <khera@kciLink.com>
        Apache denies to start a Perl CGI <sburkhardt@debis.de>
        Apache denies to start a Perl CGI <sburkhardt@debis.de>
    Re: Apache denies to start a Perl CGI (Rafael Garcia-Suarez)
        Can Perl do this?: <dvbryan@_nospamplsHotmail.com>
    Re: Can Perl do this?: (Michel Dalle)
    Re: Can Perl do this?: <jboes@eomonitor.com>
    Re: Can Perl do this?: <dvbryan@_nospamplsHotmail.com>
    Re: compiling/securing Perl code <jimNOSPAM@gosquad.com>
        cookies fetch returns an empty hash <eugene@sanet.ge>
    Re: cookies fetch returns an empty hash (Rafael Garcia-Suarez)
        cpan.org Changed (BUCK NAKED1)
    Re: Date <dave@dave.org.uk>
    Re: Delete empty directories <bart.lateur@skynet.be>
        Duplicate Records <ts012@my-deja.com>
        gui based debuggers for perl on windows <rajkumar@hotmail.com>
    Re: Hash assignments in loops? <guido@ldv.uni-trier.de>
    Re: How to connect a Perl script with VNC viewer/system <linux@wizdom.org.uk>
        how would you know the no of people accessing a perl fi (remove this part)
    Re: how would you know the no of people accessing a per <jeff@vpservices.com>
    Re: I need a fork example, please (Peter Scott)
        Line Editing vignolap@my-deja.com
    Re: Line Editing <josef.moellers@fujitsu-siemens.com>
    Re: Line Editing nobull@mail.com
    Re: Lizard gone? <jboes@eomonitor.com>
    Re: Mail <jboes@eomonitor.com>
    Re: Newbee question, help wanted ! <rvbeek@usa.net>
        Parallel Print status lines <bcant@dpml-uk.com>
        pattern match, file open max size pygkpygk@my-deja.com
        PERL/shell: batch renaming of files <exet0964@sable.ox.ac.uk>
    Re: PERL/shell: batch renaming of files <dave@dave.org.uk>
    Re: Please tell me why this code is wrong (ActiveState  (Garry Williams)
    Re: Problems compiling DBI and HP-UX 11.0 fharris@xmission.com
    Re: Q: Getting program line number? (Martien Verbruggen)
        question about reusing a variable from a regex <w.berg@NOSPAMPLEASEsamsom.nl>
    Re: question about reusing a variable from a regex (Randal L. Schwartz)
    Re: question about reusing a variable from a regex <bart.lateur@skynet.be>
    Re: question about reusing a variable from a regex <vandenb@NO.SPAMcistron.nl>
    Re: Regex to zero pad an IP address <tim@ipac.caltech.edu>
    Re: Regex to zero pad an IP address <neutron@jackbert.fc.hp.com>
    Re: Removing New Page character from a text file <kilminjaroNOSPAM@hotmail.com>
    Re: Removing New Page character from a text file <kilminjaroNOSPAM@hotmail.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 15 Nov 2000 10:40:44 -0500
From: Vivek Khera <khera@kciLink.com>
Subject: Re: "chown" of symlink instead of linked file
Message-Id: <x7vgtpz1j7.fsf@onceler.kciLink.com>

>>>>> "OW" == Otto Wyss <otto.wyss@bluewin.ch> writes:

OW> If I use "chown" specifying a symlink the owner of the linked file is
OW> changed. Is there a switch or an option I could use, so  that the owner
OW> of the symlink itself is changed? Or is there anything so the owner of

On some systems, symlinks don't have their own "owner" but are part of
the directory and thus the owner is the same as the owner of the
directory.  In reality, changing the owner of a symlink does you very
little good.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-240-453-8497
AIM: vivekkhera Y!: vivek_khera   http://www.khera.org/~vivek/


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

Date: Wed, 15 Nov 2000 16:20:12 +0100
From: Stephan Burkhardt <sburkhardt@debis.de>
Subject: Apache denies to start a Perl CGI
Message-Id: <3A12A9AC.6334B138@debis.de>

Hi all,

in an Apache installation I've got a weird problem:
It does not start a Perl CGI and I get the error
message

The requested method POST is not allowed for the URL <The .pl's URL>

Is it necessary to register all allowed CGI subdirectories 
to Apache ('cause the URL where my Perl script lies is not
under the /cgi-bin regularly used, but in another subtree;
the path is explicitly given)

thanks for a helpful hint

greetings from Stephan, Fellbach, Germany

-- 
     
                                 '''
                                (0 0)
                   +------oOO----(_)--------------+
                   |       Stephan Burkhardt      |
                   |      sburkhardt@debis.de     |
                   |     TEL: +49-711-17-49457    |
                   |   FAX: +49-711-17-790-49457  |
                   +-------------------oOO--------+
                               |__|__|
                                || ||
                               ooO Ooo


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

Date: Wed, 15 Nov 2000 16:20:18 +0100
From: Stephan Burkhardt <sburkhardt@debis.de>
Subject: Apache denies to start a Perl CGI
Message-Id: <3A12A9B2.E889FFB0@debis.de>

Hi all,

in an Apache installation I've got a weird problem:
It does not start a Perl CGI and I get the error
message

The requested method POST is not allowed for the URL <The .pl's URL>

Is it necessary to register all allowed CGI subdirectories 
to Apache ('cause the URL where my Perl script lies is not
under the /cgi-bin regularly used, but in another subtree;
the path is explicitly given)

thanks for a helpful hint

greetings from Stephan, Fellbach, Germany

-- 
     
                                 '''
                                (0 0)
                   +------oOO----(_)--------------+
                   |       Stephan Burkhardt      |
                   |      sburkhardt@debis.de     |
                   |     TEL: +49-711-17-49457    |
                   |   FAX: +49-711-17-790-49457  |
                   +-------------------oOO--------+
                               |__|__|
                                || ||
                               ooO Ooo


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

Date: Wed, 15 Nov 2000 15:29:25 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Apache denies to start a Perl CGI
Message-Id: <slrn915euc.11q.rgarciasuarez@rafael.kazibao.net>

Stephan Burkhardt wrote in comp.lang.perl.misc:
>Hi all,
>
>in an Apache installation I've got a weird problem:
>It does not start a Perl CGI and I get the error
>message
>
>The requested method POST is not allowed for the URL <The .pl's URL>
>
>Is it necessary to register all allowed CGI subdirectories 
>to Apache ('cause the URL where my Perl script lies is not
>under the /cgi-bin regularly used, but in another subtree;
>the path is explicitly given)

Obviously you'll prefer to ask this question in
comp.infosystems.www.servers.unix. (followups set). From
what you describe, it looks like apache tries to serve the
CGI program as a document and not to execute it. Try to access
it with the GET method to see what is does. And post this
complement of information in the right newsgroup.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 15 Nov 2000 15:08:42 -0000
From: "D.B" <dvbryan@_nospamplsHotmail.com>
Subject: Can Perl do this?:
Message-Id: <fDxQ5.9059$Ry5.1163693@news3.cableinet.net>

Check if a file called datafile.txt exists in a particular directory
If the datafile.txt does not exist, create it
Process form data passed from html and then append processed output to this
file
At 7am each day check if the above datafile.txt has something in it
If the datafile.txt has content, email as an attachment to xxx@domain.co.uk
Once attachment has been sent, reset the file to have no content (?touch
datafile.txt).OR rename datafile.txt to datafileold.txt.

Can the above be done in one script easily?!




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

Date: Wed, 15 Nov 2000 15:21:43 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Can Perl do this?:
Message-Id: <8uu9qj$jok$1@news.mch.sbs.de>

In article <fDxQ5.9059$Ry5.1163693@news3.cableinet.net>, "D.B" <dvbryan@_nospamplsHotmail.com> wrote:
>Check if a file called datafile.txt exists in a particular directory
>If the datafile.txt does not exist, create it
>Process form data passed from html and then append processed output to this
>file
>At 7am each day check if the above datafile.txt has something in it
>If the datafile.txt has content, email as an attachment to xxx@domain.co.uk
>Once attachment has been sent, reset the file to have no content (?touch
>datafile.txt).OR rename datafile.txt to datafileold.txt.
>
>Can the above be done in one script easily?!

Yes and no. You have two different kinds of events here - people
posting data via web to a CGI script whenever they feel like it, and
some recurring event at 7am each day.

Both can be handled in Perl, but unless you're sure you'll always get
plenty of posts per hour, you can't rely on that to trigger the daily event.
In your case, one could be a CGI script, and the other some script
launched by cron (or AT).

HTH,

Michel.


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

Date: Wed, 15 Nov 2000 11:29:29 -0500
From: Jeff Boes <jboes@eomonitor.com>
Subject: Re: Can Perl do this?:
Message-Id: <3a12ba09$0$35021$44a10c7e@news.net-link.net>

"D.B" wrote:
> 
> Check if a file called datafile.txt exists in a particular directory

perldoc -f -X

> If the datafile.txt does not exist, create it

perldoc -f open

> Process form data passed from html and then append processed output to this
> file

perldoc CGI

> At 7am each day check if the above datafile.txt has something in it

There's no way to get Perl by itself to run at a scheduled time (at
least, no OS-independent way). You'll need to tell us under what OS you
intend to run this. If it's a Unix-like OS, then read up on cron. You
may have to talk to a sysadmin to get this set up for you.

> If the datafile.txt has content, email as an attachment to xxx@domain.co.uk
> Once attachment has been sent, reset the file to have no content (?touch
> datafile.txt).OR rename datafile.txt to datafileold.txt.

perldoc -q 'send mail'


> Can the above be done in one script easily?!

Almost all of it could be handled in Perl. There's no real reason to put
the CGI interfacing stuff in with the 7am stuff, though. I'd write it as
two separate scripts.

-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Wed, 15 Nov 2000 17:11:38 -0000
From: "D.B" <dvbryan@_nospamplsHotmail.com>
Subject: Re: Can Perl do this?:
Message-Id: <vqzQ5.9284$Ry5.1196914@news3.cableinet.net>

Thanks for the responses,

I think you've got a point about using 2 separate processes to mange this :)

Regards

D.B




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

Date: Wed, 15 Nov 2000 18:43:31 GMT
From: "Jim" <jimNOSPAM@gosquad.com>
Subject: Re: compiling/securing Perl code
Message-Id: <nPAQ5.63450$n9.1545773@news2.rdc1.on.home.com>


 Hi all,

  To state my problem directly, I need to distribute a large perl-based web
 application in a secure way.  I'm sure this topic has been discussed
before,
 and from the text and discussions I've read on compiling the source, the
 answer is always 'Why would you want to do that?' or 'Try perlcc, but if it
 doesn't work, don't complain' ;)  Is anyone using a practical method of
 securing their perl code?  I basically have two requirements:

 1) Must still be relatively fast (memory resident - FCGI, mod_perl?)
 2) Must be a stable solution (perlcc seems to be out here)
 3) Code must not be easily viewable (encrypted, compiled w/ another
method?)

  Ok, that's three.  Anyway, the ideal goal is to transport the code via
 physical media or over the Internet with no worries.  Are there any perl
 licensing issues that I should be aware of?





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

Date: Wed, 15 Nov 2000 15:43:40 GMT
From: Eugene Vekua <eugene@sanet.ge>
Subject: cookies fetch returns an empty hash
Message-Id: <8uuav9$9sd$1@nnrp1.deja.com>



Hi, I am trying something pretty simple:

%cookies = fetch CGI::Cookie;

but in result I am getting an empty hash - scalar keys %cookies shows 0
hash members.

This is my first experience with cookies. So I am doing according docs
(I think). Thanks for any suggestion how to fix this,
Eugene.


--
--------------
Eugene Vekua -- SANET
http://georgia.net.ge/evhome


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 15 Nov 2000 16:57:26 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: cookies fetch returns an empty hash
Message-Id: <slrn915g4i.1cm.rgarciasuarez@rafael.kazibao.net>

Eugene Vekua wrote in comp.lang.perl.misc:
>
>
>Hi, I am trying something pretty simple:
>
>%cookies = fetch CGI::Cookie;
>
>but in result I am getting an empty hash - scalar keys %cookies shows 0
>hash members.

Are there any cookies transmitted in the request ? You can check this by
examining the contents of $ENV{'HTTP_COOKIE'}. If it's empty, the
problem is with the code that sets the cookies.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 15 Nov 2000 11:30:55 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: cpan.org Changed
Message-Id: <14744-3A12C84F-3@storefull-242.iap.bryant.webtv.net>

I had just become familiar with using CPAN's main page. A few weeks ago,
http://cpan.org changed. I now find things missing that were there
before, and it's now more difficult to navigate. Why the changes? 

Regards,
Dennis



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

Date: Wed, 15 Nov 2000 14:16:31 -0000
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: Date
Message-Id: <8uu5tu$caf$1@taliesin.netcom.net.uk>

<ameen @ dausha . net (Ameen Dausha)> wrote in message
news:3a127a51.51301822@news...
> On Wed, 15 Nov 2000 09:27:57 -0000, "Dave Cross" <dave@dave.org.uk>
> spat:
>
> >
> ><ameen @ dausha . net (Ameen Dausha)> wrote in message
> >news:3a11f48e.17053769@news...
> >> On 15 Nov 2000 00:53:46 GMT, jobbey83@aol.com (JOBBEY83) spat:
> >>
> >> >Hi, I am a total newbie and I am wondering how I can calculate the
> >current date
> >> >mm/dd/yy. If it involves installing a module could you please direct
me
> >on how
> >> >to do so?
> >>
> >> The CPAN Module "Date::Manip" is plenty powerful.
> >
> >Perhaps a little _too_ powerful for a task like this which can be
> >accomplished very easily with localtime.
>
> Yes, buy with localtime don't you need to incriment the month and day?
> Don't you need to handle the fact that this is Perl Year 100? Granted,
> that can be handled by adding a few lines of code, but:
>
> use Date::Manip;
>
> $today = &DateCalc("today", "%m/%d/%y");

Let's see what the author Date::Manip has to say on the subject (from
perldoc Date::Manip):

"Is Date::Manip the one you should be using? In my opinion, the answer is no
about 90% of the time."

Let's see how really difficult it is with localtime:

my @now = (localtime)[3 .. 5];
my $date = sprintf('%02d/%02d%0d2', ++$now[2], $now[1], $now[3] % 100);

Doesn't look that tricky to me.

I've benchmarked similar solutions, comparing localtime with Date::Manip and
have found the localtime solution to be up to 30 times faster.

hth,

Dave...





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

Date: Wed, 15 Nov 2000 14:17:21 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Delete empty directories
Message-Id: <3j651t01p8om8t36gvas5t9c5k4aiao7ps@4ax.com>

Bart Lateur wrote:

>   Recursively scan through a directory tree (using File::Find), and
>   delete all subdirectories that contain no files, but only empty
>   subdirectories.

I think I wasn't clear enough in my description. If a directory /a/b
only contains empty subdirectories /a/b/c and /a/b/d, then all three
should be removed. File::Find traverses top-down, first it visits /a/b
and only then /a/b/c etc. But deleting directories must happen
bottom-up, deepest directory first.

-- 
	Bart.


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

Date: Wed, 15 Nov 2000 18:38:35 GMT
From: Perry <ts012@my-deja.com>
Subject: Duplicate Records
Message-Id: <8uul7b$jga$1@nnrp1.deja.com>

Before I delve into my question, I wanted to state what my experience
level is with Perl:  Beginner.  With that said, here is my problem.
I'm parsing a log file on a Solaris 2.6 box which is just a plain text
file.  I'm looking for a specific string and if found, I write it to a
list.  The problem is that there can be multiple copies of the same
string and I only want to output it once.  The following is the code
that I'm currently using, which does nothing about duplicate records,
that outputs the strings that are found:

Prior to this section of code, I open an INPUT and OUTPUT file, then,

foreach $line (<INPUT>) {
   if (index($line, "Message rejected,") >= 0) {
      $reject = (substr($line, 84));
      @rejectedservice = $reject;
      print OUTPUT ("@rejectedservice\n");
   }
}

I then close the INPUT and OUTPUT files.  I re-open the file just
created and as long as it's not empty, I send it as the body of an
email message and then close it again.

I do relaize that the above code could be written using "shorthand"
(and probably more efficiently), but I'll continue to use
the "longhand" version until I become more familiar with Perl.

A snippet of the INPUT file that contains what I'm searching for is as
follows:

2000/11/15 11:04:46>Event [21]Alert completed (8267), Status: [86]
Message rejected, service_name:pin_number

The OUTPUT file looks like the following:

service1:1111111
service2:2222222
service1:1111111
service3:3333333
service3:3333333
service1:1111111

And I want it to look like this:

service1:1111111
service2:2222222
service3:3333333

Please note that it does not matter if it is sorted or not.

I appreciate any and all help.


Thanks!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 15 Nov 2000 15:30:56 GMT
From: "Rajkumar" <rajkumar@hotmail.com>
Subject: gui based debuggers for perl on windows
Message-Id: <Q_xQ5.191$BN.79299@paloalto-snr1.gtei.net>

hey all

Are there any freeware gui based debuggers for perl on windows ? If so could
could
you tell where i can download them

thanks
raj




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

Date: Wed, 15 Nov 2000 17:45:56 +0100
From: "Guido" <guido@ldv.uni-trier.de>
Subject: Re: Hash assignments in loops?
Message-Id: <8uuer1$335fu$2@fu-berlin.de>

And here a funny joke of cpan-perl ..

If I tried this following code:


> my %fruit_preference;
> for (@file_contents)
> {
>     my ($fruit,$person) split/,/,$_;
>     $fruit_preference{$person} = $fruit;
> }

Perl makes really bullshit, but If change $person and $fruit
($fruit_preference{$fruit}=$person), it will work fine.

Any Idea??

PS: Active-State Perl under Windows worked in both ways ...







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

Date: Wed, 15 Nov 2000 14:28:22 +0000
From: Mark Worsdall <linux@wizdom.org.uk>
Subject: Re: How to connect a Perl script with VNC viewer/system call
Message-Id: <x09AajAG2pE6Ewko@worsdall.demon.co.uk>

In article <8ujok7$3js$1@nnrp1.deja.com>, monkfunk@my-deja.com writes
>I'm writing a VNC frontend to resolve machine names to IP address with
>'nmblookup' so we can VNC to a machine name.
>
>I need a one-liner system call to give the IP address & the password
>
>system('echo password|vncviewer 172.168.0.1')

system('/bin/echo', 'password|vncviewer', '172.168.0.1')


-- 
He came from Econet - Oh no, I've run out of underpants :(
Home:- jaydee@wizdom.org.uk       http://www.wizdom.org.uk
Shadow:- webmaster@shadow.org.uk  http://www.shadow.org.uk
Work:- netman@hinwick.demon.co.uk http://www.hinwick.demon.co.uk


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

Date: Wed, 15 Nov 2000 23:06:49 +0800
From: I'm a good man <"goodman888"@hongkong.com(remove this part)>
Subject: how would you know the no of people accessing a perl file?
Message-Id: <8uu8kg$jio$1@hfc.pacific.net.hk>


how can you know the no. of people reading a particular page?
or the no. of visitors in your site at a particular moment?

is that possible with perl?

thanks a lot.

--
Regards,
Fung                       "http://i.am/goodman888/"




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

Date: Wed, 15 Nov 2000 08:29:57 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: how would you know the no of people accessing a perl file?
Message-Id: <3A12BA05.DE91C014@vpservices.com>

I'm a good man wrote:
> 
> how can you know the no. of people reading a particular page?
> or the no. of visitors in your site at a particular moment?
> 

Dress your self up in a page costume.  Install yourself on the server. 
Count off on your fingers and toes every time someone hits you.  When
you run out of fingers and toes (usually somewhere around hit number
20), just make up a large number.

> is that possible with perl?

You could write the entire web with perl.  But since someone has
apparantly already done that, it may be easier to just use one of the
many web-log readers to display statistics from your web server logs
which (should) automatically track every access to your site.

-- 
Jeff


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

Date: Wed, 15 Nov 2000 18:24:04 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: I need a fork example, please
Message-Id: <8xAQ5.7647$3j.3111666@news1.gvcl1.bc.home.com>

[comp.lang.perl removed from followups]

In article <JGsQ5.8070$46.518798@typhoon1.ba-dsg.net>,
 Alex Hart <news@#nospam#althepal.com> writes:
>I've read what I can on forks, but everyone assumes I've used them
>before with C, or something.  But I haven't.
>
>I want to fork off a process, run a function, then die.  Basically, I
>have a user interface that I want to keep going, but I want to talk to a
>server in the background, without having to wait for the server's
>response.
>
>I imaging its something like this :
>
>sub ServerTalk {
> blah ...
>}
>
>fork and ServerTalk() and die;

fork() returns a true value to the parent, not the child.
die() will cause a message to go to STDERR which you probably don't want.
Use exit().  Also, this idiom assumes that ServerTalk() returns a true value,
and there's no reason it should have that constraint.  Finally, fork() might
return undef if it was unsuccessful, in which case you do want to die unless
the condition was something that might repair itself.

Hence (untested):

use Errno;
while (1) {
  last if my $pid = fork;
  if (defined $pid) {
    ServerTalk();
    exit;
  }
  elsif $!{EAGAIN} {
    sleep 5;   # Give it another chance to find a process slot
  }
  else {
    die "Couldn't fork: $!\n";
  }
}

>print " talking to the server right now".
>
>Will this work. Is fork what I need to do this?

Close, and yes.  Read what perldoc -f fork has to say about buffer flushing.
You probably also want

 local $SIG{CHLD} = 'IGNORE';
 
in the right place, but you should understand the related issues of child processes
on your operating system first.  perldoc perlipc for starters.

-- 
Peter Scott


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

Date: Wed, 15 Nov 2000 15:33:59 GMT
From: vignolap@my-deja.com
Subject: Line Editing
Message-Id: <8uuad7$98b$1@nnrp1.deja.com>

This seems simple, but I am being rushed

I want to go through a file containing entries like the following:

Mailbox,YYY,/o=company/ou=organization/cn=Recipients/cn=Employees/cn=YYY
,,CHIMSG1

and create a new file consisting of entries like this one.

YYY:                                YYY@CHIMSG2.xxx.COM

How do I go about it?


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 15 Nov 2000 16:53:24 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Line Editing
Message-Id: <3A12B174.FBF4CB0D@fujitsu-siemens.com>

vignolap@my-deja.com wrote:
> =

> This seems simple, but I am being rushed
> =

> I want to go through a file containing entries like the following:
> =

> Mailbox,YYY,/o=3Dcompany/ou=3Dorganization/cn=3DRecipients/cn=3DEmploye=
es/cn=3DYYY
> ,,CHIMSG1
> =

> and create a new file consisting of entries like this one.
> =

> YYY:                                YYY@CHIMSG2.xxx.COM
> =

> How do I go about it?

Each source line has the following structure:
Fields separated by commas (hint: split /,/)
The third field has the following structure:
Fields separated by slashes (hint: split /\//)
Thn each field has the following structure:
Two fields separated by equals signs (hint: split /=3D/)

We now know the structure of the data, the program itself is left as an
exercise for the reader.

Hope this helps,

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)


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

Date: 15 Nov 2000 18:15:16 +0000
From: nobull@mail.com
Subject: Re: Line Editing
Message-Id: <u97l65m79n.fsf@wcl-l.bham.ac.uk>

vignolap@my-deja.com writes:

> This seems simple, but I am being rushed
> 
> I want to go through a file containing entries like the following:
> 
> Mailbox,YYY,/o=company/ou=organization/cn=Recipients/cn=Employees/cn=YYY
> ,,CHIMSG1
> 
> and create a new file consisting of entries like this one.
> 
> YYY:                                YYY@CHIMSG2.xxx.COM
> 
> How do I go about it?

I'd probably just use a s///.

First you have to define the problem better.  Your definition is
woefully inadequate.

How about:

s/^Mailbox,(.*?),.*\/cn=(.*?),,(.*)$/$1:       $2\@$3.xxx.COM/;

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 15 Nov 2000 10:27:37 -0500
From: Jeff Boes <jboes@eomonitor.com>
Subject: Re: Lizard gone?
Message-Id: <3a12abfa$0$35021$44a10c7e@news.net-link.net>

"Godzilla!" wrote:

> Snow skiing season has finally arrived.
> Shirley you wouldn't expect me to hang
> around with you Techno-Geeksters rather
> than extreme ski with my Little Lizard.

Excellent! Enjoy, and here's hoping you can retire soon to a climate
which features year-round skiing! 

-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Wed, 15 Nov 2000 10:34:20 -0500
From: Jeff Boes <jboes@eomonitor.com>
Subject: Re: Mail
Message-Id: <3a12ae51$0$35017$44a10c7e@news.net-link.net>

Mike Mesarch wrote:
> 
> Can someone provide me with some code to send a mail message in perl.
> Typically I don't ask for something like this, but I have searched to no
> avail on how to do this.  In the doco it suggests using sendmail
> Mail:Mailer.  All i want to do is connect to a mail server
> (smtp.something.com) and send a message.  I haven't seen anything to do
> this.

Then you haven't really looked:

perldoc -q 'send mail'

-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Wed, 15 Nov 2000 16:37:36 +0100
From: "Ray" <rvbeek@usa.net>
Subject: Re: Newbee question, help wanted !
Message-Id: <8uuags$ffk$1@porthos.nl.uu.net>

Found it! At least, a part of it.

I started with this construction, which, clearly, didn't work

( $firstref , $remref ) = split(/ /, $refs, 2);

I tried the non-browser debug, but the output was the same, so Martien's
suggestion (browser removed tagged strings) did not prove.

But I trial-and-error-ed some changes and

($firstref , $remref ) = split(' ', $refs, 2);

resulted in the correct output.

------

By the way Martien, kom jij van oorsprong uit Nederland?

Sorry, couldn't resist it.

Thanks guys for all the help!

Ray.




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

Date: Wed, 15 Nov 2000 15:56:32 +0000
From: Benjamin Cant <bcant@dpml-uk.com>
Subject: Parallel Print status lines
Message-Id: <3A12B230.B1D737FF@dpml-uk.com>

Hi,

Does anyone know how to get print status bytes from the parallel port in
perl.
I assume a do some sort of IOCTL on the port.

Thanks, Bean.



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

Date: Wed, 15 Nov 2000 16:01:36 GMT
From: pygkpygk@my-deja.com
Subject: pattern match, file open max size
Message-Id: <8uuc0p$atd$1@nnrp1.deja.com>

Hello,

I need help on 2 items:

1.  How do I find a pattern that is like "\|"
embedded in a ascii file?(not individual
characters but 2 or more characters that are next
to each other)

2. What is the maximum size of a file that I can
open in perl using the open syntax especially on
AIX?

Thanks


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 15 Nov 2000 16:07:38 -0000
From: "Herminio Gonzalez" <exet0964@sable.ox.ac.uk>
Subject: PERL/shell: batch renaming of files
Message-Id: <8uuc85$70h$1@news.ox.ac.uk>

I have a directory tree structure which is about three or four levels deep,
branching about 3 times at each level. I would like to traverse the tree to
the end nodes and look for files that match a certain pattern and rename
them. For instance, I would like all files that match

*_1_QS*
to be renamed to
*_QS_dens1*

this should change the file
this_and_that_1_QS.ext
to
this_and_that_QS_dens1.ext

Would anyone know of a handy way of doing this from a shell script or
through PERL?

Herminio




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

Date: Wed, 15 Nov 2000 17:48:12 -0000
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: PERL/shell: batch renaming of files
Message-Id: <8uuiar$guq$1@taliesin.netcom.net.uk>

Herminio Gonzalez <exet0964@sable.ox.ac.uk> wrote in message
news:8uuc85$70h$1@news.ox.ac.uk...
> I have a directory tree structure which is about three or four levels
deep,
> branching about 3 times at each level. I would like to traverse the tree
to
> the end nodes and look for files that match a certain pattern and rename
> them. For instance, I would like all files that match
>
> *_1_QS*
> to be renamed to
> *_QS_dens1*
>
> this should change the file
> this_and_that_1_QS.ext
> to
> this_and_that_QS_dens1.ext
>
> Would anyone know of a handy way of doing this from a shell script or
> through PERL?

You can do this in Perl using the File::Find module.

hth,

Dave...





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

Date: Wed, 15 Nov 2000 14:40:23 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: Please tell me why this code is wrong (ActiveState build 613 on Winblows)
Message-Id: <rfxQ5.578$xb1.34039@eagle.america.net>

On Wed, 15 Nov 2000 12:32:00 GMT, David Steuber
<nospam@david-steuber.com> wrote:
>garry@ifr.zvolve.net (Garry Williams) writes:
>' In perl 5.6.0, it seems to be the preference to `use warnings;'
>' instead of the -w switch.  Anyway, either one will work on Windows
>' as well as Unix.  
>
>Would it be a bad thing to use both?  I presume they both simply set
>a flag in the compiler to generate the appropriate run time checks.

I would say it's almost like wearing a belt *and* suspenders.  

Here's what perllexwarn says: 

    DESCRIPTION
	 The `use warnings' pragma is a replacement for both the
	 command line flag -w and the equivalent Perl variable,
	 `$^W'.

	 The pragma works just like the existing "strict" pragma.
	 This means that the scope of the warning pragma is limited
	 to the enclosing block. 

I still prefer -w because it applies to everything.  If I use modules
that don't enable warnings explicitly, then use warnings won't affect
them.  I know *I* have a lot of code in libraries that doesn't have
use warnings.  There's lots of code in CPAN that doesn't use warnings.
It's a small exposure, but I've grown accustomed to the -w "safety".  

>I guess I shouldn't presume.  It makes a pre out of u and me.

:-) 

-- 
Garry Williams


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

Date: Wed, 15 Nov 2000 17:09:08 GMT
From: fharris@xmission.com
Subject: Re: Problems compiling DBI and HP-UX 11.0
Message-Id: <3a12c264.1191982430@news.xmission.com>

On Mon, 13 Nov 2000 18:17:45 GMT, fharris@xmission.com (Frank Harris)
wrote:

>I'm having a heck of a time trying to get DBI to compile with my HP-UX
>11 system.  I am guessing that the version of CC on the system isn't
>exactly ANSI compliant, so I went ahead and installed GCC without any
>troubles.  Now I receive this message when I compile DBI using GCC:
>
>/opt/gcc/bin/gcc -c  -Ae -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O
>+Onolimit      -DVERSION=\"1.14\"  -DXS_VERSION=\"1.14\" +z
>-I/opt/perl5/lib/5.6.0/PA-RISC1.1/CORE -DDBI_NO_THREADS Perl.c
>gcc: +Onolimit: No such file or directory
>gcc: +z: No such file or directory
>*Initialization*:1: missing token-sequence in `#assert'
>*** Error exit code 1
>
>Stop.
>
>-----------------------------------------
>Any ideas how to fix this problem?
>

Ok, I fixed my own problem here.  Apparently this problem is related
to the precompiled Perl package (.depot) that I had installed.  This
error went away after I downloaded the Perl 5.6.0 source and compiled
it with gcc.

DBD::Oracle worked after I statically linked it to the Perl
executable, following the instructions in the README file included
with the DBD archive.

Thanks for all your help anyway. :-)

Frank



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

Date: Thu, 16 Nov 2000 01:09:22 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Q: Getting program line number?
Message-Id: <slrn91568i.6sn.mgjv@martien.heliotrope.home>

On 15 Nov 2000 06:35:31 -0700,
	Tom Christiansen <tchrist@perl.com> wrote:
> In article <8FE866D90quuxi@194.203.134.135>, someone who lacks the
> personal responsibility to use his own address wrote:
> 
>>It's a backronym then (as defined in the Jargon file)
> 
> You mean "retronym".  Although one might argue that mixing Latin

Backronym is actually defined in the jargon file, even though none of my
other dictionaries have a reference to it.

> into a third genome to make these grow twining and blinking out of
> a lion's mane to produce a brand new frankenspecies, perhaps something
> like a "felix lucileguminosus" :-)

That invokes visuals that are almost exactly, but not entirely, quite
like migraines.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's not a lie, it's a
Commercial Dynamics Pty. Ltd.   | terminological inexactitude.
NSW, Australia                  | 


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

Date: Wed, 15 Nov 2000 16:58:27 +0100
From: "Walter van den Berg" <w.berg@NOSPAMPLEASEsamsom.nl>
Subject: question about reusing a variable from a regex
Message-Id: <8uubrq$2fl$1@zonnetje.nl.uu.net>

Hi group,

I wanted to know how I can reuse a variable that's been read in a regex.

This line changes a string (puts something in between):
s/<RD:$level>(.*?)</<RD:$level><gr:$1>$1</oig;

and this wasn't the hard part, could've done this with a texteditor, but now
I want to reuse $1 in a next regex, like:

s/<RD>/<RD><gr:$1>/oig;

But that doesn't work. Can you tell me how I put $1 into $variable so I can
reuse it?
I've already tried
s/<RD:$level>(.*?)</<RD:$level><gr:($variable = $1)>$1</oig;
and similar things.

Thank you for your time.
Walter.





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

Date: 15 Nov 2000 08:07:12 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: question about reusing a variable from a regex
Message-Id: <m18zqlrzgv.fsf@halfdome.holdit.com>

>>>>> "Walter" == Walter van den Berg <w.berg@NOSPAMPLEASEsamsom.nl> writes:

Walter> I wanted to know how I can reuse a variable that's been read in a regex.

Walter> This line changes a string (puts something in between):
Walter> s/<RD:$level>(.*?)</<RD:$level><gr:$1>$1</oig;

Walter> and this wasn't the hard part, could've done this with a texteditor, but now
Walter> I want to reuse $1 in a next regex, like:

Walter> s/<RD>/<RD><gr:$1>/oig;

Walter> But that doesn't work. Can you tell me how I put $1 into $variable so I can
Walter> reuse it?

The straightforward way... :)

    $x = $1;
    s/<RD>/<RD><gr:$x>/oig;

And your /o isn't doing anything there.  Please remove it.  Cargo-cult-ist!

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 15 Nov 2000 16:30:01 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: question about reusing a variable from a regex
Message-Id: <96e51tg4d6gr2kc449cj3kn1mjhfrushp1@4ax.com>

Walter van den Berg wrote:

>s/<RD:$level>(.*?)</<RD:$level><gr:$1>$1</oig;
>
>and this wasn't the hard part, could've done this with a texteditor, but now
>I want to reuse $1 in a next regex, like:
>
>s/<RD>/<RD><gr:$1>/oig;

Urm, I'm sorry but I think you cannot do that, because of the /g
modifier. Afterwards, $1 will be the last thing matched.

	$_ = '<A>alpha</A><B>beta</B>';
	s:<(\w)>(.*?)</\1>:<FOO code="$1" contents="$2">:g;
	$\ = "\n";
	print;
	print $2;
-->
	<FOO code="A" contents="alpha"><FOO code="B" contents="beta">
	beta

The "alpha" (the match the first time around) is gone forever.

If that's what you want, well OK, assign $1 to a private variable
outside the s/// expression. Er... Randal showed that already.

-- 
	Bart.


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

Date: Wed, 15 Nov 2000 18:50:18 +0100
From: "Walter van den Berg" <vandenb@NO.SPAMcistron.nl>
Subject: Re: question about reusing a variable from a regex
Message-Id: <8uuib7$3pb$1@faraday.a2000.nl>


"Randal L. Schwartz" <merlyn@stonehenge.com> wrote

> Walter> I wanted to know how I can reuse a variable that's been read in a
regex.
>
> The straightforward way... :)
>
>     $x = $1;
>     s/<RD>/<RD><gr:$x>/oig;

Thanks!

> And your /o isn't doing anything there.  Please remove it.
Cargo-cult-ist!

I was going to mention that: I don't exactly know what it is doing there.
But I like being called names by gurus. It somehow gives me some strange
satisfaction... :-)

Again: thanks!
Walter.






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

Date: Wed, 15 Nov 2000 11:26:00 -0800
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Regex to zero pad an IP address
Message-Id: <3A12E348.D4F41529@ipac.caltech.edu>

Peter Sundstrom wrote:
> 
> I'm playing around (with not much success) with a regex to convert a
> standard IP address into a zero padded format.
> 
> Eg:
> 
> 192.1.10.1
> 
> becomes
> 
> 192.001.010.001
> 
> Is a regex the best way to approach it?

Sort of. How 'bout

$ip = join ".", map { sprintf "%3.3d",$_ } split /\./, $ip;

You can do it all in a substitute if you want:

$ip =~ s/(\d+)(\.|$)/sprintf "%3.3d$2",$1/eg;

 ... but I don't see the advantage, and I think it's harder to read. JMHO.

--

-- Tim Conrow         tim@ipac.caltech.edu                           |


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

Date: 15 Nov 2000 18:44:07 GMT
From: Jack Applin <neutron@jackbert.fc.hp.com>
Subject: Re: Regex to zero pad an IP address
Message-Id: <8uulhn$plj$1@fcnews.fc.hp.com>

Peter Sundstrom <peter.sundstrom@eds.com> wrote:
> I'm playing around (with not much success) with a regex to convert a
> standard IP address into a zero padded format.

Here's a method:

	$ip = '192.1.10.1';
	1 while $ip =~ s/\b(\d{1,2})\b/0$1/g;
	print "ip is \"$ip\"\n";

-- 
Jack Applin
neutron@fc.hp.com


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

Date: Wed, 15 Nov 2000 11:16:03 -0600
From: Adnan <kilminjaroNOSPAM@hotmail.com>
Subject: Re: Removing New Page character from a text file
Message-Id: <3A12C4D3.55A53105@hotmail.com>


Garry Williams wrote:

> On Mon, 13 Nov 2000 15:51:13 -0600, Adnan <kilminjaroNOSPAM@hotmail.com> wrote:
> >Hello,
> >
> > I have a text file that has newpage characters in it. If I do a 'more'
> >or open the file using vi these characters show up as ^L. If I open the
> >file using nedit editor these characters show up as <np>
> >
> > My question is, how can I get rid of these characters using a perl
> >script?
> >
> >I have tried following but it doesnt work.
> >
> >#!/usr/local/bin/perl
>
>     #!/usr/local/bin/perl -w
>
> >use strict;
>
> This is a very good start.
>
> >my $file = 'myfilenamehere';
> >open(FILE,"<$file") || die "Can't open `$file'! $!\n";
>
> It's also excellent that you check the result of the open and print $!
> in the error message.
>
> >while(<FILE>) {
> >        if (m!\<np\>!) {
> >                s/\<np\>//;
> >        }
> >        print;
> >}
> >
> >Replacing <np> with ^L in the script didnt work either.
>
> Well, I get the idea.
>
> First, there's no need to match for the character you want to squeeze
> out (substitute) because the substitute does that anyway.  So you can
> completely eliminate the if statement and concentrate on what to
> substitute.
>
> Second, the `<' and `>' characters are not special in Perl regular
> expressions, so there is no need to escape them.
>
> Third, That substitute will find the first occurrence of `<np>' and
> replace it with a null string.  You said before that the thing you
> really want to replace is a "newpage" character and you point out that
> your text editor displays it as `^L'.  Well, that's a hint as to what
> to use in the substitute.  The ^L is called a `control-L' and it is
> the character that results when you hold down the control key and then
> hit the L key.  So you really want to match for and replace (with a
> null string) the control-L character.
>
> It is not at all obvious from either the perlop or perlre manual
> pages, but both of them do make references to how to enter control
> character sequences in quoted strings or match patterns.  What you
> want is
>
>     while (<FILE>) {
>         s/\cL//;
>     }
>
> As a matter of fact, that whole thing is easily done in a one-liner:
>
>     perl -pe 's/\cL//'
>
> which will read on stdin and write translated results on stdout.
>
> By the way, another way to have done this would be to use the octal
> sequence in your match pattern.  The way to find out what that would
> be is to use your system's ascii manual page.  That will tell you that
> a control-L or new-page is octal 014, so another way to say the same
> pattern is
>
>         s/\014//;
>
> --
> Garry Williams

Thank you very much Garry. Thanks for the critique and multiple solutions. Now all
I have to do is decide which is easier for me to go with.

Thanks,

Adnan




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

Date: Wed, 15 Nov 2000 11:12:23 -0600
From: Adnan <kilminjaroNOSPAM@hotmail.com>
Subject: Re: Removing New Page character from a text file
Message-Id: <3A12C3F7.C33F4694@hotmail.com>



"John J. Trammell" wrote:

> On Mon, 13 Nov 2000 15:51:13 -0600, Adnan <kilminjaroNOSPAM@hotmail.com> wrote:
> >Hello,
> >
> >I have a text file that has newpage characters in it. If I do a 'more'
> >or open the file using vi these characters show up as ^L. If I open the
> >file using nedit editor these characters show up as <np>
> >
> >My question is, how can I get rid of these characters using a perl
> >script?
>
> How about:
>
>     perl -pi.bak -e 'tr(\f)()d' filename
>
> --
> John J. Trammell
> johntrammell@yahoo.com

Thanks John. That worked great.

Adnan



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4894
**************************************


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