[17478] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4898 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 15 21:10:40 2000

Date: Wed, 15 Nov 2000 18:10:11 -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: <974340611-v9-i4898@ruby.oce.orst.edu>
Content-Type: text

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

Today's topics:
    Re: No idea about perl, Long post, short question (Jon Ericson)
    Re: No idea about perl, Long post, short question (Logan Shaw)
    Re: No idea about perl, Long post, short question <siwatkins@iee.org>
    Re: No idea about perl, Long post, short question <siwatkins@iee.org>
    Re: No idea about perl, Long post, short question <siwatkins@iee.org>
    Re: No idea about perl, Long post, short question <siwatkins@iee.org>
    Re: No idea about perl, Long post, short question <siwatkins@iee.org>
    Re: pattern match, file open max size <mischief@velma.motion.net>
        Prevent web page time out during CGI execution? stimpiton@my-deja.com
    Re: Prevent web page time out during CGI execution? (Logan Shaw)
    Re: question about reusing a variable from a regex <ianb@ot.com.au>
    Re: Regex to zero pad an IP address <peter.sundstrom@eds.com>
        unpack tauras6097@my-deja.com
    Re: unpack (Logan Shaw)
    Re: unpack <ianb@ot.com.au>
    Re: Webpage logging script for number of simulaneous us <mischief@velma.motion.net>
        Win32::ODBC Fetchrow() problem hydsys@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 15 Nov 2000 23:17:00 GMT
From: Jonathan.L.Ericson@jpl.nasa.gov (Jon Ericson)
Subject: Re: No idea about perl, Long post, short question
Message-Id: <8FED98B18JonathanLEricsonjpln@137.78.50.25>

[Fixed wierd quoting style]
On 15 Nov 2000, siwatkins@iee.org (Simon Watkins) wrote:
>"Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
>news:m13dgsq3hn.fsf@halfdome.holdit.com...
>> >>>>> "Simon" == Simon Watkins <siwatkins@iee.org> writes:
>>
>> Simon> I'm customizing Actinic Catalog, and have discovered that their
>> Simon> a couple of problems with a perl file that writes html during
>> Simon> the order cart phases.
>>
>> So why are you posting here instead of getting support directly from
>> the company that produces Actinic Catalog?

>Randal,
>
>Thank you for your reply.  I can only hope that given your response,
>that others more gracious will be still be kind enough to assist.

You should know that Randal is one of the most respected members of the 
Perl community and often gives helpful advice.  You asked how to modify a 
script written by someone else, but have no apparant desire to learn Perl.  
Randal pointed out that Actinic should support their product.  This is a 
group for discussing perl, not a helpdesk for crappy products that just 
happen to be written in perl.  Please, either learn Perl so that you can 
provide your own support or find a product that will do what you want.  

Jon


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

Date: 15 Nov 2000 18:14:26 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: No idea about perl, Long post, short question
Message-Id: <8uv8t2$6f4$1@doughboy.cs.utexas.edu>

In article <EOBQ5.1103$X03.23143@news2-win.server.ntlworld.com>,
Simon Watkins <siwatkins@iee.org> wrote:
>Hi, the short question is:
>
>How can I amend a perl file that generates html to write the tag <base
>href="someurl/acatalog/">

Well, you could insert

	print '<base href="someurl/acatalog/">';

somewhere in the script.

Of course, that might not work, but since you've given no specifics
at all about your problem, I can't predict what will work.

Generally speaking, people will be more able and more willing to help
you in this newsgroup if you give a specific, short bit of code that
doesn't work, explain what you expected it to do, and explain what it
did instead.  Then somebody can explain to you whatever it is that you
don't understand, and then you can proceed to work on it some more.

  - Logan


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

Date: Thu, 16 Nov 2000 00:22:10 -0000
From: "Simon Watkins" <siwatkins@iee.org>
Subject: Re: No idea about perl, Long post, short question
Message-Id: <MJFQ5.2016$B02.43374@news6-win.server.ntlworld.com>

"Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
news:m1r94cones.fsf@halfdome.holdit.com...
> >>>>> "Simon" == Simon Watkins <siwatkins@iee.org> writes:
>
> Simon> Thank you for your reply.  I can only hope that given your
> Simon> response, that others more gracious will be still be kind
> Simon> enough to assist.
>
> Well, for those keeping score at home, we now have:

It is good to see a professional technical consultant being so helpful. I'm
sure you gain lots of commercial work this way.

> - user wants help with commercial software

No.  User wanted help with writing a perl statement.  This is the perl
newsgroup.  Which part do you not understand?

> - doesn't disclose that he's already made attempt to get help from vendor,
>   and was refused

What are you on about?  If it was relevant, I would have mentioned it.  It
really is none of your business.

> - doesn't know Perl that well himself, so it looks like he's trying to get
>   replacement brains for free ("gimme a fish please")

Excuse me?  I asked for help in an area in which I am not familiar.  You may
consider yourself expert in Perl, great.  I suspect however, you have great
difficulties in human relationships. To someone with as many professional
qualifications as yourself, my question could probably have been answered in
a jiffy.  I offer support on other newsgroups in areas that I am skilled to
people unfamiliar in certain topic areas.  I see no need to spend more time
in debating unrelated whys and wherefores regarding a user's request, when I
could have given a helpful answer.  I consider myself more professional than
that.

> - upside down quoter (usually a good clue)

Ahh, the NG police.

> and something you can't know unless I tell you:
>
> - commits usenet error of *** stealth CC *** (on this post)

You really do need to get a life.  Your CC to me arrived prior to your NG.
Someone as "Professional" as you, ought to know that NG posts take a while
to propagate.  If you check the timestamps you'll see the email was sent to
you WITH IDENTICAL text, as a courtesy (in the same way as you emailed me)
prior to my being even able to reply on the newsgroup.  Professional!?

> For those of you with an itchy plonk finger, I hope that's enough.

Stonehenge Consulting.  Yes, you certainly are from the dark ages.  Jeez,
how to win friends and influence people.  Not.

Simon Watkins


> 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: Thu, 16 Nov 2000 01:15:27 -0000
From: "Simon Watkins" <siwatkins@iee.org>
Subject: Re: No idea about perl, Long post, short question
Message-Id: <DxGQ5.2113$B02.45523@news6-win.server.ntlworld.com>

Logan Shaw" <logan@cs.utexas.edu> wrote in message
news:8uv8t2$6f4$1@doughboy.cs.utexas.edu...
> In article <EOBQ5.1103$X03.23143@news2-win.server.ntlworld.com>,
> Simon Watkins <siwatkins@iee.org> wrote:
> >Hi, the short question is:
> >
> >How can I amend a perl file that generates html to write the tag <base
> >href="someurl/acatalog/">
>
> Well, you could insert
>
> print '<base href="someurl/acatalog/">';
>
> somewhere in the script.
>
> Of course, that might not work, but since you've given no specifics
> at all about your problem, I can't predict what will work.

Sorry about that - I didn't want to swamp my initial request with too much
detail. But thank you for your assistance.  I'll try and identify the
problem a little more....

On my html page, a link to the shopping cart page would be for instance:

http://localhost/cgi-bin/ca000001.pl?ACTION=SHOWCART

I *believe* the relevant portion of the perl that looks at this call, and
serves the page back to the browser is as follows (I have identified with a
line of ******** where I understand the html is served back to the browser
(my apologies if I'm hopelessly off mark - this is my first time with Perl,
having identified what fixes my issue.  What I would wish to do, is have it
serve the page back to the browser with the <base HREF="domain/acatalog/">
tag in the page header such that document relative links in the html are
resolved correctly. The pages that call the script are in
localhost/acatalog/ and the perl is in the cgi-bin directory.

Does that help any or is any other information required?  I was hoping that
a quick fix as you suggested may have done the trick

sub DispatchCommands
 {
 my (@Response, $Status, $Message, $sHTML, $sAction, $sCartID);
 $::g_sCurrentPage = $::g_InputHash{"PAGE"};   # identify the calling page
 $sAction = $::g_InputHash{"ACTION"};    # check the page action

 #
 # static pages call the shopping cart page via ?ACTION=SHOWCART
 # static pages call the active X order control page via
?ACTION=ORDERACTIVEX
 # static pages call the Java order control page via ?ACTION=ORDERJAVA
 #
 # All other queries are page specific.
 #

 my ($key, $value);
 if ($sAction eq "SHOWCART")      # display the shopping cart - this is a
  {
  @Response = ShowCart();
  ($Status, $Message, $sHTML, $sCartID) = @Response; # parse the response
  if ($Status != $::SUCCESS)
   {
   ACTINIC::ReportError($Message, ACTINIC::GetPath());
   exit;
   }
  PrintPage($sHTML, $sCartID);
******************************************************
  }
 elsif ($::g_sCurrentPage eq "CONFIRMREMOVE")  # the call was made from a
"confirm remove item" page
  {
  while (($key, $value) = each %::g_InputHash) # locate the command button
   {
   if ($value =~ /$::g_sConfirmButtonLabel/ || # found the "Confirm" button
     $value =~ /$::g_sCancelButtonLabel/)  # or the "Cancel" button
    {
    my ($Temp);
    $Temp = keys %::g_InputHash;    # reset the iterator for "each"
    last;
    }
   }
  <remainder of subroutine snipped>

Thanks once more,

Simon






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

Date: Thu, 16 Nov 2000 01:44:10 -0000
From: "Simon Watkins" <siwatkins@iee.org>
Subject: Re: No idea about perl, Long post, short question
Message-Id: <EWGQ5.2149$B02.46160@news6-win.server.ntlworld.com>

"Jon Ericson" <Jonathan.L.Ericson@jpl.nasa.gov> wrote in message
news:8FED98B18JonathanLEricsonjpln@137.78.50.25...
> You should know that Randal is one of the most respected members of the
> Perl community and often gives helpful advice.

Jon,

Thank you for your response.  It may be that we have got off on the wrong
foot, but I do believe his response to me was curt and unnecessary -
however, I may have clouded the issue in which I explained my original
problem. I'll try and explain the position a bit further, as the focus has
shifted completely from what I considered a simple query, into my apparent
desire or otherwise to learn Perl/Customer Support/Helpdesking and other
non-relevant areas.

You asked how to modify a
> script written by someone else, but have no apparant desire to learn Perl.

I have reread my initial post, and I don't understand where you have drawn
the conclusion that I have no desire to learn Perl (no animosity intended).
I would very much like to learn Perl.  Until now, I have not had the need,
as I have primarily been involved with asp and other technology areas - but
we all have to broaden sooner later, and that leads every one of us to being
a newbie sooner or later.  My hand however has been forced because of this
one issue, and after discovering what would fix my problem (seemingly in a
straightforward manner), I decided (rightly or wrongly) to ask for help on a
matter that I believed would be a trivial fix for those with more experience
than I in this area.  I have to admit to being surprised at being greeted to
this newsgroup in such a manner, as the majority of newsgroups that I
frequent and provide support myself do not approach requests for help in
quite such a way.

> Randal pointed out that Actinic should support their product.

I quite agree.  However, as I explained, this really goes beyond manufactuer
support as I am trying to do something that was not originally intended for
the product.  For example, if I was trying to make Microsoft Access do
something it wasn't originally designed for, I would not expect Microsoft to
support me in my endeavours.  I know what will make Actinic Catalog work for
me, and it seemingly is a simple solution.

 This is a
> group for discussing perl,

Perhaps my mistake was even in mentioning Actinic at all.  My question is
all about Perl - it isn't about support for Actinic, quoting styles, or
whether or not I have an apparent desire to learn a product.  Lots of
assumptions are being made, and perhaps I was at fault in my original post
of providing too much information :-)

>not a helpdesk for crappy products that just
> happen to be written in perl.

Again, I come back to my point - I am not asking for helpdesk support.  I
have a need/desire to customize a perl script to have it perform in the way
that I desire because of other customizations I have made to html etc.
Nothing more, nothing less.

Please, either learn Perl so that you can
> provide your own support or find a product that will do what you want.

I will do so but as I'm sure you are aware, we aren't all as skilled in
every area of technology that we would like.  Occasionally, we come across
an area in which we are a newbie.  For me this is one of them.  I am not
ashamed to admit that and am prepared to learn.  But we have to start
somewhere before we can become expert. I was always taught that there is no
such thing as a stupid question - the only stupidity exists in not asking
the question in the first place.  As for finding a product that will do what
I want.  Unfortunately, I am committed to finding a workaround for this
product.  If only the funds were available for a more suitable solution -
but sadly they aren't.  I am trying to customize a low budget product for a
charity trust that provides Kidney Dialysis support and vacations for those
with such a need.  I simply wish to be able to implement the fix (which I
have established) in a technology area that I am not familiar with.  I hope
that clarifies things, and can put an end to the side issues surrounding my
original query.

Kind regards,

Simon
> Jon




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

Date: Thu, 16 Nov 2000 01:48:23 -0000
From: "Simon Watkins" <siwatkins@iee.org>
Subject: Re: No idea about perl, Long post, short question
Message-Id: <G%GQ5.2157$B02.46271@news6-win.server.ntlworld.com>


"Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
news:m1r94cones.fsf@halfdome.holdit.com...
> >>>>> "Simon" == Simon Watkins <siwatkins@iee.org> writes:

> For those of you with an itchy plonk finger, I hope that's enough.

Randal,

<olive branch>It appears that we may have got off on the wrong foot, through
my clouding my initial query with superfluous information, leading to your
seemingly hostile response to my first post in this forum.  On reflection,
and in my experience, these things can get silly and escalate for no
rational reason.  I have explained myself (hopefully with more clarity) in
my reply to Jon Ericson a few minutes ago.  Perhaps we can start again?
</olive branch>

Simon






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

Date: Thu, 16 Nov 2000 01:58:00 -0000
From: "Simon Watkins" <siwatkins@iee.org>
Subject: Re: No idea about perl, Long post, short question
Message-Id: <B7HQ5.2167$B02.46596@news6-win.server.ntlworld.com>

(Also copied retrospectively via email to Randal)
My apologies also for my frustrated and Mr Angry post directed toward
Randal.


"Simon Watkins" <siwatkins@iee.org> wrote in message
news:G%GQ5.2157$B02.46271@news6-win.server.ntlworld.com...
>
> "Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
> news:m1r94cones.fsf@halfdome.holdit.com...
> > >>>>> "Simon" == Simon Watkins <siwatkins@iee.org> writes:
>
> > For those of you with an itchy plonk finger, I hope that's enough.
>
> Randal,
>
> <olive branch>It appears that we may have got off on the wrong foot,
through
> my clouding my initial query with superfluous information, leading to your
> seemingly hostile response to my first post in this forum.  On reflection,
> and in my experience, these things can get silly and escalate for no
> rational reason.  I have explained myself (hopefully with more clarity) in
> my reply to Jon Ericson a few minutes ago.  Perhaps we can start again?
> </olive branch>
>
> Simon
>
>
>
>




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

Date: Wed, 15 Nov 2000 23:20:31 -0000
From: <mischief@velma.motion.net>
Subject: Re: pattern match, file open max size
Message-Id: <t166hv2r8ul6e2@corp.supernews.com>

pygkpygk@my-deja.com wrote:
> Hello,

> I need help on 2 items:

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

m/\\\|/;  # does this not work?


This works for me:
##################### start example ##################
command: cat test2
-----start output-----
$foo = <STDIN>;
chop($foo);
$foo =~ /(\\\|)/;
print("$foo\n");
print("$1\n");
-----end output-----



command: perl test2
-----begin input-----
qwerty\|ytrewq
-----end input-----

-----begin output-----
qwerty\|ytrewq
\|
-----end output-----
#################### end example ####################


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

I'll leave this to someone else. I haven't even been in a room
with an AIX machine in about five years. ;)

> Thanks


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


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

Date: Wed, 15 Nov 2000 23:05:41 GMT
From: stimpiton@my-deja.com
Subject: Prevent web page time out during CGI execution?
Message-Id: <8uv4s1$1oe$1@nnrp1.deja.com>

Is there a way to prevent a web page from timeing out during a CGI
execution?

I have a script that can take quite a long time (3-5 minute) to
compleate each step.

It does a foreach loop to relable backup tapes and the relabling can
take awile and the page times out but the script still runs.

Can I tell the page not to time out?

Cade


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


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

Date: 15 Nov 2000 17:33:05 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Prevent web page time out during CGI execution?
Message-Id: <8uv6fh$666$1@doughboy.cs.utexas.edu>

In article <8uv4s1$1oe$1@nnrp1.deja.com>,  <stimpiton@my-deja.com> wrote:
>Is there a way to prevent a web page from timeing out during a CGI
>execution?

Maybe.  It depends on your HTTP server software.  It's not a Perl
issue.

  - Logan


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

Date: Thu, 16 Nov 2000 09:33:27 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: question about reusing a variable from a regex
Message-Id: <3A130F36.E7E07348@ot.com.au>

Walter van den Berg wrote:

> I have a file like this (it's a kind of sgml used by folioviews):
>
> <RD:level>aaaa<
> <RD>aaaa<
> <RD>aaaa<
> <RD>aaaa<
> <RD:level>bbbb<
> <RD>bbbb<

<snip>

>  s/<RD:$hoogstenivo>(.*?)</<RD:$hoogstenivo><gr:$1>$1</i;
>  $x = $1;
>  s/<RD>/<RD><gr:$x>/i;

<snip>

Your looping logic is where you have gone wrong. You are doing a global
substitution for the "RD:level"s (processing the whole file), and then
trying to do something for each substituted part. You will need either
nested loops, or to do it in a single pass.

As the old adage goes, "you can do anything in a single substitution
statement", so try this (with slight simplifications such as omitting
$hoogstenivo):


#!/usr/bin/perl -w
use strict;

undef $/;
my $current;
for(<DATA>)
{
    s/(<RD(:level)?>)([^<]*)</
        $current = $3 if $2;
        "$1<gr:$current>$current<"/ge;
    print;
}


__END__
<RD:level>aaaa<
<RD>aaaa<
<RD>aaaa<
<RD>aaaa<
<RD:level>bbbb<
<RD>bbbb<
<RD>bbbb<
<RD>bbbb<
<RD:level>cccc<
<RD>cccc<
<RD>cccc<
<RD>cccc<



This gives the following output:

<RD:level><gr:aaaa>aaaa<
<RD><gr:aaaa>aaaa<
<RD><gr:aaaa>aaaa<
<RD><gr:aaaa>aaaa<
<RD:level><gr:bbbb>bbbb<
<RD><gr:bbbb>bbbb<
<RD><gr:bbbb>bbbb<
<RD><gr:bbbb>bbbb<
<RD:level><gr:cccc>cccc<
<RD><gr:cccc>cccc<
<RD><gr:cccc>cccc<
<RD><gr:cccc>cccc<


However, you will need to be careful about your input data. If there is
a chance of bad data, you would be better with some explicit perl loops
and error-checking along the way. If the data between tags can contain
"<" characters, this will need some massaging too. I have also ignored
optional whitespace in order to concentrate on the basic problem. If the
data is all strictly single lines, you could process it line by line and
remember the "aaaa"s between lines, in a similar way to what I have done
in the s///e above.

Regards,


Ian




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

Date: Thu, 16 Nov 2000 12:13:03 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Regex to zero pad an IP address
Message-Id: <8uv5fm$24a$1@hermes.nz.eds.com>


Jack Applin <neutron@jackbert.fc.hp.com> wrote in message
news:8uv3us$5ea$1@fcnews.fc.hp.com...
> Tim Conrow <tim@ipac.caltech.edu> wrote:
>
> > You can do it all in a substitute if you want:
> >
> > $ip =~ s/(\d+)(\.|$)/sprintf "%3.3d$2",$1/eg;
>
> This seemed simpler to me:
>
>   $ip =~ s/(\d+)/sprintf "%03d",$1/eg;

Now that's a good trick.  I didn't realise you could use sprintf in a regex.

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

What's harder to read?  The regex or the output?  If you are talking about
the output, I would probably agree.  This format is for of reverse zone
filenames, eg: rev.192.010.200.000
I think the idea was to make the naming format consistent and help with
sorting them.





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

Date: Wed, 15 Nov 2000 23:04:18 GMT
From: tauras6097@my-deja.com
Subject: unpack
Message-Id: <8uv4pf$1m7$1@nnrp1.deja.com>

Greetings,

Unpacking some binary data and I'm using this:

( @array1, $value1, @array2 ) = unpack( "C11 C C18", $binary_data );

You would think 11 characters would go in @array1, one character in
$value1, and 18 characters in @array2 BUT all characters go into
@array1 and $value1 and @array2 DO NOT get filled.  @array1 goobles up
everything.  What gives?

using Active Perl 5.6 on NT 4.0.


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


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

Date: 15 Nov 2000 17:31:50 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: unpack
Message-Id: <8uv6d6$648$1@doughboy.cs.utexas.edu>

In article <8uv4pf$1m7$1@nnrp1.deja.com>,  <tauras6097@my-deja.com> wrote:
>Unpacking some binary data and I'm using this:
>
>( @array1, $value1, @array2 ) = unpack( "C11 C C18", $binary_data );
>
>You would think 11 characters would go in @array1, one character in
>$value1, and 18 characters in @array2 BUT all characters go into
>@array1 and $value1 and @array2 DO NOT get filled.  @array1 goobles up
>everything.  What gives?

Actually, I'd think that the thing on the right side of
the equals sign creates a list, and then that list is
assigned to the list on the left side of the equals sign.

And when you have an lvalue that itself is a list, then Perl goes
through and assigns stuff to each thing into the list, giving
each the amount of stuff that it wants.  And arrays want a whole
list, so the first array that appears gets whatever's left.

Probably the easiest solution to your problem would be to tell
Perl just what part of the arrays on the left side you want to
write into, so that it doesn't have to assume the whole thing:

	( @array1[0..10], $value1, @array2[0..17] ) =
		unpack("C11 C C18", $binary_data );

One caveat here is that if $array[11] was defined before this
statement, it'll still be defined after it, i.e. you will have
not overwritten the entire array's contents.  But you can solve
that with a "@array1 = @array2 = ();" before the unpack.

Alternatively, you could unpack into a temporary
array and just remove what you want from there:

	@temp = unpack("C11 C C18", $binary_data );
	@array1 = @temp[0..10];
	$value1 = $temp[11];
	@array2 = @temp[12..29];

There are other approaches too, like unpacking each part inividually,
although that is probably too klunky.

  - Logan


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

Date: Thu, 16 Nov 2000 11:18:07 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: unpack
Message-Id: <3A1327BF.BB1B0182@ot.com.au>

tauras6097@my-deja.com wrote:

> Greetings,
>
> Unpacking some binary data and I'm using this:
>
> ( @array1, $value1, @array2 ) = unpack( "C11 C C18", $binary_data );
>
> You would think 11 characters would go in @array1, one character in
> $value1, and 18 characters in @array2 BUT all characters go into
> @array1 and $value1 and @array2 DO NOT get filled.  @array1 goobles up
> everything.  What gives?

You would think that if you weren't very familiar with Perl lists and
unpack. Functions can only return a single flat list, not multiple lists
(unless you return array references...),  and unpack is doing so. You are
assigning this list to another list made up of an array and a scalar and
another array.

The first array gobbles all of the returned list, and the scalar and
second list get undefined/empty. The only common time when assigning to a
list including an array is useful is if there is only one array and it
comes at the end of the list (there are other times you might want to do
this, but they are not pertinent to this problem).

You can use array slices to achieve the effect you want, as long as you
know how many elements you need (which you appear to, in this case):


perl -e '(@a[1..3], $scalar, @b) = qw(fdas asdsad sad dfsa ads sfda a fd
asdf sadf df fds); print "\@a: @a\n\$scalar: $scalar\n@b\n";'

@a:  fdas asdsad sad
$scalar: dfsa
ads sfda a fd asdf sadf df fds


Regards,


Ian




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

Date: Thu, 16 Nov 2000 00:28:03 -0000
From: <mischief@velma.motion.net>
Subject: Re: Webpage logging script for number of simulaneous users???
Message-Id: <t16agj55pgp37e@corp.supernews.com>

vnova94@hotmail.com wrote:
> Does anyone know of a script that will show at any particular time,
> what the number of users are currently viewing a webpage?

I can't show you a script that will do this, and i can promise
you that no one else can, either. A web page isn't viewed on an open
socket like a telnet connection. A web page is fetched, then viewed
on the client machine. The browser/server pair generally let the
socket close not just after each page but after each file. This
means framesets, graphics, or anything else that is embedded as a 
separate file i generally downloaded by itself. There is a method
to allow a browser to ask a server to keep the socket open for a few
requests, but you still can't tell if someone is viewing a page based
on that.


If what you mean is, by looking at the logs, can you tell who has
requested files from your web server in the last $n minutes, then
this is a mild variation on a FAQ. There are several ways already
around to monitor logs.

> Thanks,

> Matt


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


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

Date: Thu, 16 Nov 2000 01:07:11 GMT
From: hydsys@my-deja.com
Subject: Win32::ODBC Fetchrow() problem
Message-Id: <8uvbvr$7oe$1@nnrp1.deja.com>

I'm trying to use Win32::ODBC to access data from WDPF, a Westinghouse
process control system, using ODBC. I can connect OK, but when I try to
fetch rows I fail, and ODBC tracing indicates that Perl is calling
SQLExtendedFetch, which the ODBC driver does not support. As I am doing
only the most basic operations I'm wondering why SQLExtendedFetch method
is being called, and not SQLFetch? Is it something I've done
inadvertently?

I'm using Activestate Perl build 522, Win32::ODBC from
Win32ODBC_v920208.zip

The data can be retrieved from Excel using ODBC, but not from Perl. Any
help appreciated.

Peter Heweston
HYDSYS Pty Ltd


Code:

use Win32::ODBC;

main: {

 $dbf = new Win32::ODBC("DSN=w_odbc;UID=xxxx;PWD=xxxx");
 $pointname='BC8-HMWH01.BC8@sce';

 if (! $dbf->Sql("SELECT *  FROM OAUSER.POINT_HISTORY POINT_HISTORY
WHERE
   (POINT_HISTORY.POINT_NAME='$pointname') AND
   (POINT_HISTORY.START_TIME={d '2000-11-08'}) AND
   (POINT_HISTORY.INTERVAL_LENGTH=900) AND
   (POINT_HISTORY.END_TIME=\{d '2000-11-13'\})"
 )){

  print "point name=$pointname\n";

  @FieldNames = $dbf->FieldNames();
  print join(',',@FieldNames),"\n";
# I get a list of field names back OK, just no data follows:
  while ($dbf->FetchRow()){
    print "Row ";
    undef %data;
    %data=$dbf->DataHash();
    foreach $k (keys(%data)){
      print "key=$k val=$data{$k}\n";
    }
  }
 }
 $dbf->Close();
}



ODBC trace:


PERL.EXE junk   ffc293ad:ffc3f77d	EXIT  SQLExtendedFetch  with
return code -1 (SQL_ERROR)
		HSTMT               0x00be1880
		UWORD                        1 <SQL_FETCH_NEXT>
		SDWORD                     1
		UDWORD *            0x0063fba0
		UWORD *             0x0083a8d0

		DIAG [IM001] [Microsoft][ODBC Driver Manager] Driver
does not support this function (0)

		DIAG [IM001] [Microsoft][ODBC Driver Manager] Driver
does not support this function (0)




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


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

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 4898
**************************************


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