[22629] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4850 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 15 18:06:24 2003

Date: Tue, 15 Apr 2003 15:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 15 Apr 2003     Volume: 10 Number: 4850

Today's topics:
    Re: Accesing machines of a network (Bryan Castillo)
        Can I use a hash slice through an anonymous hashref? (Sara)
    Re: Can I use a hash slice through an anonymous hashref <skuo@mtwhitney.nsc.com>
    Re: Can I use a hash slice through an anonymous hashref <grazz@pobox.com>
        Child returns to parent program when initiated by Perl  (Dave)
    Re: Child returns to parent program when initiated by P <emschwar@pobox.com>
        Delete line based on the next. (supportgeek)
    Re: grep in array <tzz@lifelogs.com>
        How to compare 2 data files? (mark sabatini)
    Re: How to do a regexp to find #'s? <nospamkz15mapson@tellabs.com>
    Re: keys function not printing keys in debugger <wksmith@optonline.net>
        lex/yacc problems with C++ program and libperl (Chris Richmond - MD6-FDC ~)
    Re: LWP Problem with 500 (Internal Server Error) Can't  (Chacrint Charinthorn)
    Re: Method inheritance? (Bryan Castillo)
    Re: Method inheritance? <mpapec@yahoo.com>
    Re: Method inheritance? <mpapec@yahoo.com>
        need finding information <urzaserra@home.com>
    Re: need finding information <tzz@lifelogs.com>
    Re: newbie:substitution in a variable name <bigus AT creationfactor DOT net>
    Re: newbie:substitution in a variable name <stacom@stacom-software.de>
        problem reading db data via web <babernat@purdue.edu>
    Re: problem reading db data via web <tzz@lifelogs.com>
        Unlink Not Working On Windows Server <geo@divergentweb.NO.SPAM.com>
    Re: Unlink Not Working On Windows Server (Tad McClellan)
    Re: Unlink Not Working On Windows Server <geo@divergentweb.NO.SPAM.com>
    Re: WIN32::ODBC problem (Jay Tilton)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 15 Apr 2003 13:52:23 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Accesing machines of a network
Message-Id: <1bff1830.0304151252.6e78ff73@posting.google.com>

"Kasp" <kasp@epatra.com> wrote in message news:<b7gt66$tdr$1@newsreader.mailgate.org>...
> Thanks Brian, that helped. But I still am facing some problems.
> 
> 1. For eg. I need to authenticate myself when I connect to a machine. Any
> idea how I can do this from Perl?
> 

Wouldn't you just want to use the current user you are logged on as? 
I believe the windows scheduler would allow you to run a script as a
specified user.  If you want the perl script to handle authentication
(where the script logs on as a different user than the current user);
I don't think you can do that easily from windows.  You could do it on
a *nix system where the samba client library is installed and the perl
module Filesys::SmbClient.



> 2 . Also, once I am connected to a machine and authenticated, I need to find
> out the files & directories that have been shared. I can't seem to be able
> to do this. However, if I know that a directory (say dir2) exists under
> \\machine2, then I can operate on it using "opendir" & "-e" (file exists)
> etc. So the point is how can I come to know what all directories are shared
> under \\machine2


You might need to use Win32::NetResource - see the perldocs for that
module there is an example for enumerating all systems on the network
(takes forever where I work) and one for enumerating shares on a
particular host.

# The function you should be interested in is
GetSharedResources(\@Resources,dwType,\%NetResource = NULL)



> 
> TIA.


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

Date: 15 Apr 2003 11:00:53 -0700
From: genericax@hotmail.com (Sara)
Subject: Can I use a hash slice through an anonymous hashref?
Message-Id: <776e0325.0304151000.64e9ec83@posting.google.com>

I can't seem to get the syntax right..

  #!/usr/bin/perl -wd

  my $h = {};
  my @ages= qw(1 2 3);
  my @animals = qw(cat mouse eel);
  @{$h->{@animals}} = @ages;
  exit 0;

 DB<1> x $h
0  HASH(0x8083ea8)
   3 => ARRAY(0x8083ecc)
      0  1
      1  2
      2  3

no errors, but HUH? Where did my animals go?? It treated it in scalar
context yielding a key of "3", and assigned an arrayref as the value,
both of which seem strange. I didn't say:

  @{$h->{@animals}} = \@ages;

so why did it make it a ref? 


Thanks,
Gx


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

Date: Tue, 15 Apr 2003 11:18:48 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Can I use a hash slice through an anonymous hashref?
Message-Id: <Pine.GSO.4.21.0304151110130.12213-100000@mtwhitney.nsc.com>

On 15 Apr 2003, Sara wrote:

> I can't seem to get the syntax right..
>
>   #!/usr/bin/perl -wd
> 
>   my $h = {};
>   my @ages= qw(1 2 3);
>   my @animals = qw(cat mouse eel);
>   @{$h->{@animals}} = @ages;
>   exit 0;
> 
>  DB<1> x $h
> 0  HASH(0x8083ea8)
>    3 => ARRAY(0x8083ecc)
>       0  1
>       1  2
>       2  3
> 
> no errors, but HUH? Where did my animals go?? It treated it in scalar
> context yielding a key of "3", and assigned an arrayref as the value,
> both of which seem strange. I didn't say:
> 
>   @{$h->{@animals}} = \@ages;
> 
> so why did it make it a ref? 
> 
> 
> Thanks,
> Gx
> 




I think you want

@$href{@animals} = @ages;



They way you had it written goes incrementally as:

$href                  # is a scalar

$href->{@animals}      # is a hash reference

@{$href->{@animals}}   # when accessed through key '3' 
                       # (i.e., scalar @animals) can be dereferenced
		       # as an array... Thus $href->{@animals} is an
		       # array-ref.
                       
@{$href->{@animals}} = @ages
                      
		       # the dereferenced array-ref is assiged to
		       # @ages.

equivalently:

$href->{3} = [ @ages ]

which is what the debugger told you.

-- 
Hope this helps,
Steven



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

Date: Tue, 15 Apr 2003 18:25:51 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Can I use a hash slice through an anonymous hashref?
Message-Id: <P8Yma.10284$TR5.7461@twister.nyc.rr.com>

Sara <genericax@hotmail.com> wrote:
> I can't seem to get the syntax right..
> 
>   #!/usr/bin/perl -wd
> 
>   my $h = {};
>   my @ages= qw(1 2 3);
>   my @animals = qw(cat mouse eel);
>   @{$h->{@animals}} = @ages;
>   exit 0;

According to "Use Rule 1" from perlreftut, you should take the
syntax that works for a hash:

    @hash{@animals} = @ages;

And substitute {EXPR} for the name of the hash, where EXPR is
any expression that yields a hash reference.

    @{ EXPR }{@animals} = @ages;

In your case, $h is the hash reference, so

    @{$h}{@animals} = @ages;

> 
>  DB<1> x $h
> 0  HASH(0x8083ea8)
>    3 => ARRAY(0x8083ecc)
>       0  1
>       1  2
>       2  3
> 
> no errors, but HUH? Where did my animals go?? It treated it 
> in scalar context yielding a key of "3", and assigned an 
> arrayref as the value, both of which seem strange. 

You used @animals in scalar context here:

    $h->{@animals}
    ^

And then used that expression in an array dereference and 
list assignment.

    @{ $h->{3} } = @ages;

And that, thanks to autovivification, is equivalent to

    $h->{3} = [@ages];

-- 
Steve


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

Date: 15 Apr 2003 13:29:31 -0700
From: dfitz@services4you.com (Dave)
Subject: Child returns to parent program when initiated by Perl exec .  Why?
Message-Id: <7f8739cf.0304151229.30bb879e@posting.google.com>

I have the following code in a parent cgi program. It is not in any
kind of loop.  It is just straight line code.

&debug("ready to execute cgisubscribe\n");
@args = ("./child.cgi");
exec @args;
exit;

When the child program exits, it apparently returns to the &debug
statement in the parent calling program.  This causes the child to be
executed a second time (with no input).  On the second iteration it
does not return to the parent, or if it does, it returns to the exit.

Any suggestions on why this might be happening.  Is this a known bug? 
I was unable to find anything in bug report.

This is being run on a server using Linux, with kernal version
2.4.18-27.7.xsmp, Apache version 1.3.27 (Unix), and Perl 5.006001.

Thanks, Dave


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

Date: 15 Apr 2003 14:52:11 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Child returns to parent program when initiated by Perl exec .  Why?
Message-Id: <etohe8zcwlg.fsf@wormtongue.emschwar>

dfitz@services4you.com (Dave) writes:
> &debug("ready to execute cgisubscribe\n");
> @args = ("./child.cgi");
> exec @args;
> exit;
> 
> When the child program exits, it apparently returns to the &debug
> statement in the parent calling program.

Without knowing what child.cgi does, I can see several problems already:

1) You don't appear to know what exec() does.  'perldoc -f exec' will
   tell you. In particular, exec() never returns.  Maybe you want
   system(); I don't know.  In any event, if you don't know what a
   function does, read the documentation before using it.

2) If child.cgi ever runs, it's a miracle.  You can't assume anything
   about your cwd in a CGI environment.  In particular, it's as likely
   as not to be completely different from the place your code is located.

3) You're calling the sub 'debug' with &; this is almost always
   wrong.  Call it as debug().  See "What's the difference between
   calling a function as &foo and foo()?" in perlfaq7.

>  This causes the child to be
> executed a second time (with no input).  On the second iteration it
> does not return to the parent, or if it does, it returns to the exit.

Just based on that code, it's not possible, so something else must be
causing it.  Once exec() succeeds, the parent process is replaced with
the process it exec()s, so there's nowhere to return to.  Can you
strip parent.cgi and child.cgi down to the bare minimum required to
reproduce this bug, and post them?  This may also help you find the
bug yourself.

> Any suggestions on why this might be happening.  Is this a known bug? 
> I was unable to find anything in bug report.

It's unlikely to be a Perl bug.

> This is being run on a server using Linux, with kernal version
> 2.4.18-27.7.xsmp, Apache version 1.3.27 (Unix), and Perl 5.006001.

You probably will want to upgrade to Perl 5.8, if possible.  5.6 is
not exactly decrepit, but it's getting long in the tooth.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: 15 Apr 2003 13:41:52 -0700
From: molivier@caregroup.harvard.edu (supportgeek)
Subject: Delete line based on the next.
Message-Id: <da063e5d.0304151241.11dc7459@posting.google.com>

Here's the latest situation I've gotten my self into...

I need to delete a line based on the content on the next. Example of
the File:

125 Jersey Road          104598213     #need to delete 
125 Jersey Road          14234523d     #need to keep
9832 Auto                              #need to keep
125 Jersey Road          345234235     #need to delete
125 Jersey Road          434234234     #need to keep
9832 Auto                              #need to keep
9832 Auto                              #need to keep

As you can see I need to keep the lines where "9832 Auto" are below
"125 Jersey Road" lines. And get rid of the lines that do not have a
"9832" auto below them.
There are many cases where 9832 Auto is listed twice or thrice and I
need to keep all the lines.

The type of file i need to produce is simply:

125 Jersey Road          14234523d     
9832 Auto                              

125 Jersey Road          434234234     
9832 Auto                              
9832 Auto              

The numbers to the left are account numbers and will always be
different. the 125 Jersey Road and 9832 Auto will also remain the
same.

I know this has got to be simple, but I can't wrap my head around it.
I tried using the following code. Again thanks Bob for it. But it only
matches the first instance of a line beginning with 125 Jersey Road.
It does however match every instance of a line beginning with 9832
Auto. WIERD!

Again, a shove in the right direction on this would be more than
greatly appreciated. Thanks in advance.

open (IN, "data.txt") or die $!;
open (OUT, "> log.txt") or die $!;

my @lines = <IN>;

my $found_acct;
my $got0764;

foreach (@lines) {
 unless ($found_acct) {
  if (/^125 Jersey/) {
    print OUT $_;
    $found_acct++;
  }
 }
 else {
  if (/^9832/) {
   print OUT $_;
   $got0764++;
  } 
 
 else {last if $got0764}
 }
}


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

Date: Tue, 15 Apr 2003 11:43:13 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: grep in array
Message-Id: <4nvfxfbwby.fsf@lockgroove.bwh.harvard.edu>

On Tue, 15 Apr 2003, mr@sandman.net wrote:
> Hello! This is what I have:
> 
> %people = (
>     "john", "John Andersson",
>     "will", "William Smith"
> );
> 
> @names = ("Johnny", "David", "Willy boy", "Richard");
> 
> foreach $name (@names){
>     if (grep /$name/, keys %people){
>         print "$name is a friend of ours!\n"
>         [...]
>     } else {
>         print "We don't know $name...\n";
>     }
> }
> 
> This doesn't work, since its backways. What I want to do with the
> items in @people is check if "john" or "will" matches -IT- rather
> than the other way around.

foreach my $short_name (keys %people)
{
 if (grep /$short_name/i, @names)
 {
  print "$short_name is a friend of ours!\n";
 }
 else
 {
  print "We don't know $short_name...\n";
 }
}

> Second, I want to know who the real user was. I.e "johnny" should
> match with "john" and I want to assign "John Andersson" to a
> variable then. I want to build a list of people that are mentioned
> in the array so to speak, and I want to use their real names.
> 
> Am I making myself clear? Any help appreciated!

Just use $people{$short_name} instead of $short_name above when you
print or do something else with the name.

Ted


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

Date: 15 Apr 2003 14:02:52 -0700
From: msabatini2001@yahoo.com (mark sabatini)
Subject: How to compare 2 data files?
Message-Id: <df3ed1fc.0304151302.4d21373b@posting.google.com>

I have 2 data files that i want to compare. They look like | separated
records like
123|abc|hello|world|456|....

So how to do this in perl? Call one file old and another new.
If I do
diff old new
I get something like this

428a432
>        new string
469d473
<    old string
966c969
<        old string
---
>        new string

So from the above, can I do something in perl? I want to read the
above diff
result.
For result like
428a432, I want to save the new string in file out.new
469d473, I want to save the old string in out.old
466c471, I want to save old string in out.old and new string in
out.new

The idea being that all "a" records are to be inserted, all "d"
records are to be deleted from the old file. But "c" records are
updates. So will do this with a delete of the old record and insert of
the new.

Note that the new file, may have records like this
123|abc|hello|world|...
123|xyz|hello|world|...

i.e. there may be >1 records with the same primary key but different
data fields, so cannot depend on this field to compare the files.

Is this a good way of doing this? How do I do this?
Thanks.

-Mark Sabatini


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

Date: Tue, 15 Apr 2003 17:22:18 +0100
From: kz15 <nospamkz15mapson@tellabs.com>
Subject: Re: How to do a regexp to find #'s?
Message-Id: <3E9C31BA.3000306@tellabs.com>

Jeff Snoxell wrote:


[snip}

> I have a bunch of windows style .ini files with lines like this:
> 
> [section1]
> item1=This is item 1 # this item is used for blah blah blah
> item2=This is item 2 # this item is used for blah blah blah
> item3=This is item 3 # this item is used for blah blah blah
> item4=This is item 4 # this item is used for blah blah blah
> 
> Just wanted to read in the lines minus the comments.
> 
> It's working great now.
> 
> Many thanks,
> 
> 
> Jeff Snoxell
> Aetherweb Ltd - http://www.bespoke-web-design-uk.co.uk
> 
> 

my $ww = "item1=This is item 1 # this item is used for blah blah blah";
my @line = split(/#/,$ww);
print $line[0];

Can be further optimized/obfuscated :-)))

Cheers,

Zoltan



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

Date: Tue, 15 Apr 2003 17:08:46 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: keys function not printing keys in debugger
Message-Id: <y0Xma.7253$MB4.1660615@news4.srv.hcvlny.cv.net>


"qanda" <fumail@freeuk.com> wrote in message
news:62b4710f.0304150023.102b9ff5@posting.google.com...
--snip--
> If I then run in debug I don't understand why the keys function
> does not print anything ...
>
> $ perl -d ./hoh5
>
> Loading DB routines from perl5db.pl version 1.03
> Emacs support available.
>
> Enter h or `h h' for help.
>
> main::(./hoh5:3):       my %cfg = (                     # Common
> configuration structure.
>   DB<1> c
> Check load def1[1]
> dtype file [def1.txt]
> ref:ref HASH(0x20f834)
> fld:pos[fldthree:103]
> fld:pos[field2:250]
> fld:pos[fld1:220]
> Check at end...
>   type:def1
>     load:1
>     nflds[77]
> main::(./hoh5:60):              for my $fld (keys
> %{$dtypes->{$type}{flds}} ) {
>   DB<1> x $dtypes
> 0  HASH(0x24d570)
>    'def1' => HASH(0x205130)
>       'def_file' => 'def1.txt'
>       'flds' => HASH(0x20f834)
>          'field2' => 250
>          'fld1' => 220
>          'fldthree' => 103
>       'load' => 1
>       'nflds' => 77
>    'def2' => HASH(0x208cbc)
>       'def_file' => ''
>       'flds' => HASH(0x20f828)
>            empty hash
>       'load' => 0
>   DB<2> keys %{$dtypes->{$type}{flds}}
>
>   DB<3>

The keys function never prints.
try

print keys %{dtypes->{$type}{flds}}

By default, this will run all the keys together, but that may be ok for
debug.

or use join

print join( "\n", keys %{$dtypes->{$type}{flds}}


I did not see it right away either
Bill




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

Date: Tue, 15 Apr 2003 20:37:34 +0000 (UTC)
From: crichmon@flw6007.fm.intel.com (Chris Richmond - MD6-FDC ~)
Subject: lex/yacc problems with C++ program and libperl
Message-Id: <b7hqie$q2t$1@news01.intel.com>

Hi Folks,

   I'm asking this thrid hand for someone I'm working with
that is attepting to embed perl (version unknown) into a
C++ program.  The issue he has is that he gets compiler
warning/errors for lex/yacc variables that are defined
multiple times.  The app is using lex/yacc and so does
perl and he's assuming that's the source of the errors.
I read the perlembed.pod and didn't find anything nor
in the rest of the .pod from perl5.005_03.

Is there another resource I can try to get answers from?

Thx, Chris

-- 
 Chris Richmond         | I don't speak for Intel & vise versa    



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

Date: 15 Apr 2003 09:18:52 -0700
From: chacrint@hotmail.com (Chacrint Charinthorn)
Subject: Re: LWP Problem with 500 (Internal Server Error) Can't read entity body
Message-Id: <bfe227db.0304150818.7f61cf21@posting.google.com>

helgi@decode.is (Helgi Briem) wrote in message news:<3e9a7e50.325820274@news.cis.dfn.de>...
> On 12 Apr 2003 06:31:23 -0700, chacrint@hotmail.com
> (Chacrint Charinthorn) wrote:
> 
> >I tried to post using LWP but I got the following error:
> >500 (Internal Server Error) Can't read entity body: Connection
> > reset by peer
> 
> Perl doesn't have a 500 error.  Web servers do.  
> Is this a stealth CGI question?  If so, you would
> be well advised to consult the FAQ documents, 
> specifically perldoc -q 500, also known as:
> 
>   "My CGI script runs from the command line but not the 
>    browser.  (500 Server Error)"
> 
> Short answers:
> 1-  Debug your program on the command line first before 
> adding the added complexity of the Common Gateway 
> Interface.
> 
> 2- Use the CGI.pm module that comes as standard
> with every Perl distribution.

Okay, I also believe that this could be caused by the webserver I
posted to using my perl script. I doubt that how I could see the
proper entity body when posting via some software like TCP VIEWER.

Thanks for your assistance


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

Date: 15 Apr 2003 09:59:13 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Method inheritance?
Message-Id: <1bff1830.0304150859.546a9554@posting.google.com>

> > you need (at least) to have this at the top of your script:
> > 
> > package DB;
> > use strict;
> > use DBI;
> > @ISA = ("DBI");
> 
> Thanks for your reply. I tried this but seems like it didn't work. My
> scripts:
> ---[DB.pm]---
> package DB;
> use strict;
> use DBI;
> @ISA = ("DBI");
> 
> sub connect {
>     my $class = shift();
>     my $self = {};
>     $self = DBI::->connect("DBI:mysql:dummy", "root", "mysql", {
> RaiseError => 1 });
>     bless($self, $class);
>     return $self;
> }
> 1;



> I just try to wrap the DBI module in my own module, so I don't need to put
> host name, user name and password everytime I call it.

I don't think your needs warrant inheritance.
You are better suited using a factory method.

package MyDB;
use strict;
use DBI;
 
sub connect {
  return DBI->connect("DBI:mysql:dummy", "root", "mysql", {RaiseError=>1});
}
1;

# Using it
use MyDB;
my $dbh = MyDB->connect;
my $sth = $dbh->prepare("select count(*) from blah");
# etc.....


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

Date: Tue, 15 Apr 2003 21:04:12 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Method inheritance?
Message-Id: <eblo9vss0ljh4u8fqq90jeclij27h3vd08@4ax.com>

X-Ftn-To: Benjamin Goldberg 

Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>> What should be done when inheriting a class and wanting to be sure that
>> my attribute didn't overwrite some of inherited class?
>
>In general, there's no way to be absolutely, one hundred percent *sure*
>that your attribute won't conflict with a parent class, except by
>reading the source code of the parent class... even this may not be
>foolproof, since the next version of the module may use different names.
>
>There is, however, a general hueristic:  Use attribute names which are
>unlikely for another class to pick for it's own attributes...
>
>The most common, though not always foolproof, is to simply prefix all
>attribute names with the name of your class, something like:

Recently I picked Damian book on OO Perl and came to the part where he
suggest the same technique as you do. I guess that attribute prefixing
should be a golden rule.

>   package Foo;
>   use base 'Bar';
>   sub new {
>      my $self = shift()->SUPER::new(@_);
>      $self->{foo_firstthing} = 1;
>      $self->{foo_secondthing} = 2;
>      $self;
>   }
>
>Presumably, class Bar is unlikely to use an attribute matching
>/^foo_.*/, though there's no garuntee that it won't do so.

Hmm, I just hope that Perl6 will do something about that..

>For a *real* general solution -- each module should *document* what
>types of attribute names it uses and might use in the future, and what
>it won't possibly use in the future.  Eg, if Bar is documented to only
>use attribute names /^bar_.*/, then you will *know* that /^foo_.*/ is
>safe to use.
>
>For DBI, all attribute name starting with a capital letter are reserved
>for DBI itself.
>
>Lowercase attribute names will be used by and defined by particular data
>sources (DBD modules).
>
>So your goal is to pick an attribute name which starts with a lowercase
>letter and which won't conflict with any of the DBD modules.

It seems that Class::Delegation could handle such cases(even it looks tricky
and probably introduces some overhead).



-- 
Matija


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

Date: Tue, 15 Apr 2003 21:04:09 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Method inheritance?
Message-Id: <rako9vs8aqpuuc3gbora4cdlbblb4sq28e@4ax.com>

X-Ftn-To: Malte Ubl 

Malte Ubl <ubl@schaffhausen.de> wrote:
>> What should be done when inheriting a class and wanting to be sure that my
>> attribute didn't overwrite some of inherited class?
>
>Use delegation || use Class::Delegation

Are you referring to inheritance simulation? I went trough docs and it seems
that simulating inheritance should do the job(although class has a great
deal how to manage objects with multiple inheritance).


-- 
Matija


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

Date: Tue, 15 Apr 2003 11:24:07 -0700
From: "matt" <urzaserra@home.com>
Subject: need finding information
Message-Id: <%5Yma.40$Gv5.39@fed1read02>

I looked at perldoc.com but could not locate any infromation about new-line
charachters for different oses and such.  Would not having the right new
line charachters cause premature end of script headers error??




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

Date: Tue, 15 Apr 2003 16:03:44 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: need finding information
Message-Id: <4nwuhv8r4v.fsf@lockgroove.bwh.harvard.edu>

On Tue, 15 Apr 2003, urzaserra@home.com wrote:
> I looked at perldoc.com but could not locate any infromation about
> new-line charachters for different oses and such.  

http://www.perldoc.com/perl5.6.1/pod/perlport.html#Newlines

> Would not having the right new line charachters cause premature end
> of script headers error??

I don't know of such a Perl error, sorry.

Ted


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

Date: Tue, 15 Apr 2003 16:01:53 +0100
From: "Bigus" <bigus AT creationfactor DOT net>
Subject: Re: newbie:substitution in a variable name
Message-Id: <b7h6t1$qv0@newton.cc.rl.ac.uk>

"Alexander Eisenhuth" <stacom@stacom-software.de> wrote in message
news:b7h6jk$u879$1@ID-155280.news.dfncis.de...
> Tad McClellan schrieb:
> > Or, better yet:
> >
> >    my %B_mask = (
> >       '01'  =>  0x01,
> >       '02'  =>  0x02,
> >       '03'  =>  0x04,
> >       # ...
> >    );
> >
> > and access it with:   $B_mask{$i}
> >
>
> Ok, that makes more sense to use a data type instead of evaluating a
> expression the way i tried. Thanks

I would have suggested something like that, but I thought there may be some
weird & wonderful reason you wanted to use individual vars, and so just
decided to answer you're question directly :-)

Bigus




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

Date: Tue, 15 Apr 2003 17:21:35 +0200
From: Alexander Eisenhuth <stacom@stacom-software.de>
Subject: Re: newbie:substitution in a variable name
Message-Id: <b7h81b$uall$1@ID-155280.news.dfncis.de>

Bigus schrieb:

> I would have suggested something like that, but I thought there may be some
> weird & wonderful reason you wanted to use individual vars, and so just
> decided to answer you're question directly :-)
> 
> Bigus
> 

Both answers are of intrest for me. Thanks :-)

Alexander



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

Date: Tue, 15 Apr 2003 13:20:58 -0500
From: "Brian Abernathy" <babernat@purdue.edu>
Subject: problem reading db data via web
Message-Id: <b7hig5$gq1$1@mozo.cc.purdue.edu>

(70007)The timeout specified has expired: ap_content_length_filter:
apr_bucket_read() failed...

I receive the above error (apache error log) when executing an sql query
from a cgi script.  A consistent number of records are returned before the
error occurs.  However, several other queries returning larger datasets
function without error when called from the same cgi script.  Also, the
query executes properly from sqlplus.  Any idea what could be causing
problems?

Brian




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

Date: Tue, 15 Apr 2003 16:05:36 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: problem reading db data via web
Message-Id: <4nu1cz8r1r.fsf@lockgroove.bwh.harvard.edu>

On Tue, 15 Apr 2003, babernat@purdue.edu wrote:
> (70007)The timeout specified has expired: ap_content_length_filter:
> apr_bucket_read() failed...
> 
> I receive the above error (apache error log) when executing an sql
> query from a cgi script.  A consistent number of records are
> returned before the error occurs.  However, several other queries
> returning larger datasets function without error when called from
> the same cgi script.  Also, the query executes properly from
> sqlplus.  Any idea what could be causing problems?

No idea.  It's hard to find problems when you show none of your code.

Ted


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

Date: Tue, 15 Apr 2003 14:13:48 -0400
From: "George" <geo@divergentweb.NO.SPAM.com>
Subject: Unlink Not Working On Windows Server
Message-Id: <4decnSsAtKBB1gGjXTWcow@comcast.com>

Greetings All;

I am running a flattext database allowing a client to enter properties for
sale (actually I inherited it). An HTML form allows them the interface and
currently allows:

- new record entry (list a new property for sale)
- edit record entry (edit an existing property's text)

Recently I was asked to write some script to allow them to upload additional
pictures for their properties besides the main property picture so that they
could link text in the descriptions to it. So for example if the text
description says "You will love this new home with spa, pool, and large
living room" then the words "spa", "pool", and "large living room" will link
to pictures of those items. The new functions works so the app now allows:

- new record entry
- edit record entry
- add additional pictures

The problem is deleting old image files for properties that have been sold.
All images are in one directory on the web servers - a Windows2000 web
server at "/images/houseimages/", but the script does not delete files,
rather I get an HTTP 500 error:

====================

"Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator, email@address.com and inform them
of the time the error occurred, and anything you might have done that may
have caused the error.

More information about this error may be available in the server error log."

 ====================

The script is passed "imageFile=imagename.ext" from its calling form and
here is the perl script I am having problems with:

===========copy perl script=======
#!/usr/bin/perl

## USEFUL DEBUG: RETURNS BLANK PAGE IF SCRIPT REACHED
#BEGIN {
#print "Status: 200 OK\nContent-Type: text/html\n\n";
#}
## END USEFUL DEBUG

use CGI;
$cgi=new CGI;

my $filename = $cgi->param('imageFile');
my $delPath =
"/home/httpd/vhosts/thewebsite.com/httpdocs/datafiles/houseimages/"
# Do some sanity / untaint checks on $filename

# chdir ($delPath) or die "Can't move to images dir: $!";
# unlink $filename or die "Can't delete $filename: $!";

unlink($delPath$filename);

print $cgi->header();
print $cgi->start_html;
print <<HTML;
<p>
File Deleted Successfully!<br>
File name : $filename<br>
Store Path : $delPath<br>
</p>
HTML
print $cgi->end_html;
exit;

===========end copy perl script=======

I have tried two separate types of unlinks coded above, and the one that is
remarked out did not produce any error messages :

# chdir ($delPath) or die "Can't move to images dir: $!";
# unlink $filename or die "Can't delete $filename: $!";

When I uncomment the "Useful Debug" section it produces a nice blank page,
so I am not sure why the unlink portion is not working. If the problem was
with my $delpath specification I would expect a different error, and I have
tried different forms of the path that is there.

Anyone with any ideas why this does not work?

-George

georgeconklin AT comcast DOT net




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

Date: Tue, 15 Apr 2003 15:01:04 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Unlink Not Working On Windows Server
Message-Id: <slrnb9op80.39k.tadmc@magna.augustmail.com>

George <geo@divergentweb.NO.SPAM.com> wrote:

> rather I get an HTTP 500 error:

> "Internal Server Error

[snip]

> More information about this error may be available in the server error log."


What messages did you see when you looked at the server error log?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 15 Apr 2003 15:52:22 -0400
From: "George" <geo@divergentweb.NO.SPAM.com>
Subject: Re: Unlink Not Working On Windows Server
Message-Id: <dzydnf7T-Iho_wGjXTWcqQ@comcast.com>

Hi Tad;

I do not know, though I have placed a call to the hosting company to find
out. I sort of hoped that even though Perl is supposed to transcend the
platforms upon which it is installed there would be a common, well-known
problem using Perl's unlink. I will get back here with the error log entry
ASAP.

-George

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb9op80.39k.tadmc@magna.augustmail.com...
> George <geo@divergentweb.NO.SPAM.com> wrote:
>
> > rather I get an HTTP 500 error:
>
> > "Internal Server Error
>
> [snip]
>
> > More information about this error may be available in the server error
log."
>
>
> What messages did you see when you looked at the server error log?
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Tue, 15 Apr 2003 21:59:59 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: WIN32::ODBC problem
Message-Id: <3e9c8017.13741618@news.erols.com>

"Bigus" <bigus AT creationfactor DOT net> wrote:

: I just wanted to do (what was supposed to be) a quick adminmistrative task
: on a DB, involving changing a flag in an Access DB for about 500 records. As
: I'm more familiar with WIN32::ODBC than DBI, I knocked up the following:
: 
: ======================
: # establish DB connection
: use Win32::ODBC;
: $db = new Win32::ODBC("DSN=jiscmaildb");
: 
: # select records to amend
: if(defined $db->Sql("SELECT * FROM list_details WHERE DateDeleted IS NOT
: NULL AND Deleted = 0")){print "Error selecting records:
: ".$db->error()."\n";}
: 
: # Amend each record
: while($db->FetchRow())
: {
:   $count++;
:   @therow = $db->Data();
:   if(defined $db->Sql("UPDATE list_details SET Deleted = '1' WHERE listname
: = '$therow[1]'")){print "Error amending record $therow[1]:
: ".$db->error()."\n";}
: }
: 
: $db->Close();
: 
: print "$count records amended";
: ======================
: 
: All it's supposed to do is select the 500 or so records that match the
: criteria and then change a column in each one.
: 
: Now, it works for the first record it finds, but then just exits the while()
: loop and displays "1 records amended".

: So, why is the "UPDATE list_details..." line causing it to
: exit the loop 

I'm more familiar with DBI than with Win32::ODBC, so there's a certain
amount of WAG here, but...

It feels like the second Sql() method call is stepping on the first.
That is, the statement

   $db->Sql("SELECT * FROM list_details ... " )

creates a data set of records that need updating, but on the first
iteration that data set gets clobbered by the statement

    $db->Sql("UPDATE list_details ... " )

So on the next pass through the loop, there is nothing for FetchRow()
to return.

: and what's teh bets way of getting round it?

How about simply knocking it all out in one step?

    $db->Sql("
        UPDATE list_details
        SET Deleted = '1'
        WHERE
            DateDeleted IS NOT NULL
        AND
            Deleted = 0
    ");
    print $db->RowCount(), " records updated.\n";

Or migrate to DBI where you can conveniently have several statement
handles on one connection.



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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 V10 Issue 4850
***************************************


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