[18533] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 701 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 15 00:07:34 2001

Date: Sat, 14 Apr 2001 21: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)
Message-Id: <987307509-v10-i701@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 14 Apr 2001     Volume: 10 Number: 701

Today's topics:
        an example Re: How can u group together fields and sum  (sdfsd)
    Re: an example Re: How can u group together fields and  (Logan Shaw)
    Re: an example Re: How can u group together fields and  (sdfsd)
    Re: an example Re: How can u group together fields and  (Gwyn Judd)
    Re: Easy Perl Question... (Logan Shaw)
    Re: Easy Perl Question... <robbie@totaln.com>
    Re: Easy Perl Question... <xris@dont.send.spam>
    Re: Easy Perl Question... <robbie@totaln.com>
    Re: Easy Perl Question... <xris@dont.send.spam>
    Re: Easy Perl Question... <robbie@totaln.com>
        FAQ .:   How to contribute to this document <faq@denver.pm.org>
        Flame Target <msoftmonkeySPAM@crosswinds.net>
        Graphics in windows?? <cryofan@MailAndNews.com>
    Re: Graphics in windows?? (Eric Bohlman)
        Help me decide what talks to give at YAPC this year <mjd@plover.com>
    Re: How can u group together fields and sum them up (sdfsd)
    Re: How can u group together fields and sum them up (Logan Shaw)
    Re: How can u group together fields and sum them up (sdfsd)
    Re: How can u group together fields and sum them up (Abigail)
    Re: How can u group together fields and sum them up (sdfsd)
    Re: Laziness, Impatience and Hubris  :-) (Damian James)
    Re: Laziness, Impatience and Hubris  :-) (Si Ballenger)
    Re: newbie: DBI:ODBC and M/S SQL Server <djmarcus@ex-pressnet.com>
    Re: perl equivalent for (char) long_var in C ? (Logan Shaw)
        SV: perl equivalent for (char) long_var in C ? <chho@privat.utfors.se>
    Re: to get a PId <bowman@montana.com>
    Re: to get a PId <guillaume.3@free.fr>
        why i posted (sdfsd)
    Re: why i posted (Eric Bohlman)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 14 Apr 2001 17:14:05 -0500
From: sdfes@dsf.com (sdfsd)
Subject: an example Re: How can u group together fields and sum them up
Message-Id: <3ad8caff$0$58087$45beb828@newscene.com>

the reca are single line like the following fixed lenght no delimiter each 
line independent of the other ones.

543343404022001x10000003465Yx20000006573Yx30000000124Nx70000007534Y

acct  7 chars
date  8 chars
type1  2 chars 
amount 10 chars
billable 1 char
type2  2 chars 
amount 10 chars
billable 1 char
type3  2 chars 
amount 10 chars
billable 1 char
type4  2 chars 
amount 10 chars
billable 1 char


a good rec looks like this

543343404022001x10000003465Yx20000006573Yx30000000124Nx60000007534Y

a 

bad one like this 

543343404022001x10000003465Yx20000006573Yx30000000124Nx20000007534Y

(note that there are two x2 one with 6573 and the other with 7534)

what we need is :

543343404022001x10000003465Yx20000014107Yx30000000124N

note that now there is only one x2 and the amounts have been added together





In article <x7y9t3kxr6.fsf@home.sysarch.com>, Uri Guttman <uri@sysarch.com> 
wrote:
>>>>>> "s" == sdfsd  <sdfes@dsf.com> writes:
>
>  >> So I have no idea what the data format is.  
>
>  s> it is fixed lenght each line is 256 characters long with each field
>  s> taking up a fixed amount of space.  the types are all there 9 of
>  s> them, but some have 0 for amount.  It may be possible to add a
>  s> delimiter.
>
>use unpack for fixed width fields.
>
>  s> one other req is for the program to grab one of the fields and use
>  s> it to do a lookup to a table (its a file that can be load into
>  s> mem).
>
>repost with an example of that and clarify the operations you need on
>each record.
>
>uri
>


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

Date: 14 Apr 2001 17:31:25 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: an example Re: How can u group together fields and sum them up
Message-Id: <9baj3t$aqf$1@charity.cs.utexas.edu>

In article <3ad8caff$0$58087$45beb828@newscene.com>,
sdfsd <sdfes@dsf.com> wrote:
>the reca are single line like the following fixed lenght no delimiter each 
>line independent of the other ones.
>
>543343404022001x10000003465Yx20000006573Yx30000000124Nx70000007534Y
>
>acct  7 chars
>date  8 chars
>type1  2 chars 
>amount 10 chars
>billable 1 char
>type2  2 chars 
>amount 10 chars
>billable 1 char
>type3  2 chars 
>amount 10 chars
>billable 1 char
>type4  2 chars 
>amount 10 chars
>billable 1 char
>
>
>a good rec looks like this
>
>543343404022001x10000003465Yx20000006573Yx30000000124Nx60000007534Y
>
>a 
>
>bad one like this 
>
>543343404022001x10000003465Yx20000006573Yx30000000124Nx20000007534Y
>
>(note that there are two x2 one with 6573 and the other with 7534)
>
>what we need is :
>
>543343404022001x10000003465Yx20000014107Yx30000000124N
>
>note that now there is only one x2 and the amounts have been added together

Wow, that's nothing like the example you gave before. 

Now I really don't understand the format.  For one thing, I understand
that certain things are certain widths (date is 8 characters), but
I don't understand what that has to do with anything.  Is there
some table that says that e.g. "x2" means "date"?

Even if there is, I don't understand how that would work, because what
if "x20" means "foo" and "foo" fields are 10 characters long, but
"x200" means "bar" and "bar" fields are 9 characters long?  Then,
this:

	x200000000042

could either be a foo:

	x200000000042
	\-/\--------/
	foo   value

or a bar:

	x200000000042
	\--/\-------/
	bar   value

Or maybe there is some fixed number of digits after the "x" that are
part of the "x" number.

Also, the character "Y" seems to appear lots of times.  What's that?

At any rate, the answer to your original question is that Perl can
definitely provide a solution, and it can probably do it faster than
your current tool is doing.

C++ could certainly do it even faster, but whether you need that or not
is hard to tell.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: 14 Apr 2001 17:50:04 -0500
From: sdfes@dsf.com (sdfsd)
Subject: Re: an example Re: How can u group together fields and sum them up
Message-Id: <3ad8d380$0$58087$45beb828@newscene.com>

sorry let me elbaorate

>
>Now I really don't understand the format.  For one thing, I understand
>that certain things are certain widths (date is 8 characters), but
>I don't understand what that has to do with anything.  Is there
>some table that says that e.g. "x2" means "date"?

all recs are of fixed lenght and will be given to sql*loader an oracle util.  
We tell it the the first 7 character will be an acct number the next 10 a date 
(it will convert 04022001 to april 02, 2001) and the next 2 are the type etc

so for the first rec 
the acct number is 5433434
the date is 04022001
the type is x1
the amount is 0000003465
the billable is Y

the amount is 10 digit number with leading zeores due to being fixed lenght 
they are left padded (you can probably guesss that this came from a mainframe)

>
>Even if there is, I don't understand how that would work, because what
>if "x20" means "foo" and "foo" fields are 10 characters long, but
>"x200" means "bar" and "bar" fields are 9 characters long?  Then,
>this:
>
>        x200000000042
>
>could either be a foo:
>
>        x200000000042
>        \-/\--------/
>        foo   value
>
>or a bar:
>
>        x200000000042
>        \--/\-------/
>        bar   value
>
>Or maybe there is some fixed number of digits after the "x" that are
>part of the "x" number.
the type is 2 digits x1 the rest are ppart of the 10 digit number


>
>Also, the character "Y" seems to appear lots of times.  What's that?
just a flag we dont do anything with it


>
>At any rate, the answer to your original question is that Perl can
>definitely provide a solution, and it can probably do it faster than
>your current tool is doing.
>
>C++ could certainly do it even faster, but whether you need that or not
>is hard to tell.
we dont have C++ experience.




>
>  - Logan


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

Date: Sun, 15 Apr 2001 01:06:44 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: an example Re: How can u group together fields and sum them up
Message-Id: <slrn9dht13.fht.tjla@thislove.dyndns.org>

I was shocked! How could sdfsd <sdfes@dsf.com>
say such a terrible thing:
>>At any rate, the answer to your original question is that Perl can
>>definitely provide a solution, and it can probably do it faster than
>>your current tool is doing.
>>
>>C++ could certainly do it even faster, but whether you need that or not
>>is hard to tell.
>we dont have C++ experience.

What does that have to do with the price of fish? As far as I can tell,
you yourself haven't written a single line of code in *Perl* either, yet
here you are expecting some of the most talented Perl programmers on the
planet to write this program for you. I suggest you go and troll the
C/C++ newsgroups for a while, based on the success you are having here
you should perform marvels over there. That's all I really have to say
about that, except to say I am surprised at the amount of energy some of
the regulars are spending here to get a decent sort of specification out
of this person.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
If you remember the 60's, you weren't there.


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

Date: 14 Apr 2001 17:11:09 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Easy Perl Question...
Message-Id: <9bahtt$am1$1@charity.cs.utexas.edu>

In article <D73C6.26102$PF4.42458@news.iol.ie>,
RobbieB <robbie@totaln.com> wrote:
>I am a newbie to perl. Basically, I wanted to know, if I can create a Link,
>in a script, to another part of that script?

Sure, use goto.

> Use a form in a script, have it
>parsed by that script, and then the content of the form used by that script?

Oh wait, you don't want to create a link to another part of a script.
You want your script (which is apparently a CGI) to run and do
different things depending on its input.  In that case, I'd say you
want the input to be different based on what you want it to do, and you
probably want to have some sort of conditional ("if") statement that
does different things based on the input.  Since this is a CGI, of
course the input is likely to be CGI parameters.  The documentation for
the "CGI" module will tell you how to work with parameters.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Sat, 14 Apr 2001 23:18:12 GMT
From: "RobbieB" <robbie@totaln.com>
Subject: Re: Easy Perl Question...
Message-Id: <UU4C6.26128$PF4.42451@news.iol.ie>

Hi,

hmm, okay, I know this is asking a helluva lot(maybe?)..but, could anyone
write me a scirpt, without -w, use strict or any of that, jsut, the most
basic of basic script.. that showed me the code which would do the following

Parse a form, using the &form; subroutine(a custom subroutine I would use).

Print some content saying 'Hello, username' where, username, would be gotten
from the form.

Print two links 'Link 1' and 'Link 2', which, both, when clicked brought you
to two different parts of the same script(if you can understand that(?))

so, far, I have this:

---
#!/path/to/perl

print "Content-type: text/html"; #mime-line

&form; #parse the form

$username = $formdata{'username'}; #define the variable $user using input
from the form.

print "Hello, $username\n"; #print Hello, $username, where $username is the
variable we defined earlier
---

see, this is where my problem arises, I dont know what to link to in order
to get to different parts of the same CGI file?? I dont know if thats very
unbderstandable, I guess if it isn't I will just have to figure it out
myself.

Again, thanks for the quick replys and any further help you wish to
volunteer...


--Robbie Burke












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

Date: Sat, 14 Apr 2001 21:16:49 -0500
From: xris <xris@dont.send.spam>
Subject: Re: Easy Perl Question...
Message-Id: <xris-19C409.21164314042001@news.evergo.net>

In article <UU4C6.26128$PF4.42451@news.iol.ie>,
 "RobbieB" <robbie@totaln.com> wrote:

> #!/path/to/perl
> 
> print "Content-type: text/html"; #mime-line
> 
> &form; #parse the form
> 
> $username = $formdata{'username'}; #define the variable $user using input
> from the form.
> 
> print "Hello, $username\n"; #print Hello, $username, where $username is the
> variable we defined earlier


Do you want something like:

#!/path/to/perl

print "Content-type: text/html"; #mime-line

&form; #parse the form

if ($formdata{stage} == 1) {
   &stage1;
}
elsif ($formdata{stage} == 2) {
   &stage2;
}
elsif (! defined $formdata{stage}) {
   print "Hello, $formdata{username}<p>",
         '<A HRef="this.cgi?stage=1">Link 1</A><BR>',
         '<A HRef="this.cgi?stage=2">Link 2</A><BR>';
}

exit(0);

?



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

Date: Sun, 15 Apr 2001 02:45:37 GMT
From: "RobbieB" <robbie@totaln.com>
Subject: Re: Easy Perl Question...
Message-Id: <lX7C6.26149$PF4.41914@news.iol.ie>

Hi,

man, this is hard to explain, right, forget about forms and variables and
stuff, I want to be able to link from one part of a script to another part
of the same script,

#!/usr/bin/perl
print "Content-type: text/html";

&partA;

sub partA {
    print "Here is a link to partB <a href=\"WHAT DO I PUT HERE IN ORDER TO
HOP TO partB\">link text</a>\n";
}
sub partB {
    print "Bleh";
}



basically, I wanna know what to put in the <a href=""> tag in order to go to
partB of my script??




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

Date: Sat, 14 Apr 2001 22:12:37 -0500
From: xris <xris@dont.send.spam>
Subject: Re: Easy Perl Question...
Message-Id: <xris-4494A6.22123714042001@news.evergo.net>

In article <lX7C6.26149$PF4.41914@news.iol.ie>,
 "RobbieB" <robbie@totaln.com> wrote:

> basically, I wanna know what to put in the <a href=""> tag in order to go to
> partB of my script??

didn't my example do that?  You just create a form variable that tells 
your script where to go, and when your script executes, check that 
variable to see what the script is supposed to be doing.  I use this 
method all the time with ecommerce stuff to keep track of things like 
where a customer is in the middle of a checkout process, or which page 
of search results he/she is looking at....



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

Date: Sun, 15 Apr 2001 03:39:22 GMT
From: "RobbieB" <robbie@totaln.com>
Subject: Re: Easy Perl Question...
Message-Id: <KJ8C6.26152$PF4.42109@news.iol.ie>

Hi,

oh, so it did, sorry, its 4:40am over here, i wasn't looking very hard,
thanks man!!

--Robbie Burke




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

Date: Sun, 15 Apr 2001 00:17:02 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ .:   How to contribute to this document
Message-Id: <2M5C6.977$T3.191708672@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How to contribute to this document

    You may mail corrections, additions, and suggestions to
    perlfaq-suggestions@perl.com . This alias should not be used to *ask*
    FAQs. It's for fixing the current FAQ. Send questions to the
    comp.lang.perl.misc newsgroup.

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep comming up.  If you are some how irritated by
seeing these postings you are free to ignore them or add the sender
to your killfile.  If you find errors or other problems with these
postings please send corrections or comments to the posting email
address.

If you are not able to find this or other Perl documentation from
your installation you may access it via the web by following the
appropriate links from one of the addresses listed below.

    http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search
    http://www.perldoc.com
    http://www.cpan.org
    http://www.perl.com

Answers to questions about LOTS of other stuff, mostly not related to
Perl, can be found at

    news:news.answers

and in the many thousands of other useful Usenet news groups.

Please note that the FAQ text posted by this server has been modified
from that distributed in the stable Perl release.  It has been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ is available on request.

The perlfaq manual pages contain the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

    When included as an integrated part of the Standard
    Distribution of Perl or of its documentation (printed or
    otherwise), this work is covered under Perl's Artistic
    License.  For separate distributions of all or part of
    this FAQ outside of that, see the perlfaq manpage.

    Irrespective of its distribution, all code examples here
    are public domain.  You are permitted and encouraged to
    use this code and any derivatives thereof in your own
    programs for fun or for profit as you see fit.  A simple
    comment in the code giving credit to the FAQ would be
    courteous but is not required.

This work is provided in the hope that it will be useful but does
not represent a commitment of any kind on the part of the contributers,
authors or their agents.
-- 
    This space intentionally left blank


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

Date: Sat, 14 Apr 2001 23:05:37 -0400
From: "Joseph André" <msoftmonkeySPAM@crosswinds.net>
Subject: Flame Target
Message-Id: <9bb38j$8jbaf$1@ID-50051.news.dfncis.de>

Hello, I am new to Perl, but not to programming. My question is about CGI
programming in Perl at Tripod. Specifically, I wrote my first script, here
it is:

#!/usr/local/bin/perl

print <<END;

Content-Type: text/html\n\n



<html>

<body bgcolor="#000000" text="#ffffff">
BOO!
</body>

</html>

END


and the URL is http://wmbgt.tripod.com/cgi-bin/script.pl
If you go there, you will find that the browser seems to be loading for
about a minute, and then you get this error:

Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /cgi-bin/script.pl.

Reason: Could not connect to remote machine: Connection timed out




Can anyone tell me what I'm doing wrong? Or is it Tripod's fault? Are there
special things I have to worry about at Tripod that would affect this? This
is my first attempt at a Perl script remember, however I am an experienced
Javascripter, HTMLer, and semi-experienced C++er. Or else, flame me, tell me
my question is off topic for some unforseen reason, and refer me to an FAQ,
as I have seen happen countless times to other people on other newsgroups.
Thanks very much.

Joseph




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

Date: Sat, 14 Apr 2001 20:41:58 -0400
From: Joe Morris <cryofan@MailAndNews.com>
Subject: Graphics in windows??
Message-Id: <3B0C61B5@MailAndNews.com>

Thanks for all the help everyone here has given me. My senior project rolls 
toward completion--2 weeks and counting...or thereabouts.

I have another question though:
I want to do some graphs for my demo. These would graph some data stored on 
the hard drive of the Windows machine that I am using for the classroom 
demo. 
This would not be a CGI program. I installed the GD module at home on my 
Windows 98 box and pasted in a generic graphics script (I think it drew a 
line, or tried to) and tried to run it from the command line in the dos box. 
It did not draw a line, and did not output an error, but instead just 
printed 
a bunch of noise characters.

Can I draw graphs using GD on my windows box? Do I need some other module? 
GIMP?

Afterward, I installed tk and was able to draw a line in a tk window. That 
might serve my needs; I don't know though-- I will need to draw some pretty 
hairy graphs, such as integration of data points, etc.

Any thoughts?



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

Date: 15 Apr 2001 04:02:11 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Graphics in windows??
Message-Id: <9bb6g3$d4b$2@bob.news.rcn.net>

Joe Morris <cryofan@mailandnews.com> wrote:
> I have another question though:
> I want to do some graphs for my demo. These would graph some data stored on 
> the hard drive of the Windows machine that I am using for the classroom 
> demo. 
> This would not be a CGI program. I installed the GD module at home on my 
> Windows 98 box and pasted in a generic graphics script (I think it drew a 
> line, or tried to) and tried to run it from the command line in the dos box. 
> It did not draw a line, and did not output an error, but instead just 
> printed 
> a bunch of noise characters.

> Can I draw graphs using GD on my windows box? Do I need some other module? 
> GIMP?

> Afterward, I installed tk and was able to draw a line in a tk window. That 
> might serve my needs; I don't know though-- I will need to draw some pretty 
> hairy graphs, such as integration of data points, etc.

> Any thoughts?

I'd say go with Tk, and if the Canvas widget really turns into a
bottleneck, use GD to generate PNG graphs and use Tk::PNG to display them.  
The problem you were running into is that the Win32 console (aka "Dos
prompt") doesn't have a built-in PNG viewer, so just sending the bytes of
a PNG image to it will result in what looks like a bunch of junk
characters.


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

Date: Sat, 14 Apr 2001 21:02:11 -0400
From: Mark-Jason Dominus <mjd@plover.com>
Subject: Help me decide what talks to give at YAPC this year
Message-Id: <20010415010211.32734.qmail@plover.com>


Once again, I am unable to decide what talks to present at YAPC.
If you plan to attend YAPC in Montreal this June, please wander over
to

        http://perl.plover.com/yak/yapc.cgi

and let me know where your interests lie.

If you *don't* plan to attend YAPC, feel free to take a look, but
please don't submit the form.

Thanks.


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

Date: 14 Apr 2001 17:15:08 -0500
From: sdfes@dsf.com (sdfsd)
Subject: Re: How can u group together fields and sum them up
Message-Id: <3ad8cb5c$0$58087$45beb828@newscene.com>

are u sayign that perl needs to have everything in memory?
the whole file?

or does it read a line at a time

In article <slrn9dhhu8.j76.abigail@tsathoggua.rlyeh.net>, abigail@foad.org 
wrote:
>Tad McClellan (tadmc@augustmail.com) wrote on MMDCCLXXXIII September
>MCMXCIII in <URL:news:slrn9dh6o8.jma.tadmc@tadmc26.august.net>:
>][ Ciaran McCreesh <keesh@users.pleaseremovethisbit.sourceforge.net> wrote:
>][ >In article <3ad89ff5.62af$1d8@news.op.net>, mjd@plover.com  wrote:
>][ >> Your vendor is incompetent.  My Perl program (seven lines long)
>][ >> processed 20,000 records in 10.725 seconds.  This is 100 million records
>][ >> in 15 hours, the same as your vendor---but my program was running on a
>][ >> Pentium 233.  Using your modern hardware should cut this by an order of
>][ >> magnitude.
>][ >
>][ >Is it a linear relationship? 
>][ 
>][ Yes.
>][ 
>
>Yes, but it's not so simple.
>
>20,000 records might easily fit in RAM, and the program wouldn't need
>to do much swapping. With 100 million records (assuming a relative low
>number of duplicates), it's very likely the program starts swapping like
>a mad man, and will even die part of the way if you don't have enough
>swap space.
>
>If you would make a graph of size vs running time, you're likely to
>see something that resembles two line segments, sharing a common point.
>And right of the common point, the line segment is much steeper than on
>the left. The common point of course indicates where the program starts
>to swap.
>
>
>
>Abigail


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

Date: 14 Apr 2001 17:22:04 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How can u group together fields and sum them up
Message-Id: <9baiic$ap4$1@charity.cs.utexas.edu>

In article <3ad8cb5c$0$58087$45beb828@newscene.com>,
sdfsd <sdfes@dsf.com> wrote:
>are u sayign that perl needs to have everything in memory?
>the whole file?

No, someone asked a question about hashes, and Abigail was explaining
how hashes work in general.

Perl can happily either process a file line by line:

	while (<>)
	{
		# do something
	}

or the whole file at once:

	foreach (<>)
	{
		# do something
	}

Hope that helps.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: 14 Apr 2001 17:23:08 -0500
From: sdfes@dsf.com (sdfsd)
Subject: Re: How can u group together fields and sum them up
Message-Id: <3ad8cd2e$0$58087$45beb828@newscene.com>


see my followup post

breaking up the recs is not needed in ffact better not too. so a one tp one 
relationships would be fine

what is needed is to sum up the dupes



In article <3ad8c927.6684$352@news.op.net>, mjd@plover.com (Mark Jason 
Dominus) wrote:
>In article <slrn9dhhu8.j76.abigail@tsathoggua.rlyeh.net>,
>Abigail <abigail@foad.org> wrote:
>>][ >Is it a linear relationship? 
>>][ 
>>][ Yes.
>>][ 
>>
>>Yes, but it's not so simple.
>
>Perhaps I misunderstood the task, but the program I wrote has a fixed
>memory requirement.
>
>The question turns on whether, given the following two records of input:
>
>125      x2  34        x41   43            x14  76          x54   54 
>125    x2  34      x41  43      x2  76        x41  54      x14  65
>
>should the output contain seven records, or only four?
>
>My understanding of the original question was that the output should
>contain seven records:  Four from the first input record, and
>three from the second.
>


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

Date: Sat, 14 Apr 2001 23:28:15 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: How can u group together fields and sum them up
Message-Id: <slrn9dhn8f.j76.abigail@tsathoggua.rlyeh.net>

Mark Jason Dominus (mjd@plover.com) wrote on MMDCCLXXXIII September
MCMXCIII in <URL:news:3ad8c927.6684$352@news.op.net>:
== In article <slrn9dhhu8.j76.abigail@tsathoggua.rlyeh.net>,
== Abigail <abigail@foad.org> wrote:
== >][ >Is it a linear relationship? 
== >][ 
== >][ Yes.
== >][ 
== >
== >Yes, but it's not so simple.
== 
== Perhaps I misunderstood the task, but the program I wrote has a fixed
== memory requirement.
== 
== The question turns on whether, given the following two records of input:
== 
== 125      x2  34        x41   43            x14  76          x54   54 
== 125    x2  34      x41  43      x2  76        x41  54      x14  65
== 
== should the output contain seven records, or only four?
== 
== My understanding of the original question was that the output should
== contain seven records:  Four from the first input record, and
== three from the second.


I remember "summing up duplicates", so I would say 4. And since it wasn't
given that identical labels follow each you've got to store what you've
seen so far.

Maybe I misunderstood, but if you can just process line by line, without
keeping history, the problem is utterly simple, so simple I doubt the awk
people shied away from it. It also makes you wonder why the vendor was
sorting.



Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: 14 Apr 2001 19:06:05 -0500
From: sdfes@dsf.com (sdfsd)
Subject: Re: How can u group together fields and sum them up
Message-Id: <3ad8e564$0$58087$45beb828@newscene.com>


it is line by line.
AWK people were concerned the speed would be too slow

the vendor had a preexisting package that sorts and does other things too
so they used it.  but its not that fast

>
>Maybe I misunderstood, but if you can just process line by line, without
>keeping history, the problem is utterly simple, so simple I doubt the awk
>people shied away from it. It also makes you wonder why the vendor was
>sorting.
>
>
>
>Abigail


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

Date: 14 Apr 2001 22:18:31 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Laziness, Impatience and Hubris  :-)
Message-Id: <slrn9dhj38.hd2.damian@puma.qimr.edu.au>

Si Ballenger chose Fri, 13 Apr 2001 17:08:03 GMT to say this:
>>
>>  SB> So..., how do you really feel? Don't be shy! Grunt big for daddy
>>  SB> and you will feel a lot better.  ;-)
>>  ...
>Come on Uri, I've been trolling for usenet a**wipes all morning.
>Can't cut the line now and let you get away. ;-)

This is getting ridiculous. FOAD, troll.

*plonk*

Cheers,
Damian
-- 
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;){;(
$:=rand$;+$|)==$;&&next;@;[$;,$:]=@;[$:,$;]}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker # rev 3 -- a JAPH in progress, I guess...


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

Date: Sun, 15 Apr 2001 02:22:22 GMT
From: shb@vnet.net (Si Ballenger)
Subject: Re: Laziness, Impatience and Hubris  :-)
Message-Id: <3ad90437.86573888@166.82.1.9>

On 14 Apr 2001 22:18:31 GMT, damian@qimr.edu.au (Damian James)
wrote:

>This is getting ridiculous. FOAD, troll.
>
>*plonk*

AKA in usenet: "I'm going to go now and hide under mommies skirt
where you can't get me."  ;-)

>Cheers,
>Damian

 Yes, have a nice day!


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

Date: Sat, 14 Apr 2001 21:32:35 -0400
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: Re: newbie: DBI:ODBC and M/S SQL Server
Message-Id: <tdhuhb2qopsj82@corp.supernews.com>

I had a similar problem... The error is in the parameter to DBI->connect.
It should read:
        DBI->connect( "dbi:ODBC:TestDB", 'sa', ''') or die...

In other words, get rid of the 'DSN='.

-Regards
David


"Chris" <cpryce@pryce.net> wrote in message
news:B6F3579B.279B%cpryce@pryce.net...
> in article tcp2mn12vs5v15@corp.supernews.com, David J. Marcus at
> djmarcus@ex-pressnet.com wrote on 04/05/2001 10:10 AM:
>
> > When I list the available ODBC drivers (using example in Programming the
> > Perl DBI book), it shows:
> >
> > Driver: ODBC
> >       Data Source is DBI:ODBC:Visual FoxPro Database
> >       . . .
> >       Data Source is DBI:ODBC:TestDB
> >       . . .
> >
> > So I know that the ODBC connection is there.
> >
> > In my test program I:
> >       my $conn = DBI->connect( "dbi:ODBC:DSN=TestDB", 'sa', ''') or
die...
> >       my $sth = $conn->prepare( " CREATE TABLE ..."} or die...
> >       $sth->execute or die...
> >
> > The connect fails with the following error message:
> >   DBI->connect(DSN=TestDB) failed: [Microsoft][ODBC Driver Manager] Data
> > source name not found and no default driver specified (SQL-IM002)(DBD:
> > db_login/SQLConnect err=-1)
> >
> > I am suspecting that I am not specifying the DSN properly.
>
> I suspect (although I can't say for certain, having never worked with perl
> in win32) that you are correct. If the example script lists:
>
> >       Data Source is DBI:ODBC:TestDB
>
> Then I would try that in my connect string, as in:
>
> my $conn = DBI->connect( "dbi:ODBC:TestDB", 'sa', ''') or die...
>
> Also, keep in mind that the Programming the DBI book is wonderful, but it
> only covers DBI::ODBC version 2.0. Current is 2.8 (?) and includes a few
> significant changes.
>
> cp
>
>




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

Date: 14 Apr 2001 17:05:29 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: perl equivalent for (char) long_var in C ?
Message-Id: <9bahj9$ak6$1@charity.cs.utexas.edu>

In article <9ba9rp$all$1@yggdrasil.utfors.se>,
Christer Holmdahl <chho@privat.utfors.se> wrote:
>I'm a newbie (i admit) to Perl and I'm trying to convert an old C =
>program.
>Is there a Perl equivalent for (char)long_var in C?

Not exactly.  In Perl there aren't several integer types of varying
sizes.

If you want to take a character (usually ascii) code and convert
it into an actual character, then use chr().

If you want to convert an integer into a quantity no bigger
than what you'd store in a byte, use pack, i.e.

	$byte = pack ("C", $integer);

It might help if you explained more about what you are trying to do.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Sun, 15 Apr 2001 00:26:46 +0200
From: "Christer Holmdahl" <chho@privat.utfors.se>
Subject: SV: perl equivalent for (char) long_var in C ?
Message-Id: <9baioa$c5q$1@yggdrasil.utfors.se>

It's a small function that looks like this:


void xorbuf(char *buf, int nrbytes, long key1, long key2, int and_f)
{
  int i;

  if (nrbytes>0) {
    for (i=0;i<nrbytes;i++) {
      for (;;) {
        *(buf+i) ^= (((char)key2 * (char)(i+key1)) & (char)and_f);

        if (isAllowed(*(buf+i))) {
         break;
        }
      }
    }
  }
}


Regards

/Christer





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

Date: Sat, 14 Apr 2001 16:54:42 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: to get a PId
Message-Id: <_r4C6.2016$ph.4701@newsfeed.slurp.net>


"guillaume" <guillaume.3@free.fr> wrote in message
news:h22C6.442$yP4.892013@nnrp6.proxad.net...
> thank you, but i'm under Win32.

which Win32? if WMI is present (default on 2000, may be installed on Win95
and up) you can query it.On NT, you can get it by iterating through the
process objects in HKEY_PERFORMANCE_DATA and reading the 'Id Process'
counter.





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

Date: Sun, 15 Apr 2001 00:39:50 GMT
From: "guillaume" <guillaume.3@free.fr>
Subject: Re: to get a PId
Message-Id: <q56C6.918$uS1.1498242@nnrp1.proxad.net>

bowman a écrit:

>which Win32? if WMI is present (default on 2000, may be installed on Win95
>and up) you can query it.

it's Win95. What do you call WMI? a sort of Windows manager interface?

guillaume.3@free.fr



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

Date: 14 Apr 2001 21:13:11 -0500
From: sdfes@dsf.com (sdfsd)
Subject: why i posted
Message-Id: <3ad90331$0$58093$45beb828@newscene.com>

I asked not because i wanted somebody to write the program for me.  We have 
already done it in C (not C++, since we dont have the expertise) to replace 
Cosort job that was taking too long.

I had heard good things about Perl and AWK and placed messages in both groups 
to see how they would approach problem and if it provided a better or faster 
solution.  

I was not asking for a written problem but basically  
1 - can perl do this
2-  if so give can u give a basic outline so we can expend on it and test it 
out

We are mainly an Oralce pl/sql and C shop and I was interested to see if we 
could get some new tools like Perl or AWK.  This problem seem like a good 
choice to see if they could help since it was file manipluation which was 
based the strong points as i understand for Perl.

I am sorry the spec was so poor but i though question was clear baically 
dealing with duplicate data.  a field appears twice or more in a line what i 
want is to group it together.  i was a bit supprised that people were asking 
about delimiters and such since i took that as a non issue.  but that is 
probably due to my poor knowledge of perl

In article <slrn9dht13.fht.tjla@thislove.dyndns.org>, tjla@guvfybir.qlaqaf.bet 
(Gwyn Judd) wrote:
>I was shocked! How could sdfsd <sdfes@dsf.com>
>say such a terrible thing:
>>>At any rate, the answer to your original question is that Perl can
>>>definitely provide a solution, and it can probably do it faster than
>>>your current tool is doing.
>>>
>>>C++ could certainly do it even faster, but whether you need that or not
>>>is hard to tell.
>>we dont have C++ experience.
>
>What does that have to do with the price of fish? As far as I can tell,
>you yourself haven't written a single line of code in *Perl* either, yet
>here you are expecting some of the most talented Perl programmers on the
>planet to write this program for you. I suggest you go and troll the
>C/C++ newsgroups for a while, based on the success you are having here
>you should perform marvels over there. That's all I really have to say
>about that, except to say I am surprised at the amount of energy some of
>the regulars are spending here to get a decent sort of specification out
>of this person.
>


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

Date: 15 Apr 2001 03:55:04 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: why i posted
Message-Id: <9bb62o$d4b$1@bob.news.rcn.net>

sdfsd <sdfes@dsf.com> wrote:
> I am sorry the spec was so poor but i though question was clear baically 
> dealing with duplicate data.  a field appears twice or more in a line what i 
> want is to group it together.  i was a bit supprised that people were asking 
> about delimiters and such since i took that as a non issue.  but that is 
> probably due to my poor knowledge of perl

[I'm not trying to single you out here, and this is really directed toward 
the general reader]

Data formats are one of those areas where, quite annoyingly, everyone 
comes up with their own personal notation conventions that seem perfectly 
obvious to them but that nobody else can comprehend, simply because the 
first person takes a lot of the details for granted.  Really, explaining 
data formats in a way that others can quickly comprehend is a lot more 
work than most people imagine it is.  But anything less than the full 
amount of effort is purely wasted effort (and therefore a violation of 
Laziness).  We just had the same problem in at least two other threads 
(the "Lisp-like state machine" thread and the thread with the problem 
about matching <word>).

Please, everybody, try to explain your data formats in either plain
English or plain Perl code (the latter being especially helpful if English
isn't your first language), not in some invented notation.  This is one of
those rare areas where attempting to be concise usually results in being
cryptic instead.  And please *explain* them; don't just give some sample
data and expect everyone to divine its structure.


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

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


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