[16349] in Perl-Users-Digest
Perl-Users Digest, Issue: 3761 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 20 18:05:33 2000
Date: Thu, 20 Jul 2000 15:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964130715-v9-i3761@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 20 Jul 2000 Volume: 9 Number: 3761
Today's topics:
Re: "Missing coprocessor" ("Ian.")
Re: [NEWBI] Reg Exp request for help <sumus@aut.dk>
AS/400? <dkj+@andrew.cmu.edu>
Authenticating on NT Domains <dfog@home.com>
Re: automated filling of html/cgi-pages <makarand_kulkarni@my-deja.com>
Cannot reconnect to MySQL erwinjohnson@my-deja.com
Re: Check string for a certain format <sumus@aut.dk>
Re: Computing date + xxx days <jcook@strobedata.com>
Re: Counter Problem <steve@gte.net>
Re: directory structure listing <porthos@goplay_nospam.com>
file location and access strategies hacktic@my-deja.com
File Token <cajual@hotmail.com>
Re: File Token <billy@arnis-bsl.com>
getting a file from another site (P&C)
Re: getting a file from another site <jcorso@__NO_SPAM__bionicbox.com>
Re: how to convert "1.2.3.10" to "01020310"? (Abigail)
Re: how to convert "1.2.3.10" to "01020310"? <jcook@strobedata.com>
Re: How to write data into file ... ? <billy@arnis-bsl.com>
Re: humbly parsing Perl <bart.lateur@skynet.be>
Just to get perl up and running... <harrisj@ipass.net>
Re: lwp/post question <makarand_kulkarni@my-deja.com>
Re: MySQL+Apache+PHP+mod_perl+mod_ssl - Is it possible? <porthos@goplay_nospam.com>
Net::FTP module to delete files <kaweed@micron.com>
Re: Net::FTP to delete multiple files <tony_curtis32@yahoo.com>
Re: New to Perl, How to call script and check when fini <care227@attglobal.net>
NFS Client in perl? <otis@my-deja.com>
Re: NFS Client in perl? <billy@arnis-bsl.com>
Re: Odd or even ? <callgirl@la.znet.com>
parentheses confusing regexps jbellis@hotmail.com
Re: parentheses confusing regexps <billy@arnis-bsl.com>
Re: parentheses confusing regexps <sumus@aut.dk>
Test CGI IE5 ocean77@my-deja.com
Re: Understanding Perl Idiom (Please Help) <care227@attglobal.net>
Re: Understanding Perl Idiom (Please Help) <UlleAckermann@t-online.de>
Re: Understanding Perl Idiom (Please Help) (Craig Berry)
uninitialized variable value? (Jim Quinn)
Re: uninitialized variable value? (Tim)
Re: uninitialized variable value? <makarand_kulkarni@my-deja.com>
Re: What is the differance? <billy@arnis-bsl.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 20 Jul 2000 22:24:28 +0000 (UTC)
From: ian.freedomnet@softhome.net ("Ian.")
Subject: Re: "Missing coprocessor"
Message-Id: <20000720.2224.1029snz@softhome.net>
JS> > I> Ive just started looking into Perl. I collected a DOS version of
JS> > I> Perl 5 from ftp.demon.co.uk. Im ok with the DPMI bit but when
JS> > I> I try to run the .exe on my 386, its complaining about the lack
JS> > I> of a coprocessor. I know there are some 387 emulators around
JS> > I> somewhere but could someone please tell me the right one
JS> > I> to use with this Perl. I did try just making wemu387.386 from the
JS> > I> Perl 4 package available to it but it didnt do anything with it.
JS> >
JS> > Hey! Does anyone know the answer to this? Im never going to get
JS> > started with Perl if I cant get the interpreter to work. Is
JS> > this the wrong newsgroup? The "misc" in the name sounds right
JS> > to me.
JS>
JS> Hey! You want to get killfiled over this ?
Preferable to being completely ignored. I wouldnt mind so much if
this was a low volume group but there looks like theres hundreds
of people here.
JS> if you really are on a DOS / Win 3.1? system then you should get
JS>
JS> <http://www.delorie.com/djgpp/dl/ofc/simtel/v2gnu/perl552b.zip>
Thats the file I collected. When unzipped, over 6Mb of gunge without
even a mention of a co-processor without which perl.exe wont run.
JS> And read the other requirements in the sundry documents at the same
JS> site.
Ill have another look in the v2gnu directory. However I cant see
why someone couldnt just say.."Try xxxxxxxx.xxx" Im still no
wiser.
JS> I have posted a full list of the requirements in the past but I
JS> think you need to learn patience.
No, I want to learn Perl. That I suspect, will require all the
patience I can muster.
--
Bye now,
Ian.
------------------------------
Date: 20 Jul 2000 23:48:48 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: [NEWBI] Reg Exp request for help
Message-Id: <zonca2wv.fsf@macforce.sumus.dk>
kloomis@bigplanet.com.bbs@openbazaar.net (Ken Loomis) writes:
> User Input -> Converts to
>
> john doe -> John Doe
[...]
Springs to mind:
# $string contains the user input
$string = lc $string
$string =~ s/\b(.)/\u$1/g;
or just
$string =~ s/\b(.)(.*?)\b/\u$1\L$2/g;
which may be slightly intimidating to the untrained regex reader though.
> Also, does anyone know of a book or online tutorial that does a great
> job of explaining regular expressions?
Don't you like perlre and the section on Regexp Quote-Like Operators in perlop?
--
Jakob
------------------------------
Date: Thu, 20 Jul 2000 15:01:56 -0400
From: Dean K Jackson <dkj+@andrew.cmu.edu>
Subject: AS/400?
Message-Id: <UtRomYm00UwB0sHs80@andrew.cmu.edu>
Anything special I need to do to get libwww working on an AS/400?
Dean
------------------------------
Date: Thu, 20 Jul 2000 17:44:46 -0400
From: Dave Fogelson <dfog@home.com>
Subject: Authenticating on NT Domains
Message-Id: <dqrensgj0hceff6dsmn4lif8hmbd5cht1m@4ax.com>
I am currently using ActiveState perl 5.6, and have been trying to use
the Win32::AuthenticateUser module. I have need of accessing various
mapped drives from withing a cgi script. The machine is running IIS4.
I cannot afford to have the users of this site logging into the domain
directly, and need a method of giving the script access to the domain,
but not the user.
Using the code :
use AuthenticateUser;
AuthenticateUser("Domain", "User", "Password");
I get an error of subroutine AuthenticateUser is not definied. Does
anyone know of why this isn't working, or of another way to open files
on remote computers for parsing? TIA
Dave
------------------------------
Date: Thu, 20 Jul 2000 14:49:40 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
Subject: Re: automated filling of html/cgi-pages
Message-Id: <397773F4.302B4B68@my-deja.com>
> If it is possible, how can I do this ?
use the HTTP::Request::Common module
------------------------------
Date: Thu, 20 Jul 2000 19:26:14 GMT
From: erwinjohnson@my-deja.com
Subject: Cannot reconnect to MySQL
Message-Id: <8l7jo9$39s$1@nnrp1.deja.com>
I'm trying to figure out why my Perl cgis can successfully connect to a
MySQL database numerous times and then lose there ability to
connect without having to restart my server? Something to note is that
after this inability to connect I am still able to view the data
using WebMin which uses Perl but not the same account to log onto the
MySQL database. Also, I have a VB program on Windows
that modifies the database using the same CONFIG values as the Perl
scripts and it too can access the MySQL database when the
Perl scripts are unable to.
Does there seem to be anything wrong with how my Perl code excerpts
access the MySQL database? The following code would
usually set $MESSAGE to be "DBH worked STH2 worked STH worked", then
eventually it would set it to "Could not connect to
the database".
use DBI;
$CONFIG{'DBNAME'} = "$DBNAME"; # name of the database
$CONFIG{'HOST'} = "$HOSTNAME"; # Hostname of SQL Server, or
blank for localhost
$CONFIG{'USER'} = "user"; # Username for SQL,
or blank for none
$CONFIG{'PASS'} = "pw"; # Password for SQL,
or blank for none
$CONFIG{'PORT'} = "3306"; # SQL Port, or blank
to exclude
$CONFIG{'OPTIONS'}=""; # SQL Options, or
blank for none
$CONFIG{'CONNECT'} = "DBI:mysql:$CONFIG{'DBNAME'}";
$CONFIG{'CONNECT'} .= ":$CONFIG{'HOST'}" if ($CONFIG{'HOST'});
$CONFIG{'CONNECT'} .= ":$CONFIG{'PORT'}" if ($CONFIG{'PORT'});
$CONFIG{'CONNECT'} .= ":options=$CONFIG{'OPTIONS'}" if
($CONFIG{'OPTIONS'});
my($MESSAGE)="";
my ($DBH) = DBI->connect($CONFIG{'CONNECT'}, $CONFIG{'USER'},
$CONFIG{'PASS'});
if ($DBH) {
$MESSAGE="DBH worked";
my($STH2)=$DBH->prepare("SELECT * FROM $TABLE WHERE
username='$USERNAME';");
my($RET)=$STH2->execute;
if ($RET) {
$MESSAGE=" STH2 worked";
#get field names
my($STH)=$DBH->prepare("SHOW fields FROM $TABLE;");
$RET=$STH->execute;
if ($RET) {
$MESSAGE.=" STH worked";
my($NAME);
while($ary_ref=$STH->fetchrow_arrayref) {
#some code
}
}
$STH->finish;
}
$STH2->finish;
$DBH->disconnect;
}
else {
$MESSAGE="Could not connect to the database";
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 20 Jul 2000 23:25:50 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: Check string for a certain format
Message-Id: <1z0obijl.fsf@macforce.sumus.dk>
"Colin Larcombe" <colin_larcombe@hotmail.com> writes:
> Newbie writes
Indeed :-)
> I need to check a string for the format XX9999999999.
[...]
> 2. Any other suggestions for a better test gratefully received.
Never heard of regular expressions?
Check out perlre or the section on Regexp Quote-Like Operators in perlop.
[a-z] matches all the lower case letters
[A-Z] matcehs all upper case.
[A-Za-z] matches both (you can also make the regex ignore case with i suffix)
\d matches digits
\d{10} matches 10 digits in a row
See if you can work it out.
best regards
--
Jakob
------------------------------
Date: Thu, 20 Jul 2000 11:01:38 -0700
From: Jim Cook <jcook@strobedata.com>
To: jhalbrook@my-deja.com
Subject: Re: Computing date + xxx days
Message-Id: <39773E82.E72FA27C@strobedata.com>
> I'm a newbie to Perl.
>
> I was curious if there is a quick and dirty way to perform
> simple date math? I simply need to add xxx number of days
> to a given Gregorian date, and produce the resulting date.
I'm pretty new myself. These routines are ones I've converted to several
languages, so I get the same numbers everywhere. I'm pretty sheepish
about posting them, because the coding was done when I could barely
spell "perl," let alone code in it.
Please don't anybody kill me over the style or coding.
Anyway, I have routines that convert month, day, year into a number and
back. Add to the number and you've got what you want. Although I'm sure
others suggestions will work better.
#--------------------------------------------------------------------------
# Julian date arithmetic
#--------------------------------------------------------------------------
#Converted from the following QBASIC program written by Bill Cook. The
#algorithm is from Communications of the ACM and gives the Julian date
used
#by astronomers.
#DEFLNG A-Z
#FUNCTION g2j& (yinp, minp, dinp)
#y = yinp
#m = minp
#D = dinp
#IF m > 2& THEN
# m = m - 3&
#ELSE
# m = m + 9&
# y = y - 1&
#END IF
#c = y \ 100&
#ya = y - 100& * c
#j = (146097& * c) \ 4& + (1461& * ya) \ 4& + (153& * m + 2&) \ 5& + D +
1721119&
#g2j = j
#END FUNCTION
#DEFLNG A-Z
#SUB j2g (jinp, y, m, D)
#j = jinp
#j = j - 1721119&
#y = (4& * j - 1&) \ 146097&
#j = 4& * j - 1& - 146097& * y
#D = j \ 4&
#j = (4& * D + 3&) \ 1461&
#D = 4& * D + 3& - 1461& * j
#D = (D + 4&) \ 4&
#m = (5& * D - 3&) \ 153&
#D = 5& * D - 3& - 153& * m
#D = (D + 5&) \ 5&
#y = 100& * y + j
#IF m < 10& THEN
# m = m + 3&
#ELSE
# m = m - 9&
# y = y + 1&
#END IF
#end sub
#
#--------------------------------------------------------------------------
# Convert from month day year to Julian date
#
# lword MDYToJulian(month, day, year)
#
#--------------------------------------------------------------------------
sub MDYToJulian
{
local ($month, $day, $year) = @_;
local ($retval, $century, $yearoffset);
if ($month > 2) {
$month -= 3;
}
else {
$month += 9;
$year--;
}
$century = int($year / 100);
$yearoffset = $year - 100 * $century;
$retval = int((146097 * $century) / 4);
$retval += int((1461 * $yearoffset) / 4);
$retval += int((153 * $month + 2) / 5) + $day + 1721119;
$retval;
}
#--------------------------------------------------------------------------
# Convert from string to Julian date
#
# Month, day, year in that order, each separated by one or more non
# digits (m/d/y or m-d-y or m,d/y etc.)
# If the date string is NULL or otherwise illegally formatted,
# today's date is returned
#
# lword StrToJulian(char *datem_d_y)
#
#--------------------------------------------------------------------------
sub StrToJulian
{
local ($_) = @_;
local ($month, $day, $year);
if (! ( ($month, $day, $year) = /(\d\d*)\D\D*(\d\d*)\D\D*(\d\d*)/ )
) {
($_, $_, $_, $day, $month, $year) = localtime(time);
}
&MDYToJulian($month, $day, $year);
}
#--------------------------------------------------------------------------
# Convert from Julian to Month, Day, Year
#
# void JulianToMDY(lword julian, uint *month, uint *day, uint *year)
#
#--------------------------------------------------------------------------
sub JulianToMDY
{
local($julian, $month, $day, $year) = @_;
local($tmp);
$julian -= 1721119;
$_[3] = $year = int((4 * $julian - 1) / 146097);
$julian = 4 * $julian - 1 - 146097 * $year;
$tmp = int($julian / 4);
$julian = int((4 * $tmp + 3) / 1461);
$tmp = 4 * $tmp + 3 - 1461 * $julian;
$tmp = int(($tmp + 4) / 4);
$_[1] = $month = int((5 * $tmp - 3) / 153);
$tmp = 5 * $tmp - 3 - 153 * $month;
$_[2] = $day = int(($tmp + 5) / 5);
$_[3] = $year = int(100 * $year + $julian);
if ($month < 10) {
$_[1] = $month += 3;
}
else {
$_[1] = $month -= 9;
$_[3] = $year += 1;
}
undef;
}
#--------------------------------------------------------------------------
# Convert from Julian to string. If the buffer is NULL, a local
# static buffer is used.
#
# char *JulianToStr(lword julian, char *buf)
#
#--------------------------------------------------------------------------
sub JulianToStr
{
local($julian, $buf) = @_;
local ($_, $month, $day, $year);
&JulianToMDY($julian, $month, $day, $year);
$_ = "$month/$day/$year";
if ($buf ne undef) {
$_[1] = $_;
}
$_;
}
--
jcook@strobedata.com Live Honourably 4/1 - 4/3 + 4/5 - 4/7 + . . .
2000 Tuesdays: Feb/last 4/4 6/6 8/8/ 10/10 12/12 9/5 5/9 7/11 11/7 3/14
Strobe Data Inc. home page http://www.strobedata.com
My home page O- http://jcook.net
------------------------------
Date: Thu, 20 Jul 2000 20:37:53 GMT
From: "SteveSingletary" <steve@gte.net>
Subject: Re: Counter Problem
Message-Id: <BqJd5.568$vV1.216951@dfiatx1-snr1.gtei.net>
Got it. Thank you both very much. I didn't realize that I could not read
from a file that I had opened for writing. I now open the file, read it to
get the count of items currently in it, close it, and then open again but
this time to write to.
Steve
SteveSingletary <steve@gte.net> wrote in message
news:7Bnd5.655$Qd5.210923@dfiatx1-snr1.gtei.net...
>
> Can someone help me with this code. I thought this would be the easy part
> to the script.
>
> #
> $comment_file = "/home/www/guest/comments.txt";
>
> if (-e $comment_file) {
> open (FILE,">>$comment_file");
> $NBR = 0;
> }
> else {
> open (FILE,">$comment_file");
> $NBR = 1;
> }
> #
> # Calculate the comment number
> #
> if ($NBR != 1) {
> @comm_count = <FILE>;
> foreach $line (@comm_count) {
> $NBR++
> }
> $NBR++
> }
> #
> if ($form_results{'COMMENT'}) {
> print FILE "$NBR=$form_results{'COMMENT'}\n";
> }
> ####
> The output should be:
> 1=comment1
> 2=comment2
> ...
> however, the output is
> 2=comment1
> 1=comment1
> 1=comment1
> So apparently the counter is not counting the foreach's. I have tried
> diferent things but can't figure it out.
>
> Steve
>
>
>
------------------------------
Date: Thu, 20 Jul 2000 12:14:58 -0700
From: Greg <porthos@goplay_nospam.com>
Subject: Re: directory structure listing
Message-Id: <39774FB2.75050DCF@goplay_nospam.com>
Thanks Rafael!! that was exactly what I was looking for.
have a wonderful day.
Greg.
Rafael Garcia-Suarez wrote:
>
> >so far I havent done very well. I made an attempt using find in a shell
> >script but that didn't work out well
>
> #!/bin/sh
> find $* -type d | sort | sed 's,[^/]*/, ,g'
>
> This should not be too difficult to translate the above in perl.
>
> --
> Rafael Garcia-Suarez
------------------------------
Date: Thu, 20 Jul 2000 20:30:18 GMT
From: hacktic@my-deja.com
Subject: file location and access strategies
Message-Id: <8l7ngs$5vi$1@nnrp1.deja.com>
Hi all,
I'm quite new with CGI using Perl, but I wondered if there is some
protocol or strategy on where to create/place files and how to access
(using abs/rel path) them if they are located in other virtual
directories.
I'll give a situation from where my question rises:
I have a Perl script that allows the user to convert images in his/her
web directory to other formats or colors.
The Perl script accesses an info-file (flat-text-file) located in the
same directory. This info-file contains the URL (/mysite/img/) of the
images to display it in the browser and the absolute path of the images
(e.g. c:\inetpub\wwwroot\mysite\img) for the convert tool to access the
images.
The convert tool, located in the scripts directory is then executed
from the Perl script like following:
convert c:\inetpub\wwwroot\mysite\img\infile.gif
c:\inetpub\wwwroot\mysite\img\outfile.jpg
I'm running into problems on servers that have virtual directories and
I can't figure out the absolute path to the images for the convert tool.
Can somebody tell me if this _is_ the way to do this kinda thing?
Mainly to access the images. Can anybody give me his/her idea on how to
handle this the best way?
Regards;
-Mark-
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 20 Jul 2000 14:44:20 -0400
From: Christopher <cajual@hotmail.com>
Subject: File Token
Message-Id: <MPG.13e112913d5dc82989681@news.ica.net>
Hi,
Is there a way to generate some sort of indicator token for a file that
PERL has created? I want to use this token as a marker to tell a C
program whether or not the PERL program is finished with the file yet, so
the C program can close the file. I'm hoping there is some sort of
atomic function that will create the token when the file is created so I
can acheive mutual exclusion. Thanks!
Chris.
------------------------------
Date: Thu, 20 Jul 2000 14:16:51 -0500
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: File Token
Message-Id: <39775023.AC22368E@arnis-bsl.com>
Christopher wrote:
>
> Hi,
>
> Is there a way to generate some sort of indicator token for a file that
> PERL has created? I want to use this token as a marker to tell a C
> program whether or not the PERL program is finished with the file yet, so
> the C program can close the file. I'm hoping there is some sort of
> atomic function that will create the token when the file is created so I
> can acheive mutual exclusion. Thanks!
>
> Chris.
IMHO you need file locking (available from C and Perl).
Pls consult:
perldoc perlfaq5
(http://www.cpan.org/doc/manual/html/pod/perlfaq5.html)
perldoc -f flock
(http://www.cpan.org/doc/manual/html/pod/perlfunc/flock.html)
maybe, perldoc -f fcntl
(http://www.cpan.org/doc/manual/html/pod/perlfunc/fcntl.html)
Hope this help.
Ilja.
------------------------------
Date: Thu, 20 Jul 2000 19:56:50 GMT
From: mailloop@localhost.com (P&C)
Subject: getting a file from another site
Message-Id: <39785a83.343550289@news.comstar.net>
I'm developing a small perl script that checks a files time and if its
more than two minutes old I need to get a new version of the file from
another site (yes, I have permission). I can either do an http or ftp
(or perhaps another option if you can name one).
I think http would be the quickest and least overhead but how do I go
about doing this. I know there are modules but those things are
MASSIVE and require other modules etc. etc. etc.
Please tell me the best way to approach this.
Phil
p c a t n t a d m i n d o t c o m
------------------------------
Date: Thu, 20 Jul 2000 17:01:15 -0400
From: "Jason J Corso" <jcorso@__NO_SPAM__bionicbox.com>
Subject: Re: getting a file from another site
Message-Id: <snepsk9a6tt95@corp.supernews.com>
Getting files through http is *very* simple:
i have a script that gets the current headlines from slashdot...
use LWP::Simple;
...
$ultramode = get "http://www.slashdot.org/ultramode.txt";
the installation of LWP requires a few packages...
...but it is worth it and if you are hosting somewhere else, i imagine it
is already installed...
jason
P&C <mailloop@localhost.com> wrote in message
news:39785a83.343550289@news.comstar.net...
> I'm developing a small perl script that checks a files time and if its
> more than two minutes old I need to get a new version of the file from
> another site (yes, I have permission). I can either do an http or ftp
> (or perhaps another option if you can name one).
>
> I think http would be the quickest and least overhead but how do I go
> about doing this. I know there are modules but those things are
> MASSIVE and require other modules etc. etc. etc.
>
> Please tell me the best way to approach this.
>
> Phil
> p c a t n t a d m i n d o t c o m
------------------------------
Date: 20 Jul 2000 14:22:27 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <slrn8nehs8.3do.abigail@alexandra.delanet.com>
Jim Cook (jcook@strobedata.com) wrote on MMDXV September MCMXCIII in
<URL:news:39773A9A.98A07D39@strobedata.com>:
?? > :: Mapping in a void context? Abigail??
?? > Once again. There is absolutely nothing wrong with map in a void context.
??
?? Unless you take perldoc to be the gospel:
??
?? Found in perlfaq6.pod
?? What's wrong with using grep or map in a void context?
??
?? Both grep and map build a return list, regardless of their
?? context. This means you're making Perl go to the trouble of
?? building up a return list that you then just ignore. That's
?? no
?? way to treat a programming language, you insensitive
?? scoundrel!
But I don't take the perlfaq to be the gospel. Sometimes, the FAQ is
wrong. Sometimes, it's opiniated. Tom and Nat are smart, but not
infallable.
I think it should read:
What's wrong with using grep or map in a void context?
While Perl is very capable of finding out the context of an
expression and act appropriately, neither map nor grep takes
advantage of this and always build a list, regardless of their
context. This means Perl goes to the trouble of building a
return list that will be ignored. That's no way to implement
a programming language.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: Thu, 20 Jul 2000 13:08:31 -0700
From: Jim Cook <jcook@strobedata.com>
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <39775C3F.2894738F@strobedata.com>
> ?? Unless you take perldoc to be the gospel:
> But I don't take the perlfaq to be the gospel. Sometimes, the FAQ is
> wrong.
> I think it should read:
Beautiful riposte!
--
jcook@strobedata.com Live Honourably 4/1 - 4/3 + 4/5 - 4/7 + . . .
2000 Tuesdays: Feb/last 4/4 6/6 8/8/ 10/10 12/12 9/5 5/9 7/11 11/7 3/14
Strobe Data Inc. home page http://www.strobedata.com
My home page O- http://jcook.net
------------------------------
Date: Thu, 20 Jul 2000 15:37:05 -0500
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: How to write data into file ... ?
Message-Id: <397762F1.FD1EEB88@arnis-bsl.com>
tvn007@my-deja.com wrote:
...skipped...
> > and I would like to put it in the following format:
> >
> > xyzabcdbf;
> > abcdeaaa;
>
> Sorry for the confusion:
>
> The input should have the following format:
> xyzabc
> dbf;
> abcde
> aaaa;
>
Try the following:
#!/usr/bin/perl -w
use strict;
$/ = ';';
while (<DATA>)
{
tr/\r\n//d;
print $_, "\n";
}
__END__
xyzabc
dbf;
abcde
aaaa;
111111
22222222
333;
Hope the question about reading input from a file
and printing result to a file could be resolved
by yourself with the help of:
perldoc -f open
perldoc -f print
perldoc -f close
perldoc -f perlfaq5
(all docs also available from www.cpan.org)
Hope this helps.
Ilja.
------------------------------
Date: Thu, 20 Jul 2000 21:59:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: humbly parsing Perl
Message-Id: <f5tens8efadce7af33994i05j6kbp8aen7@4ax.com>
jdimov@cis.clarion.edu wrote:
>> perl -MO=Deparse yourscript.pl
>>
>> One serious problem is that missing modules are unacceptable.
>>
>
>That's precisely the reason I need help. I want to be able to do this
>even if I don't have all the modules and even if the script was written
>for a different platform and has no chance of getting interpreted on my
>machine.
You can make blank modules. The only contents it really need, is the
explicitely exported functions; or rather, their prototypes. They could
live in a separate directory tree, which you include using
perl -Mlib=/my/blank/lib -MO=Deparse yourscript.pl
You can't properly parse perl if you don't know if some things are
indeed functions.
--
Bart.
------------------------------
Date: Thu, 20 Jul 2000 16:41:52 -0400
From: Jim Harris <harrisj@ipass.net>
Subject: Just to get perl up and running...
Message-Id: <6D799342332EFED2.45BC58F850F12615.EC2967E6B92ED961@lp.airnews.net>
I'd like to learn perl. I've tried installing ActivePerl on my PC.
When
I run Perl560.exe, I get a blank DOS window with nothing in it.
I've tried typing in some of the most basic things I know:
perl -v (causes the window to instantly close and vanish), several
versions of the "Hello world" (several messages about "expecting
different operators".... I'm copying straight out of a book).
I've tried finding ActivePerl's "Trouble Shooting FAQ" but keep
getting a "404 Error" message and I've given up trying to find
what I need on site.
What am I missing here?
A bad install or does ActivePerl operate in some different way
from what I think I'm understanding in instructional material?
It's occurred to me to try to "build" perl from source code.
I have CodeWarrior but I'm not sure how to compile a project
like this.
------------------------------
Date: Thu, 20 Jul 2000 14:58:53 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: Bill Webster <billw@dal.asp.ti.com>
Subject: Re: lwp/post question
Message-Id: <3977761C.FCC96FEC@my-deja.com>
> I guess that means that my machine can act just like
> an apache server.
It means that you have apache installed on your
machine. IT got installed when you installed linux.
> how the request information creates its name/value pairs?
No website download is necessary. Write your own HTML form
and set the method to GET ( instead of post ) to see
how the name/value pairs are being sent. You will see these
name and value pairs at the end of the URL on the browser
--
------------------------------
Date: Thu, 20 Jul 2000 12:18:54 -0700
From: Greg <porthos@goplay_nospam.com>
Subject: Re: MySQL+Apache+PHP+mod_perl+mod_ssl - Is it possible??
Message-Id: <3977509E.F3DA40B3@goplay_nospam.com>
"Nicholas A. Kuzmik" wrote:
>
> In article <8l03b1$ho9$1@nnrp1.deja.com>, vartekquest@my-deja.com wrote:
>
> >
> >
> > I want to setup a Linux www server with support for PHP + mod_perl +
> > SSL, but I haven't been able to compile it succesfully.
> >
> > - Firstly I install mySQL
> > - then I build PHP
> > - then I patch apache with mod_ssl
> > - then I patch apache with mod_perl
> > - from mod_perl I do: make; make install, but it doesn't compile.
> > - then I should change httpd.conf to add support for .php, .php3,
> > etc. et voila!
> >
> > The question is: is it possible to share both PHP, mod_perl and
> > mod_ssl built on an Apache server? Or is it just plain stupid compiling
> > mod_perl when you have PHP?
> >
> > Has anybody successfully built this config?
> >
> >
> > Sent via Deja.com http://www.deja.com/ Before you buy.
>
> what about php4? if mod_perl is enabled (either by DSO or by built-in), i
> get a nasty segfault == document contained no data. bleh...
>
> nick kuzmik
I tried to do the same once a while back and after 8-10 hours of trying
I gave up.
I'd be interested to know if you ever get them all to work.
------------------------------
Date: Thu, 20 Jul 2000 10:01:58 -0600
From: "Kris" <kaweed@micron.com>
Subject: Net::FTP module to delete files
Message-Id: <8l77pq$sqb$1@admin-srv3.micron.com>
Hello-
I am using the Net::Ftp module to transfer some files to a remote
machine. However, I would like to be able to delete all the files (or just
the .gif files) in that directory prior to copying any over. The ftp client
(or server) does not appear to have any sort of rm *.gif or erase *.gif or
del *.gif, or any such command which I could use. So is there any method
that I could use to remove all gif files on the remote server via my client
before transferring my files? I have played with a method of using the 'ls'
command, then putting all the resulting listed files into an array, and
removing all of those one by one- but I have been unable to get this
functional. Any ideas? Thanks!
Kris
------------------------------
Date: 20 Jul 2000 13:06:08 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Net::FTP to delete multiple files
Message-Id: <87em4od6cv.fsf@limey.hpcc.uh.edu>
>> On Thu, 20 Jul 2000 11:06:06 -0600,
>> "Kris" <kaweed@micron.com> said:
> Hello- I am using the Net::Ftp module to transfer some
> files to a remote machine. However, I would like to be
> able to delete all the files (or just the .gif files) in
> that directory prior to copying any over. The ftp
> client (or server?) does not appear to have any sort of
> rm *.gif or erase *.gif or del *.gif, or any such
perldoc Net::FTP
...
delete ( FILENAME )
Send a request to the server to delete `FILENAME'.
Do a Net::FTP::ls() first, filter the names you want and
then delete them.
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Thu, 20 Jul 2000 14:04:02 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: New to Perl, How to call script and check when finished?
Message-Id: <39773F12.C3098246@attglobal.net>
sysnovice wrote:
>
> First let me say I'm not only new to perl I'm new to
> programming. So if I am out of line asking this in this
> forum please let me know.
>
> What I would like to know is how to call a script to
> shutdown a database and check for a condition code to see
> when the script has completed. Then I want to call other
> functions to mirror and backup the database and send an
> email when its all completed. Maybe someone could point me
> to some exsisting scripts that I could look at.
Check out the documentation for system() or exec().
Both of these will block until the process you spawned via
them has finished, so you don't have to check.
------------------------------
Date: Thu, 20 Jul 2000 18:19:25 GMT
From: Otis Gospodnetic <otis@my-deja.com>
Subject: NFS Client in perl?
Message-Id: <8l7fr3$p2$1@nnrp1.deja.com>
Hi,
I need to be able to check whether a remote NFS server is up and
whether the local machine has certain partitions from that NFS server
mounted.
I know I could probably try talking to nfsd over a socket and that I
could probably try checking if some file that is on the mounted
partition exist, but that doesn't look like the prettiest solution.
I searched for 'NFS' at http://search.cpan.org/ but found nothing.
Is there no perl NFS module or something such?
Thanks,
Otis
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 20 Jul 2000 14:52:26 -0500
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: NFS Client in perl?
Message-Id: <3977587A.76A52802@arnis-bsl.com>
Otis Gospodnetic wrote:
>
> Hi,
>
> I need to be able to check whether a remote NFS server is up and
> whether the local machine has certain partitions from that NFS server
> mounted.
>
> I know I could probably try talking to nfsd over a socket and that I
> could probably try checking if some file that is on the mounted
> partition exist, but that doesn't look like the prettiest solution.
>
> I searched for 'NFS' at http://search.cpan.org/ but found nothing.
>
> Is there no perl NFS module or something such?
>
Haven't seen a Perl NFS module, but maybe there is one.
If you need just a very quick (and not-so-portable) solution,
then simply start mount/showmount/??? commands from your
perl script, capture the output (using backticks or pipe
or something else) and parse it.
Consult you system's mount and showmount man pages.
BTW, on some systems (at least on AIX) there are some
C library (libc) functions for this purpose,
if really needed yoy may try to call them from Perl.
But, ok, it becomes a non-Perl posting...
Hope this helps.
Ilja.
------------------------------
Date: Thu, 20 Jul 2000 11:17:42 -0700
From: "Godzilla!" <callgirl@la.znet.com>
Subject: Re: Odd or even ?
Message-Id: <39774246.8F24EA21@la.znet.com>
Jimmy Lantz wrote:
> The thing I need is to get every other item
> to be treated differently. I thought to make
> the distinction odd or even number then treat the
> objects differently depending if its odd or even.
> I'm trying to do the following:
(snip)
> Does anyone has a clue on how to go about it?
Not really. Test script and printed results follow.
Works no matter how large a counter number.
> Yours sincerely
Honestly and truly?
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
@Array = ("even", "odd", "even", "odd");
$counter = 0;
foreach $element (@Array)
{
if (${\substr ($counter, -1, 1)} =~ /0|2|4|6|8/)
{ print "$element treatment\n"; }
else
{ print "$element treatment\n"; }
$counter++;
}
exit;
PRINTED RESULTS:
________________
even treatment
odd treatment
even treatment
odd treatment
Godzilla!
--
print "file:///%43|%2f";
------------------------------
Date: Thu, 20 Jul 2000 20:15:32 GMT
From: jbellis@hotmail.com
Subject: parentheses confusing regexps
Message-Id: <8l7mkp$59b$1@nnrp1.deja.com>
This sample script,
#!/usr/bin/perl -w
$foo = 'how (now)';
$bar = 'how (now)_42';
print ($bar =~ /$foo\_(\d+)/);
prints nothing, rather than the 42 I would have expected.
Removing the parentheses in $foo and $bar makes it
behave as expected. What's going on here?
-Jonathan
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 20 Jul 2000 15:50:45 -0500
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: parentheses confusing regexps
Message-Id: <39776625.1005D9E1@arnis-bsl.com>
jbellis@hotmail.com wrote:
>
> This sample script,
>
> #!/usr/bin/perl -w
>
> $foo = 'how (now)';
> $bar = 'how (now)_42';
> print ($bar =~ /$foo\_(\d+)/);
>
> prints nothing, rather than the 42 I would have expected.
> Removing the parentheses in $foo and $bar makes it
> behave as expected. What's going on here?
>
print ($bar =~ /\Q$foo\E_(\d+)/);
The reason is that parentheses in $foo are treated
in 'regexp' meaning, not literally.
Consult:
perldoc perlop
(http://www.cpan.org/doc/manual/html/pod/perlop.html)
perldoc -f quotemeta
(http://www.cpan.org/doc/manual/html/pod/perlfunc/quotemeta.html)
And, AFAIK you do not need to escape a '_' in regexp.
Hope this helps.
Ilja.
------------------------------
Date: 20 Jul 2000 23:13:22 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: parentheses confusing regexps
Message-Id: <3dl4bj4d.fsf@macforce.sumus.dk>
jbellis@hotmail.com writes:
> This sample script,
>
> #!/usr/bin/perl -w
>
> $foo = 'how (now)';
> $bar = 'how (now)_42';
> print ($bar =~ /$foo\_(\d+)/);
>
> prints nothing, rather than the 42 I would have expected.
Yeah. $foo is interpolated before the regex is evaluated - so the regex
you're evaluating is:
/how (now)\_(\d+)/
try with $bar = 'how now_42'; and you may understand everything clearly
all of a sudden.
To match an actual parenthessis you need to escape it, so this will do
what you expected before:
$foo = 'how \(now\)';
$bar = 'how (now)_42';
print ($bar =~ /$foo\_(\d+)/);
Oh and one more thing: '_' is not a special char in regex, så it needn't
be escaped. The reason why the above regex works when the underscore is
escaped and not when it's not is that $foo_ is a valid identifier and
will be used in stead of $foo if you leave out the backslash. The usual way
to separate the var name from the text in interpolating contexts is:
$bar =~ /${foo}_(\d+)/
but the backslash works too (but is a bit confusing). Never seen that before :)
--
Jakob
------------------------------
Date: Thu, 20 Jul 2000 18:36:51 GMT
From: ocean77@my-deja.com
Subject: Test CGI IE5
Message-Id: <8l7gs2$1ha$1@nnrp1.deja.com>
I have written a executable CGI and want to test it using Omnihttpd.
However, I do not know how to config IE5 to run the script to test it
like the IP address ot others config.I did not change the default
settings of Omnihttpd.
Regards
Wee Keong
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 20 Jul 2000 14:08:57 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Understanding Perl Idiom (Please Help)
Message-Id: <39774039.655DD730@attglobal.net>
kenlaird@my-deja.com wrote:
>
> #!/usr/bin/perl -w
> @a=`ps -edf`;
> foreach (@a) {
> if (/ftp/) {
> print ;
> }
> }
>
> It works fine,but trying to understand the Perl idiom I'd like to
> know why the use of both parenthesis (without them it doesn't work ).
> Would be grateful to have any explanation.
>
Do you mean the parens with 'if (/ftp/)' and 'foreach (@a)' ?
I have to assume that you are, since these are the only ones in
your example. Called in this way, if() requires parens, as does
foreach(). I must confess to being a little confused by your
question (question fragment?)
> It works fine,but trying to understand the Perl idiom I'd like to
> know why the use of both parenthesis (without them it doesn't work )
You need to reword that to be a complete question.
------------------------------
Date: Thu, 20 Jul 2000 19:19:09 +0200
From: Ulrich Ackermann <UlleAckermann@t-online.de>
Subject: Re: Understanding Perl Idiom (Please Help)
Message-Id: <3977348D.17977E74@t-online.de>
kenlaird@my-deja.com wrote:
>
> I've got this script:
>
> #!/usr/bin/perl -w
> @a=`ps -edf`;
> foreach (@a) {
> if (/ftp/) {
> print ;
> }
> }
Hi Ken,
If you put the 'if' in front of a line, you have to use the paranthesis.
But if you change the position you don't have to:
#!/usr/bin/perl -w
@a=`ps -edf`;
foreach (@a) {
print if /ftp/;
}
should do the same.
------------------------------
Date: Thu, 20 Jul 2000 19:57:04 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Understanding Perl Idiom (Please Help)
Message-Id: <snemcgnb6tt88@corp.supernews.com>
kenlaird@my-deja.com wrote:
: I've got this script:
:
: #!/usr/bin/perl -w
: @a=`ps -edf`;
: foreach (@a) {
: if (/ftp/) {
: print ;
: }
: }
I might suggest indenting your code to show the loop and conditional block
structure; it makes it much easier to read.
: It works fine,but trying to understand the Perl idiom I'd like to
: know why the use of both parenthesis (without them it doesn't work ).
: Would be grateful to have any explanation.
That's just Perl syntax; the list operand of foreach and the boolean
operand of if both need to be in parens when used in block prefix (as
opposed to statement modifier) form.
By the way, you can write the above more compactly as
print grep /ftp/, `psf -edf`;
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Turning and turning in the widening gyre
| The falcon cannot hear the falconer." - Yeats, "The Second Coming"
------------------------------
Date: Thu, 20 Jul 2000 21:11:10 GMT
From: jq@usa.net (Jim Quinn)
Subject: uninitialized variable value?
Message-Id: <8F77AFEE8jqusanet@64.252.33.231>
How can i check in my program if a certain variable is unitialized?
------------------------------
Date: Thu, 20 Jul 2000 21:18:50 GMT
From: SPAM+indigo@dimensional.com (Tim)
Subject: Re: uninitialized variable value?
Message-Id: <8F779433Bindigodimcom@166.93.207.145>
jq@usa.net (Jim Quinn) wrote in <8F77AFEE8jqusanet@64.252.33.231>:
>How can i check in my program if a certain variable is unitialized?
print "Not initialize\n" unless defined $x;
should do the trick. -w and use strict will go a long way
towards catching undefined use without having to check explicitly.
man perlfunc for more info.
-T
------------------------------
Date: Thu, 20 Jul 2000 14:43:20 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
Subject: Re: uninitialized variable value?
Message-Id: <39777278.A4A11F03@my-deja.com>
Jim Quinn wrote:
>
> How can i check in my program if a certain variable is unitialized?
use defined
--
------------------------------
Date: Thu, 20 Jul 2000 14:10:37 -0500
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: What is the differance?
Message-Id: <39774EAD.1B1F473A@arnis-bsl.com>
Ala Qumsieh wrote:
>
> Ilja Tabachnik <billy@arnis-bsl.com> writes:
>
> > length($octet) == 1 ? ($mac.="0$octet") : ($mac.=$octet)
> >
> > See perldoc perlop about operator precedence.
> >
> > Or maybe more compact:
> >
> > $mac = join '' => map {length==1? "0$_" : $_} split(/:/,$mac);
>
> You have one weird definition for 'compact'!
>
> :-)
>
> --Ala
Hm-m, my contruct replaces the original construct
(with foreach() loop), so IMHO it is more compact.
Though, maybe not too much compact ;-)
Ilja.
------------------------------
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 3761
**************************************