[17570] in Perl-Users-Digest
Perl-Users Digest, Issue: 4990 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 29 18:10:47 2000
Date: Wed, 29 Nov 2000 15:10:22 -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: <975539422-v9-i4990@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 29 Nov 2000 Volume: 9 Number: 4990
Today's topics:
Re: how to browse directory in my system from remote sy dtbaker_dejanews@my-deja.com
Re: IIS CGI <xzrgpnys@yvtugubhfrovm.pbz>
Re: IIS CGI dtbaker_dejanews@my-deja.com
IO::Socket send exits on failure <hbarta@enteract.com>
Re: Loading of modules? nobull@mail.com
Manipulate hidden Exchange recipients brian_ludwig@my-deja.com
Re: Manipulating File Modification Time <mjcarman@home.com>
Re: Manipulating File Modification Time (Tom Christiansen)
Re: Newbie Q (Arek P)
Re: one question about perl return value dtbaker_dejanews@my-deja.com
Re: Pattern matching in arrays with foreach loop nobull@mail.com
Re: PLEASE HELP ME???!!!! (Mark Wright)
Re: Poll it <kseterba@chello.no>
Re: Posting Guidelines? <nospam.newton@gmx.li>
Problem with Variables... I think... foo@foo.com
Re: Problem with Variables... I think... <noone@dontbother.com>
Re: Problem with Variables... I think... nobull@mail.com
Re: Problem with Variables... I think... nobull@mail.com
Re: Problem with Variables... I think... (Tyrone Mills)
Re: Problem with Variables... I think... (Tyrone Mills)
Re: Problem with Variables... I think... (Tyrone Mills)
Re: Problems writing file using Perl on NT (IIS 4 + Per <johngros@Spam.bigpond.net.au>
Re: Problems writing file using Perl on NT (IIS 4 + Per <johngros@Spam.bigpond.net.au>
Re: proxy autoconfig brett_wilson@my-deja.com
Re: Reading a csv file <isterin@hotmail.com>
Re: Reading a csv file (David Wall)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 29 Nov 2000 21:04:48 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: how to browse directory in my system from remote system using cgi/perl
Message-Id: <903r1b$iof$1@nnrp1.deja.com>
In article <902ns0$kdd$1@nnrp1.deja.com>,
epdass@my-deja.com wrote:
> Hi
>
> I am doing one cgi program using perl. In which I
> eagerly want to do one new function which is
> nothing but listing of my local directories and
> files .
>
-----------------
wow, that would be one heck of a security violation if it were possible!
there are lots of things in the design of http transactions to prevent
actions like this. If you have a process running on the client, you can
"push" information via ftp or something, but you cant "pull" from a
server via cgi.
D
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 29 Nov 2000 19:15:07 GMT
From: kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz>
Subject: Re: IIS CGI
Message-Id: <3A255648.DDFE5FE6@yvtugubhfrovm.pbz>
ioa wrote:
>
> Hi ALL!
> DO I have to specify the forder where the perl is for a CGI running in
> IIS.
>
> For example:
> In Unix I should say:
>
> #!/usr/bin/perl
>
> but # is a comment in DOS or NT ... So the system won't read that line
>
> Thanks in advance
Well, the shebang line is acctually a comment in Unix too, it's just a
special kind of comment. Make sure you path contains the location of
the perl executable, and the system won't even look at the shebang
(#!/usr/bin/perl) line anymore.
Luck,
Kevin
--
email: xzrgpnys@yvtugubhfrovm.pbz
Huh? http://www.flactem.com/utils/rot13.html
------------------------------
Date: Wed, 29 Nov 2000 21:00:20 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: IIS CGI
Message-Id: <903qp1$ie7$1@nnrp1.deja.com>
In article <903a7g$35v$1@nnrp1.deja.com>,
ioa <ioa@sererico.com> wrote:
> Hi ALL!
> DO I have to specify the forder where the perl is for a CGI running in
> IIS.
>
> For example:
> In Unix I should say:
>
> #!/usr/bin/perl
>
> but # is a comment in DOS or NT ... So the system won't read that line
>
----------------
I think that the webserver MAY read the #! line even when it is not read
in command line perl on win32 machines. If you are having trouble with
your local webserver for development, try www.xitami.com for a freebie
that is easy to install and configure.
D
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 29 Nov 2000 21:00:59 GMT
From: Henry_Barta <hbarta@enteract.com>
Subject: IO::Socket send exits on failure
Message-Id: <903qqb$7lr$1@bob.news.rcn.net>
I'm using an IO::Socket::INET socket to connect to a another
Perl program and send data. If the other Perl program exits,
the one that initiated the connection exits when calling
IO::Socket::send with the diagnostic message:
send: Cannot determine peer address at ./<scriptname>.pl line 81
I would much prefer that it just return an 'undef' so I could
handle this within my program.
Is there a known workaround for this problem? Should I use bare
sockets? Put the code that does the send in an 'eval'? (I'm
vaguely familiar with the notion of using an 'eval' to run
something that might die.)
Did a deja news search and found someone who experienced the
same problem, but did not find any followups to that post.
thanks,
hank
(JAPH wannabe. :)
--
Hank Barta White Oak Software Inc.
hbarta@enteract.com Predictable Systems by Design.(tm)
Beautiful Sunny Winfield, Illinois
------------------------------
Date: 29 Nov 2000 17:46:02 +0000
From: nobull@mail.com
Subject: Re: Loading of modules?
Message-Id: <u9wvdmoen9.fsf@wcl-l.bham.ac.uk>
"Jason Timmins" <jason@webfoundry.co.uk> writes:
> Do you happen to know if my assumption that the Perl interpreter loads the
> whole .pl in one go and then proceeds to 'run' it, is correct?
This is true with a few exceptions.
Code in a BEGIN block is executed as soon as the compiler reaches the
closing curly of the block.
The 'use' statement is a special shorthand for a specific commonly
used type of BEGIN block see "perldoc -f use" for details.
I'm not sure, but I expect that code associated with overloading
constants is executed at compile time.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 29 Nov 2000 20:26:32 GMT
From: brian_ludwig@my-deja.com
Subject: Manipulate hidden Exchange recipients
Message-Id: <903opc$goe$1@nnrp1.deja.com>
I am trying to get to Hidden Recipients with
Perl/LDAP, but after hiding an Exchange mailbox,
it doesn't appear in the "Recipients" container.
Is there a way to reference a particular mailbox,
using as a start:
$ExchCont = Win32::OLE-
>GetObject "LDAP://server/cn=Recipients,ou=Site,o=
Org");
or is there a "container" that holds hidden
recipients?
any help would be appreciated..
thanks!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 28 Nov 2000 16:03:08 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Manipulating File Modification Time
Message-Id: <3A242B9C.EE82AA03@home.com>
J Garcia wrote:
>
> I know how to use stat(filename) to access file
> modification time ($mtime)
If that's the only attribute you want, there's no need to parse the
whole output of stat(). You can just use -M instead.
> and then use localtime($mtime) to get exact HHMMSS info
> for a file. After trying to substitute new values for
> HHMMSS, I found out that the file time was not modified.
[Wondering what you did and why you expected it to change the
file's modtime.]
> I have tried several things including opening and closing
> file and trying to modify file time in between.
[Still wondering why you expected that to change the file's modtime.]
> Is it possible to modify file modification times with Perl [...]
Not within Perl itself. To Perl, the last modification time for a file
is read-only. You can read it into a variable and then change the
variable, but all you're doing is mucking with a copy of data; there is
no magic that ties your variable back to the file who's stat() data was
stored there, nor should you expect there to be.
The only way to "change" a file's modtime directly from Perl is to
change the file itself, at which point the modtime will be updated
accordingly -- by the OS, not by Perl.
If you want to arbitrarily set the modtime to something (e.g. yesterday
at noon) you need to get out into the OS itself. On *nix, you can use
the 'touch' command. Presumably, there is something similar under Win*
and other platforms, but this isn't a Perl question anymore. If you
don't know the command for the OS you're working on, *please* don't ask
here. The appropriate place would be a newsgroup for that OS.
-mjc
------------------------------
Date: 29 Nov 2000 11:32:44 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Manipulating File Modification Time
Message-Id: <3a254bcc@cs.colorado.edu>
In article <3A242B9C.EE82AA03@home.com>,
Michael Carman <mjcarman@home.com> wrote:
>The only way to "change" a file's modtime directly from Perl is to
>change the file itself, at which point the modtime will be updated
>accordingly -- by the OS, not by Perl.
Wrong. See Perl's standard utime function, patterned after the
standard utime(2) syscall.
--tom
------------------------------
Date: Wed, 29 Nov 2000 17:13:54 EST
From: Arek@nospam._pietruszewski_.com (Arek P)
Subject: Re: Newbie Q
Message-Id: <903v32$1euk$1@earth.superlink.net>
On Sat, 25 Nov 2000 14:37:06 +0100, Daniel Thuresson
<dante@mvd.chalmers.se> wrote:
hmmm..sounds to me like u can do most of this stuff after reading some
perl docs....
untested code; this should give U some hints:
#perl interpreter path goes here
use File::Copy;
#above for the copy
opendir(D1, "/user/d1") or die "$!";
opendir(D2, "/user/d2") or die "$!";
@d1_files=(grep/^.*./, readdir(D1));
@d2_files=(grep/^.*./, readdir(D2));
#open and read both dir in to corresponding arrays
@difference_files=();
foreach $f (@d1_files)
{
#for each file in first dir, check to see if exists in second
@exist=(grep(/$f/, @d2_files));
if (!(scalar @exists))
{
#if it does not , place it in the difference array
push @difference_files, $f;
}
}
foreach (@difference_files)
{
#do something to those files with name in $_
#and copy
copy("user/d1/".$_, "/user/d2/")
}
AGAIN this is untested,probably not the most efficient, but should
help u in some way...
ArekP.
>Hi
>
>I'm just getting started with perl and I was wondering if anyone could
>point me in the right direction.
>The problem is as follows: I want to get all the filenames from a
>directory, compare those filenames with files in another directory, and
>if there exists files in the first directory that does not exist in the
>second directory, do some stuff with those files and save them to the
>second directory. I'm running Perl 5.00.
>
>Any help appreciated.
>Cheers!
>//Daniel
>
------------------------------
Date: Wed, 29 Nov 2000 20:58:00 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: one question about perl return value
Message-Id: <903qkk$ib3$1@nnrp1.deja.com>
In article <3A252FFE.844E14B9@hotmail.com>,
Bill Wang <wangbill18@hotmail.com> wrote:
> This is a multi-part message in MIME format.
> --------------2102C99B27BF6879706C3859
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> How to use perl to return server time, then treat the time as a start
> time, so I can use javascript to display a clock.
--------------
server time may not be very accurate.... try www.time.gov
dan
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 29 Nov 2000 17:48:29 +0000
From: nobull@mail.com
Subject: Re: Pattern matching in arrays with foreach loop
Message-Id: <u9vgt6oej6.fsf@wcl-l.bham.ac.uk>
konstantin_wiesel@my-deja.com writes twice:
> ...to my surprise does not work as expected.
> foreach $line (@directory) {
> if ($line =~ m/rio/goi) {
Remove the /g modifier.
"perldoc perlop" explains what the /g modifier does to m// in a scalar
context:
The /g modifier specifies global pattern
matching--that is, matching as many times as
possible within the string. How it behaves
depends on the context. [snip]
In scalar context, each execution of m//g finds
the next match, returning TRUE if it matches, and
FALSE if there is no further match. The position
after the last match can be read or set using the
pos() function; see the pos entry in the perlfunc
manpage.
You should remove the /o modifier too. It has no effect but as you
have just learned the hard way habitually dropping in random "magic
incantations" you've seen other people use but that you don't
understand will sooner or later lead you into problems. BTW: This is
what we mean when we talk about "cargo-cult programming".
Oh, and for $DEITY's sake get into the habit of using my() all the
time - but make sure you understand why first!
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 29 Nov 2000 20:43:23 GMT
From: mark@giallo.demon.nul (Mark Wright)
Subject: Re: PLEASE HELP ME???!!!!
Message-Id: <3a2769a9.1139889@194.159.73.10>
One joyful day (Tue, 28 Nov 2000 21:43:28 GMT to be precise), Bart
Lateur <bart.lateur@skynet.be> decided that the Usenet community would
benefit from this remarkable comment:
<...>
>Assuming @words contains the list of words,
>
> s/ZZZZ/$words[rand @words]/ge;
>
>
>If anybody can explain me this: if you don't use the /e option (you
>shouldn't need it because what is in brackets is executed anyway), you
>get the same word for every replacement, in the whole string. Huh? Does
>this not look like memoization (funcion value caching)?
Presumably, if it's not being evaluated as an expression, then the
replacement string is, as far as the regexp engine is concerned,
constant as there are no extraction interpolations ($1 et al) and can
therefore be evaluated once. Kinda like an implicit /o on the
replacement string.
Mark Wright
- mark@giallo.demon.nl
--
perl -e "print join' '=>map{$_ if s/(\w*)(.)ay/\U$2\E$1/}grep/^\w/=>reverse qw+ackerhay :o( erlpay :o| notheraay :o\ ustjay :o)+"
------------------------------
Date: Wed, 29 Nov 2000 18:45:29 GMT
From: "Kos" <kseterba@chello.no>
Subject: Re: Poll it
Message-Id: <d9cV5.140$k03.14691@news01.chello.no>
I did but he said that its not supported
"Tad McClellan" <tadmc@metronet.com> wrote in message
news:slrn9281q6.12l.tadmc@magna.metronet.com...
> Kos <kseterba@chello.no> wrote:
>
> >I am using Pollit
>
>
> Send mail to jason@cgi-world.com then.
>
>
> [ snip *1100* lines of code! ]
>
>
> --
> Tad McClellan SGML consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Wed, 29 Nov 2000 21:27:28 +0100
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: Posting Guidelines?
Message-Id: <ngpa2tglf13brgkd6m0p7mmhpfcrg7nsaq@4ax.com>
On Tue, 28 Nov 2000 00:09:32 GMT, cfedde@fedde.littleton.co.us (Chris Fedde)
wrote:
> I'm talking about
> a few periodic postings that say things like "post in plain text",
> "edit quoted text", and "write below what you are responding to."
Something like the (in?)famous "Quoting Strategies and the Jeopardy Game"
postings that Tom Christiansen used to post regularly about a year ago?
Short excert:
: The following message will be posted periodically until observed
: clue-levels in these parts improve, or until the heat death of the
: Universe arrives.
:
: EXECUTIVE SUMMARY:
: To send better messages, please trim and summarize what you're
: replying to, and integrate your quoted text with the body of your
: message. Don't just put everything at the end. This isn't Jeopardy.
: People expect question-and-answer, not answer-and-question responses.
The last copy I have is <383525b7@cs.colorado.edu> .
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 29 Nov 2000 19:13:15 GMT
From: foo@foo.com
Subject: Problem with Variables... I think...
Message-Id: <3a25554a.11201897@news.junction.net>
Hello All,
Sorry if this is a terrifically dumb question (I'm pretty sure it is).
Let me start off by saying I am very new to Perl and I am writing this
as I go to read some tutorials to try and figure out where I've gone
wrong. Any help would be greatly appreciated.
I am running Perl v5.6.0 (Active Perl) on Windows NT.
I've got 2 perl scripts that are giving me a great deal of problems. I
think it is because I don't understand Perl's variable properly or how
to deal with them.
Problem 1:
I want the following script to actually run the shutdown utility.
Instead, it simply prints it to the screen...
use Shell;
$a = '\\\\is-tmills';
$b = ' /L';
$c = ' /R';
$d = ' /Y';
$e = ' /C';
$foo = ("shutdown $a $b $c $d $e");
print $foo;
What am I doing wrong?
Problem 2:
This one is really bending my mind... The actuall script is much
larger, so I'm including only a small portion. I'm sure it will be
enough for you to see what I'm doing wrong.
If I uncomment the $HOST-$ENV{COMPUTERNAME} or $HOST='dmartin', the
script works fine. However, if I try to read in a list of values or
pass one on the command line, the references to $Server are all bad
through out the rest of the script. All references to $Server are
fine, except those that use it in a Function Call.
use Time::localtime;
use Win32::NetAdmin qw( GetUsers LocalGroupIsMember
LocalGroupAddUsers UserGetAttributes
UserSetAttributes UsersExist
LocalGroupDeleteUsers
LocalGroupGetMembers
LocalGroupGetMembersWithDomain);
my %hash;
$report = 'report.txt';
#$HOST = $ENV{COMPUTERNAME};
#$HOST = 'dmartin';
$list = 'machines.txt';
$now = ctime();
open(REPORT, ">>$report") || die "Couldn't open report.txt";
open(LIST, "<$list") || die "Couldn't open $list";
while (<LIST>) {
# Check to see if the Machine name has back slashes
if ( m/\\\\/ ) {
$Server = $_;
}
elsif ( m/./ ) {
$Server = "\\\\$_";
}
# Trim the trailing Newline (\n) character
$Server =~ (s/\n//);
print $Server;
print REPORT "*** Began $Server at $now\n";
** This next line fails, complaining about $Server **
if (UsersExist($Server, 'operator')) {
BLAH...
}
I think that in both cases I'm simply not handling the variables right
or something like that. Please help if you can.
Thanks in advance,
Tyrone Mills
------------------------------
Date: Wed, 29 Nov 2000 11:27:51 -0800
From: "Robert Lund" <noone@dontbother.com>
Subject: Re: Problem with Variables... I think...
Message-Id: <t2alvn5v4gk93@corp.supernews.com>
> Problem 1:
>
> I want the following script to actually run the shutdown utility.
> Instead, it simply prints it to the screen...
>
> use Shell;
>
> $a = '\\\\is-tmills';
> $b = ' /L';
> $c = ' /R';
> $d = ' /Y';
> $e = ' /C';
>
> $foo = ("shutdown $a $b $c $d $e");
> print $foo;
I would replace the above with:
print qx [shutdown \\\\is-tmills /l /r /y /c];
--Robert
------------------------------
Date: 29 Nov 2000 19:45:57 +0000
From: nobull@mail.com
Subject: Re: Problem with Variables... I think...
Message-Id: <u9ofyyo93e.fsf@wcl-l.bham.ac.uk>
"Robert Lund" <noone@dontbother.com> writes:
> I would replace the above with:
>
> print qx [shutdown \\\\is-tmills /l /r /y /c];
Please see FAQ: "What's wrong with using backticks in a void context?"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 29 Nov 2000 19:42:56 +0000
From: nobull@mail.com
Subject: Re: Problem with Variables... I think...
Message-Id: <u9pujeo98f.fsf@wcl-l.bham.ac.uk>
foo@foo.com writes:
> Let me start off by saying I am very new to Perl and I am writing this
> use Shell;
Don't!
As a Perl beginner you should we wary of any module for which the
documentation reads: "Here's one that'll whack your mind a little
out". Particularly when you note that "your" in this context refers
to "perl5-porters". If Larry recons Shell.pm will whack a Perl guru's
mind a little out just think what it'll do to a newbie's mind!
> I want the following script to actually run the shutdown utility.
> Instead, it simply prints it to the screen...
> $foo = ("shutdown $a $b $c $d $e");
> print $foo;
print($foo) prints the string $foo.
system($foo) asks the operating system's command line interpreter to
execute the string $foo as a command.
> This one is really bending my mind...
> # Trim the trailing Newline (\n) character
> $Server =~ (s/\n//);
But this is on a DOS-like OS so what about the Carriage-Return (\r)
character?
Make that:
$Server =~ (s/\r\n//);
Better still use chomp().
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 29 Nov 2000 21:15:23 GMT
From: tmills@total-care.com (Tyrone Mills)
Subject: Re: Problem with Variables... I think...
Message-Id: <3a2571b2.6046724@news.junction.net>
On Wed, 29 Nov 2000 11:27:51 -0800, "Robert Lund"
<noone@dontbother.com> wrote:
: snip :
>>
>> $foo = ("shutdown $a $b $c $d $e");
>> print $foo;
>
>I would replace the above with:
>
>print qx [shutdown \\\\is-tmills /l /r /y /c];
>
>
>--Robert
>
Thanks! That worked perfectly. I have to admit, I was unprepared for
it to work and had to scramble to save and shutdown my work... :)
Thanks!
Tyrone
------------------------------
Date: Wed, 29 Nov 2000 21:19:24 GMT
From: tmills@total-care.com (Tyrone Mills)
Subject: Re: Problem with Variables... I think...
Message-Id: <3a2571fc.6121462@news.junction.net>
On 29 Nov 2000 19:42:56 +0000, nobull@mail.com wrote:
>foo@foo.com writes:
>
>> Let me start off by saying I am very new to Perl and I am writing this
>
>> use Shell;
>
>Don't!
>
>As a Perl beginner you should we wary of any module for which the
>documentation reads: "Here's one that'll whack your mind a little
>out". Particularly when you note that "your" in this context refers
>to "perl5-porters". If Larry recons Shell.pm will whack a Perl guru's
>mind a little out just think what it'll do to a newbie's mind!
You are quite right, it bent my mind pretty bad! The tip from Robert
works, but I see you had a warning about that, so I'll go check the
FAQ and read up on backticks. I'll also try using system($foo).
>> This one is really bending my mind...
>
>> # Trim the trailing Newline (\n) character
>> $Server =~ (s/\n//);
>
>But this is on a DOS-like OS so what about the Carriage-Return (\r)
>character?
>
>Make that:
>
> $Server =~ (s/\r\n//);
>
>Better still use chomp().
I'll give that a try!
Thanks a million,
Tyrone
------------------------------
Date: Wed, 29 Nov 2000 21:29:59 GMT
From: tmills@total-care.com (Tyrone Mills)
Subject: Re: Problem with Variables... I think...
Message-Id: <3a257465.6738539@news.junction.net>
On 29 Nov 2000 19:42:56 +0000, nobull@mail.com wrote:
>> This one is really bending my mind...
>
>> # Trim the trailing Newline (\n) character
>> $Server =~ (s/\n//);
>
>But this is on a DOS-like OS so what about the Carriage-Return (\r)
>character?
>
>Make that:
>
> $Server =~ (s/\r\n//);
>
>Better still use chomp().
I changed the substition to what you indicated above, but I still get
this error. I really should have included this the first time. I
probably didn't explain the problem very well.
This is the message I get on any function that I try to use $Server on
if $Server is filled by either ARGV[0] or $_ when reading a line from
a file.
Get Users() failed: The system could not find the environment
option that was entered at password_cl.pl line 89, <LIST> line 1.
Any thoughts?
Thanks,
Tyrone
------------------------------
Date: Wed, 29 Nov 2000 20:37:41 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: Problems writing file using Perl on NT (IIS 4 + Perl 5.0)
Message-Id: <pOdV5.11062$GW5.71269@news-server.bigpond.net.au>
It is unable to open because you have an extra dot in your open statement.
You are lucky I have good eyes ;-).
try if (open(FILE, ">" $order_directory . $file_name))
Extra dot was here ^ but now it is here.
"Philip Garrett" <philipg@atl.mediaone.net> wrote in message
news:2t0V5.828$88.210971@typhoon.southeast.rr.com...
> Dave K <eweb.support@esolutions.co.nz> wrote in message
> news:QN%U5.421$Fn.15138934@news.xtra.co.nz...
> > Hi there,
> > I am attempting to troubleshoot a script written by a customer of mine.
It
> > is basically a small storefront app that takes orders, then processes
them
> > (no cc authentication - just writes orders to a filename).
> >
> > Currently we have it setup to write to the ./orders/ directory within
the
> > cgi-bin directory (ie. ~/cgi-bin/orders/). The problem we are having is
> that
> > orders just do not get written to the directory. The error generated is
> > File Error
> > Unable to open ./U738843983
> > where U738843983 is just any random number assigned to an order. The
> > relevant subroutines in the perl are:
>
> Use the $! variable to get more information out of Perl. See below.
>
> > #---------------------------------------------------------
> > # Subroutine to write the data to a file.
> > #---------------------------------------------------------
> > sub write_data
> > {
> > # Local variables associated with arguments.
> > local ($file_name, $order_data) = @_;
> > $file_name =~ s/[\.\;\|\/]//g;
> > $order_data =~ s/[\.\;\|\/]//g;
> >
> > # Open file for writing.
> > if (open(FILE, ">" . $order_directory . $file_name))
> > {
> > # Write the data to the file.
> > print FILE $order_data;
> >
> > # Close the file.
> > close(FILE);
> > }
> > else
> > {
> > # Indicate that the file was not opened.
> > &return_error("File Error","Unable to open " . $order_directory .
> > $file_name);
>
> Change that line to:
> &return_error("File Error", "Unable to open
> ${order_directory}${file_name}: $!");
> That should help you troubleshoot the problem.
>
> BTW, the & isn't really needed.
>
> [snip]
>
> hth,
> p
>
>
------------------------------
Date: Wed, 29 Nov 2000 22:54:01 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: Problems writing file using Perl on NT (IIS 4 + Perl 5.0)
Message-Id: <dOfV5.11175$GW5.71808@news-server.bigpond.net.au>
Woops should be
$file = $order_directory.$file_name;
if (open(FILE, ">$file"))
I missed the point of the dot.
The file name and path should be inside the quotes too.
"John Boy Walton" <johngros@Spam.bigpond.net.au> wrote in message
news:pOdV5.11062$GW5.71269@news-server.bigpond.net.au...
> It is unable to open because you have an extra dot in your open statement.
> You are lucky I have good eyes ;-).
> try if (open(FILE, ">" $order_directory . $file_name))
> Extra dot was here ^ but now it is here.
>
> "Philip Garrett" <philipg@atl.mediaone.net> wrote in message
> news:2t0V5.828$88.210971@typhoon.southeast.rr.com...
> > Dave K <eweb.support@esolutions.co.nz> wrote in message
> > news:QN%U5.421$Fn.15138934@news.xtra.co.nz...
> > > Hi there,
> > > I am attempting to troubleshoot a script written by a customer of
mine.
> It
> > > is basically a small storefront app that takes orders, then processes
> them
> > > (no cc authentication - just writes orders to a filename).
> > >
> > > Currently we have it setup to write to the ./orders/ directory within
> the
> > > cgi-bin directory (ie. ~/cgi-bin/orders/). The problem we are having
is
> > that
> > > orders just do not get written to the directory. The error generated
is
> > > File Error
> > > Unable to open ./U738843983
> > > where U738843983 is just any random number assigned to an order. The
> > > relevant subroutines in the perl are:
> >
> > Use the $! variable to get more information out of Perl. See below.
> >
> > > #---------------------------------------------------------
> > > # Subroutine to write the data to a file.
> > > #---------------------------------------------------------
> > > sub write_data
> > > {
> > > # Local variables associated with arguments.
> > > local ($file_name, $order_data) = @_;
> > > $file_name =~ s/[\.\;\|\/]//g;
> > > $order_data =~ s/[\.\;\|\/]//g;
> > >
> > > # Open file for writing.
> > > if (open(FILE, ">" . $order_directory . $file_name))
> > > {
> > > # Write the data to the file.
> > > print FILE $order_data;
> > >
> > > # Close the file.
> > > close(FILE);
> > > }
> > > else
> > > {
> > > # Indicate that the file was not opened.
> > > &return_error("File Error","Unable to open " . $order_directory
.
> > > $file_name);
> >
> > Change that line to:
> > &return_error("File Error", "Unable to open
> > ${order_directory}${file_name}: $!");
> > That should help you troubleshoot the problem.
> >
> > BTW, the & isn't really needed.
> >
> > [snip]
> >
> > hth,
> > p
> >
> >
>
>
------------------------------
Date: Wed, 29 Nov 2000 21:25:35 GMT
From: brett_wilson@my-deja.com
Subject: Re: proxy autoconfig
Message-Id: <903s88$js4$1@nnrp1.deja.com>
Sorry i didnt really explain what i needed to know.
We have a cgi script in our users browsers that has the lines similar
to the following
> > PROXY w3proxy.netscape.com:8080; PROXY mozilla.netscape.com:8081
I didnt write the script but it is on netscapes webstite for automatic
config scripts..
I was just wondering how the script/browser?? connects to the first
server to determine whether it is up and what type of connextion it
makes eg does it ping the server or something??
Sorry for the simple questions im only just getting into this
Thanks
Brett
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 29 Nov 2000 19:14:57 GMT
From: ISTERIN <isterin@hotmail.com>
Subject: Re: Reading a csv file
Message-Id: <903kjb$cta$1@nnrp1.deja.com>
DBI and DBD::CSV allows for easy access and also you can set your
delimeter.
Ilya Sterin
In article <slrn925r3t.gbn.tadmc@magna.metronet.com>,
tadmc@metronet.com (Tad McClellan) wrote:
> Chris Darlington <c.darlington@virgin.net> wrote:
>
> >I have a .csv file which takes the following format:
>
> Do you mean "csv" or "CSV"?
>
> Where:
>
> csv: values separated with commas, commas in data fields prohibited
>
> CSV: like office tools dump out, with quoted fields containing
> commas/newlines, ...
>
> You might also have a look at Perl FAQ, part 4:
>
> "How can I split a [character] delimited string except when inside
> [character]? (Comma-separated files)"
>
> >Date,Match,Name1,Name2,Name3
> >
> >I want to load each line into an array and then seperate each line
using the
> >split function and the commas to split the line.
>
> For csv files, you use the split function:
>
> while ( <> ) {
> my @fields = split /,/;
> # ...
> }
>
> For CSV files, you use a CSV module from CPAN :-)
>
> >How do I read each date into an array along with the other fields?
>
> I'm not following you there.
>
> The date will be in $fields[0]. You can copy or push() it into
> another array as normal.
>
> >Can anyone please help?
>
> CPAN can help.
>
> Get the Text::CSV_XS (or Text::CSV) module there.
>
> --
> Tad McClellan SGML consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 29 Nov 2000 13:56:41 -0500
From: darkon@one.net (David Wall)
Subject: Re: Reading a csv file
Message-Id: <8FFB88A7Edarkononenet@206.112.192.118>
mgjv@tradingpost.com.au (Martien Verbruggen) wrote in
<slrn928de2.br5.mgjv@verbruggen.comdyn.com.au>:
>
>If you fix the spaces, you only have one wrong line, and that's your
>fault, not the parser's. What you have written doesn't parse CSV, it
>parses some other format.
I know the data is wrong. I was making up stuff that deliberately *wasn't*
CSV.
>You can't honestly expect any CSV parser to allow invalid syntax. CSV
>is a defined file format. You can't just make something up that has
>commas, call it CSV, and then expect CSV_XS to parse it.
I didn't expect it to. I was just playing with data that sort of looked
like CSV, but really wasn't. I should have been clearer about that, but I
thought it was clear that I was just having some fun, not intentionally
trying to mislead anyone.
--
David Wall
darkon@one.net
------------------------------
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 4990
**************************************