[16670] in Perl-Users-Digest
Perl-Users Digest, Issue: 4082 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 21 14:09:34 2000
Date: Mon, 21 Aug 2000 11:05:20 -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: <966881120-v9-i4082@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 21 Aug 2000 Volume: 9 Number: 4082
Today's topics:
A puzzle: Can't find the syntax error in this regex?!? <burton@remove_this.lucent.com>
Re: Cookie problem (chrs in value) (Anno Siegel)
Re: Cookie problem (chrs in value) <ljg@star.le.ac.uk>
Re: Cookie problem (chrs in value) <ljg@star.le.ac.uk>
Re: Cookie problem (chrs in value) (Rafael Garcia-Suarez)
Re: Cookie problem (chrs in value) (Randal L. Schwartz)
Re: Cookie problem (chrs in value) (Abigail)
DBD::Oracle through DBD::Proxy .. stored procedures hel <NOSPAMheir@home.net>
Re: Eval and Regexps Help <ren.maddox@tivoli.com>
exists() before 5.6 for sub's <jerrad@networkengines.com>
Re: Generating a directory list... <abe@ztreet.demon.nl>
Re: Generating a directory list... <nick.allen@tbwa-europe.com>
Re: gethostbyaddr nobull@mail.com
Re: Getting rid of extra spaces and returns <lr@hpl.hp.com>
Re: Hash List Comparing <uri@sysarch.com>
Re: Hash List Comparing (Marcel Grunauer)
Re: Hash List Comparing <uri@sysarch.com>
Re: Hash List Comparing (Anno Siegel)
help a newbie with writing to a file cornelhughes@netscape.net
Re: help a newbie with writing to a file <red_orc@my-deja.com>
Re: Help with quotewords (Martien Verbruggen)
Re: Help with quotewords <jeff@vpservices.com>
Re: Help! Perl wont even run from DOS prompt. <bhoran@gate.net>
help: wanted perl programmer london eldras@my-deja.com
Re: how to generate unreadable from readable perl code (Abigail)
Re: Negativity in Newsgroup -- Solution <hartleh1@westat.com>
newline and carriage return problems flanagab@hqamc.scott.af.mil
Re: ODBC question <hartleh1@westat.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 21 Aug 2000 12:50:00 -0500
From: Burton Kent <burton@remove_this.lucent.com>
Subject: A puzzle: Can't find the syntax error in this regex?!?
Message-Id: <39A16BC8.7D9740A5@remove_this.lucent.com>
I'm stumped. What am I doing wrong, as this won't compile?
Thanks.
B
#!/opt/exptools/bin/perl
my $ELEMENT_REGEX = "[A-z][A-z0-9-]*";
my %lc_elements;
my %lc_attributes;
sub add_links {
my $text = shift;
$text =~ s#<([BU])> ?($ELEMENT_REGEX) ?</\1>#
my $thing = lc($2);
if ($lc_attributes{$thing}) {
$thing = "_" . $lc_attributes{$thing} . "_";
}
elif ( $lc_elements{$thing} ) {
$thing = "_" . $lc_elements{$thing} . "_";
}
else {
$thing = $2;
}
$thing;
#egs;
$text =~ s#\b($ELEMENT_REGEX)\b#
my $thing = lc($1);
if ($lc_elements{$thing}) {
$thing = "\_$lc_elements{$thing}\_";
}
elif ($lc_attributes{$thing}) {
$thing = "\_" . $lc_attributes{$thing} . "\_";;
}
else {
$thing = $1;
}
$thing;
#egs;
return $text;
}
------------------------------
Date: 21 Aug 2000 15:20:43 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Cookie problem (chrs in value)
Message-Id: <8nrhcb$utv$1@lublin.zrz.tu-berlin.de>
Liam Gretton <ljg@star.le.ac.uk> wrote in comp.lang.perl.misc:
>Hi,
>
>I'm trying to set a cookie where the value is a user's e-mail address. The
>'@' symbol in the address is getting escaped to %40, but something's not
>quite right because the browser is storing the cookie value as
>
> ljg tar.le.ac.uk
>
>(that's 40 spaces, and the 's' is missing) instead of
>
> ljg%40star.le.ac.uk
>
>Any idea what I'm doing wrong? perldoc CGI says that CGI.pm escapes and
>unescapes as necessary, but something isn't working as expected here.
There are 40 unexplained blanks. There's a "40" in "ljg%40star...".
Coincidence? Has a "printf" been seen near "%40s"?
Anno
------------------------------
Date: Mon, 21 Aug 2000 16:20:42 +0100
From: Liam Gretton <ljg@star.le.ac.uk>
Subject: Re: Cookie problem (chrs in value)
Message-Id: <ant211542a49Whac@xmm4.xra.le.ac.uk>
In article <slrn8q2eua.tj3.abigail@alexandra.foad.org>, Abigail
<URL:mailto:abigail@foad.org> wrote:
> Well, if things are happening at you tell us here, it surely is a browser
> bug.
It happens on every browser I've tested it with. Mainly rather obscure
ones, but Netscape 4.74 is one of them. I don't have such problems setting
the cookie from PHP4 code.
The email address is submitted in a form, the contents of which end up in
$in{}. The cookie is set as so:
my $query = new CGI;
my $cookie_out = $query->cookie(-name => "userid",
-value => "$in{\"email\"}",
-path => "/",
-domain => "www.src.le.ac.uk",
-secure => 0);
printf $query->header(-cookie=>$cookie_out);
--
Liam Gretton ljg@star.le.ac.uk
Space Research Centre, http://www.src.le.ac.uk/
Physics and Astronomy Dept, phone +44 (0) 116 223 1039
University of Leicester, fax +44 (0) 116 252 2464
Leicester LE1 7RH, UK http://xmm4.xra.le.ac.uk/
------------------------------
Date: Mon, 21 Aug 2000 16:26:50 +0100
From: Liam Gretton <ljg@star.le.ac.uk>
Subject: Re: Cookie problem (chrs in value)
Message-Id: <ant211550a01Whac@xmm4.xra.le.ac.uk>
In article <8nrhcb$utv$1@lublin.zrz.tu-berlin.de>, Anno Siegel
<URL:mailto:anno4000@lublin.zrz.tu-berlin.de> wrote:
> There are 40 unexplained blanks. There's a "40" in "ljg%40star...".
> Coincidence? Has a "printf" been seen near "%40s"?
You absolute star! That's exactly the problem. Thanks!
--
Liam Gretton ljg@star.le.ac.uk
Space Research Centre, http://www.src.le.ac.uk/
Physics and Astronomy Dept, phone +44 (0) 116 223 1039
University of Leicester, fax +44 (0) 116 252 2464
Leicester LE1 7RH, UK http://xmm4.xra.le.ac.uk/
------------------------------
Date: Mon, 21 Aug 2000 15:40:02 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Cookie problem (chrs in value)
Message-Id: <slrn8q2jl8.abm.rgarciasuarez@rafael.kazibao.net>
Liam Gretton wrote in comp.lang.perl.misc:
>In article <slrn8q2eua.tj3.abigail@alexandra.foad.org>, Abigail
><URL:mailto:abigail@foad.org> wrote:
>> Well, if things are happening at you tell us here, it surely is a browser
>> bug.
>
>It happens on every browser I've tested it with. Mainly rather obscure
>ones, but Netscape 4.74 is one of them. I don't have such problems setting
>the cookie from PHP4 code.
>
>The email address is submitted in a form, the contents of which end up in
>$in{}. The cookie is set as so:
>
>my $query = new CGI;
>
>my $cookie_out = $query->cookie(-name => "userid",
> -value => "$in{\"email\"}",
Why not using simply
-value => $in{"email"},
and where does this value come from?
> -path => "/",
> -domain => "www.src.le.ac.uk",
> -secure => 0);
>
>printf $query->header(-cookie=>$cookie_out);
--
Rafael Garcia-Suarez
------------------------------
Date: 21 Aug 2000 08:50:44 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Cookie problem (chrs in value)
Message-Id: <m11yziipez.fsf@halfdome.holdit.com>
>>>>> "Liam" == Liam Gretton <ljg@star.le.ac.uk> writes:
Liam> In article <8nrhcb$utv$1@lublin.zrz.tu-berlin.de>, Anno Siegel
Liam> <URL:mailto:anno4000@lublin.zrz.tu-berlin.de> wrote:
>> There are 40 unexplained blanks. There's a "40" in "ljg%40star...".
>> Coincidence? Has a "printf" been seen near "%40s"?
Liam> You absolute star! That's exactly the problem. Thanks!
Moral - stop using printf so much. I can't recall the number
of beginner programs that look like this:
printf $string;
Gah! Do they know what they just did? Scary.
--
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: 21 Aug 2000 17:09:10 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Cookie problem (chrs in value)
Message-Id: <slrn8q2ogd.tj3.abigail@alexandra.foad.org>
Liam Gretton (ljg@star.le.ac.uk) wrote on MMDXLVII September MCMXCIII in
<URL:news:ant211550a01Whac@xmm4.xra.le.ac.uk>:
** In article <8nrhcb$utv$1@lublin.zrz.tu-berlin.de>, Anno Siegel
** <URL:mailto:anno4000@lublin.zrz.tu-berlin.de> wrote:
** > There are 40 unexplained blanks. There's a "40" in "ljg%40star...".
** > Coincidence? Has a "printf" been seen near "%40s"?
**
** You absolute star! That's exactly the problem. Thanks!
Ah, so the program is *NOT* sending out the %40 as you claimed.
Which proved exactly my point.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
------------------------------
Date: Mon, 21 Aug 2000 13:31:23 -0400
From: "Michael Heir" <NOSPAMheir@home.net>
Subject: DBD::Oracle through DBD::Proxy .. stored procedures help
Message-Id: <39a165e4@viper.isc.att.com>
I am trying to call a simple stored procedure. I use DBD::Proxy, connecting
to an Oracle database. I tried the same code on a machine that uses
DBD::Oracle directly (to the same database) and it WORKS. Using it through
the DBD::Proxy yields the error below. Is there a way to get stored
procedures to work in Oracle through the proxy?
Thanks.
$sth = $dbi->prepare(" BEGIN :result := sf_a2n(234); END; ");
my $result = "";
$sth->bind_param_inout(":result", \$result, 50);
$sth->execute;
I get the following error on the bind_param_inout line:
DBD::Proxy::st execute failed: Server returned error: Failed to execute
method CallMethod: Can't bind a reference (SCALAR(0x4256b4))
------------------------------
Date: 21 Aug 2000 10:32:45 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Eval and Regexps Help
Message-Id: <m33djyaaua.fsf@dhcp11-177.support.tivoli.com>
mgjv@martien.heliotrope.home (Martien Verbruggen) writes:
> On Sat, 19 Aug 2000 13:29:04 GMT,
> bluearchtop@my-deja.com <bluearchtop@my-deja.com> wrote:
> >
> > Is there a better way to do this if I wanted it to evaluate/return each
> > line?
> >
> > i.e.
> >
> > <%
> > $x=1;
> > $y=2;
> > $x."\n";
> > $y."\n";
> > %>
> >
> > I would want this to print:
> > 1
> > 2
>
> <%
> $x = 1;
> $y = 1;
> "$x\n$y\n"
> %>
OK, I think I see a way to get what you want. Try this:
our $emit_str; # or "use var qw($emit_str)" in earlier versions of perl
sub emit { $emit_str .= join '', @_ }
$str =~ s/<%(.*?)*>/local $emit_str; eval $1; $emit_str/iesg;
And then use "emit" wherever you where originally wanting to use "print".
<%
$x=1;
emit "$x\n";
$y=2;
emit "$y\n";
%>
The dynamically scoped $emit_str is needed to accumlate the output for
each block and reset between blocks.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Mon, 21 Aug 2000 12:18:15 -0400
From: Jerrad Pierce <jerrad@networkengines.com>
Subject: exists() before 5.6 for sub's
Message-Id: <39A15647.372FB399@networkengines.com>
Does anybody know of a way to emulate:
exists &foo;
functionality in a pre 5.6 build?
Thanks!
PS> Please (b) cc me with any replies
------------------------------
Date: Mon, 21 Aug 2000 17:16:01 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Generating a directory list...
Message-Id: <njh2qs4qg3a5qpg0af3hlvrpolo0foq5mn@4ax.com>
On Mon, 21 Aug 2000 15:02:18 +0100, "Nick Allen"
<nick.allen@tbwa-europe.com> wrote:
> I'm an absolute beginner at this but have managed to get as far as creating
> the array of filenames together with filesizes etc. What I'm stuck on is how
> to work out whether a directory entry is a directory or a file. I figure it
> has something to do with the file mode paramter returned by stat but as I'm
> unfamiliar with unix I'm getting a bit stuck. I'd persevere on my own but a
> little nudge in the right direction could help a lot.
perldoc -f -X
--
Good luck,
Abe
------------------------------
Date: Mon, 21 Aug 2000 17:59:10 +0100
From: "Nick Allen" <nick.allen@tbwa-europe.com>
Subject: Re: Generating a directory list...
Message-Id: <8nrmlh$1of$1@soap.pipex.net>
I thought I'd replied but it hasn't appeared.
Thanks so much for all the help and detailed explanation - very much
appreciated Martin (and Abe too).
Should take me a while to plough through it all but looks extremely helpful.
Nick
Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message
news:slrn8q2f3a.uou.mgjv@martien.heliotrope.home...
> On Mon, 21 Aug 2000 15:02:18 +0100,
> Nick Allen <nick.allen@tbwa-europe.com> wrote:
> >
> > 1) a file should link to that file
> > 2) a directory should link to the same script but with a new paramater
> > telling the script to generate a list for that subdirectory.
> >
> > Hope that made sense.
> >
> > I'm an absolute beginner at this but have managed to get as far as
creating
> > the array of filenames together with filesizes etc. What I'm stuck on is
how
> > to work out whether a directory entry is a directory or a file. I figure
it
>
> You want to have a look at the perl operators that start with '-', and
> that can be found on the perlfunc documentation, either in the HTML
> stuff that comes with ActiveState or via perldoc
>
> # perldoc -f -X
>
> (on some older versions of perldoc this won't work, and you'll have to
> do
>
> # perldoc perlfunc
>
> and page down)
>
> You'll be most interested in the -d and -f, and maybe in -r as well. I
> am not entirely certain how many of these things translate to Win32 file
> systems, where some of the documented attributes are meaningless, but
> others are available that Unix file systems don't provide.
>
> > has something to do with the file mode paramter returned by stat but as
I'm
> > unfamiliar with unix I'm getting a bit stuck. I'd persevere on my own
but a
> > little nudge in the right direction could help a lot.
>
> You could use stat, but I'd just go for the -d and -f operators. Stat
> only becomes useful when you need more information.
>
> However.... How did you get the file size? Via stat? ou do already have
> the file type then.. in the third field returned.
>
> I still wouldn't use it. I suggest that you read
>
> # perldoc -f stat
>
> where you'll find examples of how to do this with the -d operator
> without having to make a second call to stat.
>
> [snip]
> if (-x $file && (($d) = stat(_)) && $d < 0) {
> print "$file is executable NFS file\n";
> }
> [snip]
>
> In your case you could do something like
>
> use strict;
> my $directory = '/tmp';
>
> opendir(DIR, $directory) or die "Couldn't opendir $directory: $!";
> foreach my $file (readdir DIR)
> {
> my @stat = stat("$directory/$file");
>
> if (-d _)
> {
> # it's a directory
> }
> elsif (-f _)
> {
> # it's a file ($stat[7] contains the size)
> }
> else
> {
> # Are there others on win32?
> }
> }
> closedir DIR;
>
> If you want to use the Fcntl macros and constants (as described by the
> stat documentation):
>
> use Fcntl qw/:mode/;
>
> # instead of -d
> if (S_ISDIR($stat[2]))
>
> # -f
> if (S_ISREG($stat[2]))
>
> etc..
>
> It's up to you which one of these two you want to use. Both are readable
> enough, and execution speed will barely differ. Startup speed may be
> slightly slower for the Fcntl, but I'm not even sure of that.
>
> (and yes, the forward slash works fine on Win32).
>
> > 1) Is there a library which does much of this - e.g provides a function
> > called isdirectory or isfile or something?
>
> the -X operators do this sort of stuff, yes.
>
> > 2) Would I be better off using something other than perl.
>
> Not at all :) For this sort of work you can hardly beat Perl :)
>
> Martien
> --
> Martien Verbruggen |
> Interactive Media Division | If at first you don't succeed, try
> Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use
> NSW, Australia | being a damn fool about it.
------------------------------
Date: 21 Aug 2000 18:42:41 +0100
From: nobull@mail.com
Subject: Re: gethostbyaddr
Message-Id: <u9ya1qbje6.fsf@wcl-l.bham.ac.uk>
zideon@my-deja.com writes something unrelated to Perl.
> I split the $host at '.', but I think I'll have a problem when $host
> contains the following string (it must only print "xs4all" and "demon"):
> - dial2334-2.xs4all.nl
> - dial32ssd.demon.co.uk
> - dial332.sdf.demon.co.uk
>
> The first $host is from The Netherlands (.nl) and the second from the
> UK (.co.uk). Is this format always the same???
> ("dialxxx" . "domain" . "country...country").
I spent ages looking for the Perl question then I realised there
wasn't one.
Your question is "do all DNS domains follow some common structure".
This has absolutely nothing to do with Perl. BTW, the answer is "no".
Please think about your question before you post. If it is not
related to Perl in any way then please don't post here.
Before you say "but I'm doing it in Perl!" ask yourself this question:
if you were having sex in the back of a car would you post questions
about contraception to rec.autos.misc?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 21 Aug 2000 09:56:57 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Getting rid of extra spaces and returns
Message-Id: <MPG.140aff34c10a449098aca9@nntp.hpl.hp.com>
In article <7avgwvie9u.fsf@merlin.hyperchip.com> on Mon, 21 Aug 2000
01:39:06 GMT, Ala Qumsieh <aqumsieh@hyperchip.com> says...
>
> Unknown <bob3434@excite.com> writes:
>
> > Basically I want to be able to parse the data so that addional spaces
> > between words are eliminated and additional returns (more than one) are
> > eliminated. Any suggestions would be appreciated.
>
> You can use the /s modifier for tr///:
>
> tr/\n //s;
No. The following replaces sequences of newlines or spaces (intermixed
in any way) by single spaces:
tr/\n / /s;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 21 Aug 2000 16:02:57 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Hash List Comparing
Message-Id: <x7k8davbym.fsf@home.sysarch.com>
>>>>> "MG" == Marcel Grunauer <marcel@codewerk.com> writes:
MG> print "error" if grep { not length } @hash{qw/A B C D/};
MG> takes the list of hash values from the specified keys and tests if each
MG> one has a length of 0 (i.e., is not filled), then returns those as a
MG> list. If there is such a return list, it prints "error".
what about values of '' (the null string)?
use exists to test for keys in a hash. that is what it is for.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 21 Aug 2000 16:15:00 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: Hash List Comparing
Message-Id: <slrn8q2l3k.6ch.marcel@gandalf.local>
On Mon, 21 Aug 2000 16:02:57 GMT, Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "MG" == Marcel Grunauer <marcel@codewerk.com> writes:
>
> MG> print "error" if grep { not length } @hash{qw/A B C D/};
>
> MG> takes the list of hash values from the specified keys and tests if each
> MG> one has a length of 0 (i.e., is not filled), then returns those as a
> MG> list. If there is such a return list, it prints "error".
>
>what about values of '' (the null string)?
>
>use exists to test for keys in a hash. that is what it is for.
True, but OP asked for detecting whether the values have been "filled",
which I understood to have length > 0.
--
Marcel Gr\"unauer - Codewerk plc . . . . . . . . . . . <http://www.codewerk.com>
Perl Consulting, Programming, Training, Code review . . . <marcel@codewerk.com>
mod_perl, XML solutions - email for consultancy availability
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();
------------------------------
Date: Mon, 21 Aug 2000 16:24:25 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Hash List Comparing
Message-Id: <x7g0nyvayu.fsf@home.sysarch.com>
>>>>> "MG" == Marcel Grunauer <marcel@codewerk.com> writes:
MG> On Mon, 21 Aug 2000 16:02:57 GMT, Uri Guttman <uri@sysarch.com> wrote:
>> use exists to test for keys in a hash. that is what it is for.
MG> True, but OP asked for detecting whether the values have been
MG> "filled", which I understood to have length > 0.
chalk it up as another case of newbie specs. :)
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 21 Aug 2000 16:29:24 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Hash List Comparing
Message-Id: <8nrld4$v1h$1@lublin.zrz.tu-berlin.de>
Uri Guttman <uri@sysarch.com> wrote in comp.lang.perl.misc:
>use exists to test for keys in a hash. that is what it is for.
This can be parsed in two ways that both make sense. Pity only one
is true.
Anno
------------------------------
Date: Mon, 21 Aug 2000 14:56:38 GMT
From: cornelhughes@netscape.net
Subject: help a newbie with writing to a file
Message-Id: <8nrfur$gga$1@nnrp1.deja.com>
I have a script that when I try to open a file to write to it I am
told: "could not open >/inetpub/yoursports/cgi-perl/monmad/w1.txt"
The file exists and my hosting company assures me that I have been
given the write permission to everything in the cgi-perl directory and
its subdirectories. Can someone tell me where I am going wrong. If I
use < instead of > it does not complain but nothing writes to the file.
Can someone also suggest a good perl learning site. The books I have
seem useless. Here's the relavant code:
sub put_entry {
$file = ">".$pickdbase;
open(FILE, $file) || die "Couldn't open $file";
print FILE qq($userid|$mday,$mon,$year,$hour|$pickoverunnum|);
# foreach $gamenum (sort keys %gamepicks) {
# print FILE qq($gamepicks{$gamenum},);
# }
foreach $gamenum (sort keys %gamepicks) {
print FILE qq($gamenum,$gamepicks{$gamenum},);
}
print FILE qq($endl);
close(FILE);
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 21 Aug 2000 15:05:22 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: help a newbie with writing to a file
Message-Id: <8nrgf1$h0a$1@nnrp1.deja.com>
In article <8nrfur$gga$1@nnrp1.deja.com>,
cornelhughes@netscape.net wrote:
> I have a script that when I try to open a file to write to it
>
> sub put_entry {
> $file = ">".$pickdbase;
> open(FILE, $file) || die "Couldn't open $file";
if you change this line to:
open(FILE, $file) || die "Couldn't open $file, $!";
you will get more information, and may be able to determine the problem.
However, if you can read from the file but not write to it, sounds like
the write permissions for the file are set wrong.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 22 Aug 2000 01:04:43 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Help with quotewords
Message-Id: <slrn8q2h8b.uou.mgjv@martien.heliotrope.home>
[Next time, please respect the natural arrow of time, and put your reply
AFTER the suitably cut-down text you include]
On Mon, 21 Aug 2000 14:44:08 GMT,
j355@my-deja.com <j355@my-deja.com> wrote:
> BRIAN O'NEIL, "123 MAIN ST, APT 5", ANY CITY, GA, 30313
[snip]
> If you run this into ParseWords it will choke on the single quote.
[snip]
> I would love to find a cleaner solution! Anybody?
Have you tried the Text::CSV modules? ParseWords wasn't meant to deal
with CSV. Also: Have you done a search on www.deja.com for the keyword
CSV?
[jeopardectomy]
Martien
--
Martien Verbruggen |
Interactive Media Division | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd. | no excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: Mon, 21 Aug 2000 11:01:30 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Help with quotewords
Message-Id: <39A16E7A.6B8896B8@vpservices.com>
j355@my-deja.com wrote:
>
> The problem is when I get data from a client it may be in a CSV file
> like this:
>
> BRIAN O'NEIL, "123 MAIN ST, APT 5", ANY CITY, GA, 30313
>
> Note that the first field contains a single quote and the second field
> is quoted. This is one of the cleaner examples of the data I get. The
> real world sucks, eh?
That example is perfectly good CSV. The quotes are needed around the
second field because it contains an embedded comma which would otherwise
be treated as a field separator.
> I would love to find a cleaner solution! Anybody?
If you want to roll your own, use Text::CSV_XS. If you want to do
things like sort it in various orders or select only certain fields or
certain records, then use DBD::CSV or DBD::RAM, both of which allow you
to treat CSV files as databases.
Jeff
--
perl -MDBI -e "$d=DBI->connect('dbi:RAM:');
$d->func(['Just,Another,Perl,Hacker'],'import');
print join ' ', $d->selectrow_array('SELECT * FROM table1')"
------------------------------
Date: Mon, 21 Aug 2000 11:35:01 -0400
From: Brian Horan <bhoran@gate.net>
To: xdesmond@hotmail.com
Subject: Re: Help! Perl wont even run from DOS prompt.
Message-Id: <Pine.A41.4.21.0008211130330.42074-100000@dakota.gate.net>
~
'v' Brian Horan
// \\ Systems Analyst/Administrator/Programmer
/( )\ Miami Herald Publishing Company bhoran@herald.com
^`~'^
Linux: For when you're sick of CTRL-ALT-DEL
> whats a good solution for windows?
-linux
you will want to find your perl binary(executable--perl.exe) and include
that in your path, the file you should edit is autoexec.bat, I believe.
and just add a line like this :
SET PATH=C:\Perl\BIN;%path%
this will put the perl interpreter into your command path....It's a sad
version of the *nix $PATH environment variable.
>
> sorry for the rookie questions..
> thanks a bunch
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
------------------------------
Date: Mon, 21 Aug 2000 17:22:27 GMT
From: eldras@my-deja.com
Subject: help: wanted perl programmer london
Message-Id: <8nrofs$qvg$1@nnrp1.deja.com>
anyone up for £1000? bit of medling with my web page.
html, javascript and web knowledge. london only
thanks
please email me asprinpain@hotmail.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 21 Aug 2000 17:27:52 GMT
From: abigail@foad.org (Abigail)
Subject: Re: how to generate unreadable from readable perl code
Message-Id: <slrn8q2pjg.tj3.abigail@alexandra.foad.org>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDXLVII
September MCMXCIII in <URL:news:8nrevj$uq6$1@lublin.zrz.tu-berlin.de>:
|| Abigail <abigail@foad.org> wrote in comp.lang.perl.misc:
|| >Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDXLVII
|| >September MCMXCIII in <URL:news:8nr4ud$ugb$1@lublin.zrz.tu-berlin.de>:
|| >\\
|| >\\ So you're saying there is a set of rules such that if a Perl source
|| >\\ is written accordingly it it easy to (for instance) recognize all
|| >\\ Perl identifiers and skip identical strings that aren't identifiers?
|| >\\ Not to speak of other requirements, like comment parsing, recognition
|| >\\ of quoted text, etc....
|| >
|| >Well, yes, I think it's trivial to program Perl in such a way that any
|| >substring that consists of '$', '@', '%' followed by an identifier, but
|| >not preceded by a backslash, is a variable, and that all variables are
|| >written that way. It's also trivial to write Perl such that any occurance
|| >of a '#' that does not start a comment is proceeded by a backslash.
||
|| Okay, fortunately for that claim $#array and $# aren't really needed.
|| What if $# becomes interesting again? What about $$? Symrefs are out,
|| you can't rename a variable that's accessed via ${ $x.$y}.
$$ certainly isn't a '$' followed by an identifier. And if you have $$
followed by letters, you can write the $$ as ${$}. Similar for all
punctuation symbols. And for $#, you can always write ${"0x23"} or
${"\#"}.
As for symrefs are out, you wouldn't be doing symrefs with 'use strict'
anyway, now would you? Sure, you can't translate Exporter.pm this way.
Big deal. Don't write Exporter that way then.
|| Did I hear someone say "use English"?
Well, it's trivial to not use English, now is it? That's what I claimed.
Perhaps you can't code without the use of English.pm, but rest assured,
most people can. ;-)
Abigail
--
perl -wlne '}print$.;{' file # Count the number of lines.
------------------------------
Date: Mon, 21 Aug 2000 13:47:18 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: Negativity in Newsgroup -- Solution
Message-Id: <39A16B26.A22AE9C2@westat.com>
Tim Hammerquist wrote:
>
> Get the comfy chair!
>
Aren't Python jokes off topic in a Perl newsgroup?
--
Henry Hartley
------------------------------
Date: Mon, 21 Aug 2000 17:11:56 GMT
From: flanagab@hqamc.scott.af.mil
Subject: newline and carriage return problems
Message-Id: <8nrns9$q7n$1@nnrp1.deja.com>
I'm trying to do some simple processing of a HTML document's forms.
All of the data has been passed to a Perl script by the standard POST
method. I have no problems except with the TEXTAREAs. These can
contain carriage returns (actually CR LF) within the box.
I'm trying to write the output of the form to a data file in
tab-delimited form. The trouble is that the LF is being interpreted as
a newline. I figured, no problem, I'll strip the \x0A from the strings
before I write them to the file, however, when I tried to do this, they
would NOT go away!
I tried to split the string and chomp off the newline. It came back. I
tried to split the string and chop off the newline, this chopped off
BOTH the \x0D and \x0A from the string. The trouble here is, I want to
KEEP the \cM. I only want to be rid of the \cJ.
I also tried going ahead and chopping off both characters, and then
reassembling the string, and appending the \x0D characters to each
section of the string. The string comes back with \x0d \x0a instead.
When I attempt a logical expression to search and replace on the string,
it will find the 0A, but it inserts it back in along with my replacement
string.
In summation, I can get rid of the \x0a characters, but not without
getting rid of the \x0d characters as well. No matter what I try, the
\x0a charaters won't go away. Is there some switch or
configuration setting to correct this problem? Does anyone have any
ideas?!
(Would using syswrite help? I haven't tried that yet.)
Thanks in advance for your help!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 21 Aug 2000 13:22:53 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: ODBC question
Message-Id: <39A1656D.C2E99154@westat.com>
DM wrote:
>
> Thanks for the link. The DSN however is not the problem. The
> error occurs before the DSN is even used. I'm including the
> line numbers in the code below:
> ---then inside of engine4.pl---
> 15
> 16 use Win32::ODBC;
>
> --- Error
> Missing $ on loop variable at C:\perl\lib/Exporter.pm line 40.
> BEGIN failed--compilation aborted at
> C:\Inetpub\wwwroot\cgi-bin\engine4.pl line 16.
>
> The program never makes it past line 16 in the script. Any ideas?
Do you have any other Perl scripts that run in the web server that use
Win32::ODBC? If so, this probably isn't the problem but it's possible
you have a bad install. You might try reinstalling (both Perl and
ODBC.pm). Alternatively, you might try running this script on a machine
that has working ODBC scripts and see if it works there.
--
Henry Hartley
------------------------------
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 4082
**************************************