[21718] in Perl-Users-Digest
Perl-Users Digest, Issue: 3922 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 6 00:06:50 2002
Date: Sat, 5 Oct 2002 21:05:10 -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 Sat, 5 Oct 2002 Volume: 10 Number: 3922
Today's topics:
cgi script to receive data? (Robert)
Re: cgi script to receive data? <nobody@nowhere.com>
cgi script to send to URL and via email (Robert)
Re: date regex problem <jbritain@cox.net>
Re: help w chained "maps" <penny1482@attbi.com>
Re: ithreads, perl 5.8 and shared objects <derek@wedgetail.com>
Re: ithreads, perl 5.8 and shared objects <goldbb2@earthlink.net>
matching an unknown pattern. (Doggy)
Re: matching an unknown pattern. <nospam@nospam.com>
Re: matching an unknown pattern. (Jay Tilton)
Re: matching an unknown pattern. <garry@ifr.zvolve.net>
Re: matching an unknown pattern. <VES@VES.NET>
Re: merging 2 strings (Jeff Mott)
Re: merging 2 strings (Ken)
Re: newbie question - perl vs ? <nuba@turmalina.dcc.ufmg.br>
Re: newbie question - perl vs ? <tk@WINDOZEdigiserv.net>
Re: newbie question - perl vs ? <tim@ironwork.com>
Re: newbie question - perl vs ? <tim@ironwork.com>
Reproduce Datafile <andre.norman@sympatico.ca>
Re: Reproduce Datafile (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Oct 2002 16:46:11 -0700
From: r@starcenter.com (Robert)
Subject: cgi script to receive data?
Message-Id: <f12829c8.0210051546.2dbab151@posting.google.com>
Hello,
Can someone suggest a simple shopping cart cgi program to receive data
from my credit-card provider only?
I already have an order page that will send the data to the provider.
But my provider will confirm the transmission by sending the data
again to a cgi program on my server. The provider would not recommend
a suitable program, but only said that "any shopping cart program will
do." This script should then allow me to see the data in some manner.
So --- can anyone here recommend a suitable program? The data will be
in the form of variables such as, bill_name, bill_address, option1,
option2, etc.
Thank you.
Sincerely,
Robert Tkoch
------------------------------
Date: Sun, 6 Oct 2002 09:51:59 +1000
From: "Gregory Toomey" <nobody@nowhere.com>
Subject: Re: cgi script to receive data?
Message-Id: <oOKn9.46902$g9.134508@newsfeeds.bigpond.com>
Robert wrote in message ...
>Hello,
>
>Can someone suggest a simple shopping cart cgi program to receive data
>from my credit-card provider only?
>
>I already have an order page that will send the data to the provider.
>But my provider will confirm the transmission by sending the data
>again to a cgi program on my server. The provider would not recommend
>a suitable program, but only said that "any shopping cart program will
>do." This script should then allow me to see the data in some manner.
>
>So --- can anyone here recommend a suitable program? The data will be
>in the form of variables such as, bill_name, bill_address, option1,
>option2, etc.
>
>Thank you.
>
>Sincerely,
>
>Robert Tkoch
Try http://oscommerce.com/ - Perl based; open source; shopping cart;
interfaces to various payment systems; lots of reference sites; free.
gtoomey
------------------------------
Date: 5 Oct 2002 17:50:36 -0700
From: r@starcenter.com (Robert)
Subject: cgi script to send to URL and via email
Message-Id: <f12829c8.0210051650.45915a39@posting.google.com>
Hello,
I need a perl script to do the following:
1. From my online form, send the form data to my credit-card
provider's URL.
2. At the same time, send me an email of the same data. The data to be
sent does not require high security, as the user will add his
sensitive credit-card info after he gets to the credit-card provider's
secure URL.
Please help by suggesting a likely script, or by indicating where I
might learn about creating such a script.
Thank you.
Sincerely,
Robert
------------------------------
Date: Sat, 05 Oct 2002 22:52:40 GMT
From: Jim Britain <jbritain@cox.net>
Subject: Re: date regex problem
Message-Id: <c7pupuortgg7kghk5vhleo9ukefp95pkp4@4ax.com>
On Sat, 05 Oct 2002 13:18:23 GMT, "Doug" <dgardiner@houston.rr.com>
wrote:
>I have a field of text that displays a line starting with a date and a time
>stamp, but cannot successful strip the timestamp out of it.
>
>A sample line 2002-08-14 00:00:00 has me stumped.
>
>Here are some of the ways I've tried unsucessfully.
>
>$foo=~s/^\d+-\d+-\d /$1/;
>$foo=~s/^\w+ /$1/;
>$foo=~s/\d+:\d+:\d+$//;
>$foo=~s/(\d+):(\d+):(\d+)$//;
>
>Does anyone have any ideas. My result is that it is either totally
>unchanged or it is empty.
I believe you have skewered yourself with an inappropriate
meta-definition. You are buried too far down in the details of each
word on the line
Consider:
If you think of the line as a record, and the items as space separated
fields, then the solution becomes simpler -- you no longer need to
deal with digits and characters.
OK, so a line is an individual record.
A record consists of fields separated by spaces. and the structure is
consistent at least for the first two fields.
Now what you want to accomplish becomes simply splitting the line into
individual fields; ignoring those that are unwanted, and using those
that are.
open ( INPUT, "$inputsource");
while (<INPUT>) {
($date, $time, $wanted_text) = split ( / /); #split on space
# do whatever with wanted_text
}
no need to get into the characeters themselves at this point.
It is possible to use $junk, $junk for the "throw-away" variables, but
using meaningful contextual names makes the program easier to read and
relate to the incoming file format.
So it is not a regex problem so much, but a meta-definition that
affects the design of the program.
The required regex gets simplified down to what is required to match
the field seperator.
------------------------------
Date: Sun, 06 Oct 2002 00:41:54 GMT
From: "Dick Penny" <penny1482@attbi.com>
Subject: Re: help w chained "maps"
Message-Id: <mFLn9.52335$Pz.46903@rwcrnsc51.ops.asp.att.net>
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3D9E5CF8.35D2C43A@earthlink.net...
> Dick Penny wrote:
> >
> > A day or two ago, I asked for and rec'd help re multiple map
> > transforms of data. Now, I am trying to break apart a long line into
> > separate "maps" one per line so its easier to read, and easier to
> > continue to add functionality.
> > This has been advocated several places in AS and clpm.
> > #1 below works fine - of course, you guys provided it.
> > My #2 attempt to break #1 into two lines fails - I get all the data
> > and digits OK, BUT w/o the period insertations.
> > Uggh, what have I missed? I've seen examples where they just chained
> > maps, sorts, greps together - isn't that what I'm doing in #2?
> >
> > #1
> > my @numbrs = map { [ map { s/(\d{4})(\d\d)$/$1.$2/; $_ } /\d+/g ] }
> > @lines;
>
> Try this:
> my @numbers = map {
> [ map { s/(\d{4})(\d\d)$/$1.$2/; $_ } /\d+/g ]
> } @lines;
>
> Remember, these aren't *chained* maps here, but nested ones.
>
> You might want to write it as a single map, rather than a pair of them:
>
> my @numbers = map {
> s/(\d{4})(\d\d)$/$1.$2/g;
> [ /\d{4}\.\d\d/g ];
> } @lines;
>
> Or better yet:
>
> for my $line (@lines) {
> my @nums = grep 6 == length, $line =~ /\d+/g;
> substr($_, 4, 0, ".") for @nums;
> push @numbers, \@nums;
> }
>
> > #2
> > my @numbrs = map { s/(\d{4})(\d\d)$/$1.$2/; $_ }
> > map{[/\d+/g]} @lines;
>
> Here, you're trying to write chained maps... the above code is like:
>
> my @numbrs =
> map { s/(\d{4})(\d\d)$/$1.$2/; $_ }
> map [ /\d+/g ],
> @lines;
>
> Which first turns each line (originally a string) into an arrayref of
> numbers, and then performs string substitution on the arrayref, as if
> you'd had:
>
> foreach my $line ( @lines ) {
> my @bunch_of_numbers = $line =~ /\d+/g;
> my $aref = \@bunch_of_numbers;
>
> # *Think* about what this line does.
> $aref =~ s/(\d{4})(\d\d)$/$1.$2/;
>
> push @numbers, $aref;
> }
I was trying to break the nest into a chain because I am reasonable
successful in writing things like
@aray1 = map {xform1} @data
@aray2 = map {xform2} @aray1
etc.
etc.
and I was trying to eliminate the intermediate storage, and I thought/think
that just stringing lines of maps, each w 1 transform, is easy to
understand. I do see why my chain failed.
But in general, does
@answer = map {xform1}
map {xform2}
etc., etc. @data
have independent, separate iterators $_, that work from bottom to top, and
complete one map before starting the next map? That's kind-of what I was
trying to do.
As I read what I just wrote, I am confusing myself. Is my problem that a map
provides one, and only one iterator, but after I xform data into beginingsof
a 2D matrix(row by row) , I need two iterators to do anything. But if this
is true, why do your lines above that I've marked with *****
work (or don't they, I have not tested yet)?
------------------------------
Date: Sun, 06 Oct 2002 10:28:22 +1000
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: ithreads, perl 5.8 and shared objects
Message-Id: <3d9f83c3$0$23169$afc38c87@news.optusnet.com.au>
Bart Schuller wrote:
> I'll jumble the original article a bit so I can start with the answer:
>
> In article <wZcn9.280$i84.19789@news.optus.net.au>,
> Derek Thomson <derek@wedgetail.com> wrote:
>
>>The original question:
>>
>>The following simple program gives this error in Perl 5.8
>>and I don't understand why. Any help is appreciated:
>>
>>Can't call method "id" on unblessed reference at s.pl line 23.
>
>
> The answer is in the manpage for threads::shared in the BUGS section:
>
> "bless" is not supported on shared references. In the current version,
> "bless" will only bless the thread local reference and the blessing
> will not propagate to the other threads. This is expected to be imple-
> mented in a future version of Perl.
I know, I read that and despaired :(
However, there was one discussion here on clpm that indicated that
blessing *first*, then sharing, would work. The replier was quite
strident on this point, almost to the point of insulting the questioner,
even thought that's not at all clear from the doco that I can see. I
guess I was hoping for that guy to come back and call *me* a lam0r! I'd
be happy to take it, as long as I got an answer ;)
So, it looks like this doesn't work at all ...
>
> However, there are other modules available on CPAN without this
> restriction. Have a look at the Thread-related modules in
> http://search.cpan.org/author/ELIZABETH/
I want ithreads, 'cause I really like the design, like I said. And this
would break my desire to allow my ORB to work with no other modules,
aside from those that come with the Perl distro.
>
> I also urge you to experiment with the thread support in 5.8 and write
> up what you like and don't like about it. The perl5-porters list will be
> interested to know how they work in practice.
The fact that threading doesn't work with blessed references seems like
a tragic oversight. I don't think it should have been announced quite so
triumphantly while this was extant. But yes, I'll raise the issue. I do
like the basic idea of separation by default, and sharing by
declaration, though!
>
>
>>Secondly, I'm working on a Perl CORBA ORB
>>(http://sourceforge.net/projects/perlorb), and if Perl threads aren't
>>working correctly then there's no way it can properly support
>>multithreaded servers. I'd really like to know what the story is one way
>>or another soon.
>
>
> I assume you've looked at my (quite dead by now, alas) COPE?
Yes. I didn't like some things about it, like the reliance on the
Exceptions module. I needed a "pure" Perl solution. Has it been tested
with other ORBs, BTW?
Why is it dead, BTW?
--
Derek Thomson.
------------------------------
Date: Sat, 05 Oct 2002 23:02:58 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: ithreads, perl 5.8 and shared objects
Message-Id: <3D9FA7E2.551C5B55@earthlink.net>
Derek Thomson wrote:
>
> Uri Guttman wrote:
[snip]
> > and what do you mean by the server calling itself directly or
> > indirectly?
>
> Let's say a client calls method 'foo' on object 'A' in one process.
> Method 'foo' now calls method 'bar' on object 'B' in another process.
> As part of the execution of method 'bar', method A.fubar is called. As
> A.foo is already being handled in A's process, we have a deadlock
> situation.
Not necessarily... Look at it like this... suppose when the first
process does:
my $result = $B->bar(@args);
It really does:
my $result;
send_message( $B, "bar", \@args );
RPCLOOP: {
my $event = get_next_event();
# ->fubar, in this process, will be called from here:
$event->dispatch(), redo RPCLOOP
if $event->type() ne "response";
$result = $event->data();
}
Note that while waiting for a response, it is *not* waiting *only* for a
response to $B->bar, but it is also dispatching other requests, too!
> The trivial (direct) case is when A.foo calls A.fubar directly, but
> that can be avoided by having the ORB (or whatever infrastructure)
> skip the message dispatch by detecting that it's a local call. That's
> impossible, however, in the indirect case described above.
Even if it's not smart enough to skip the message dispatch, there
shouldn't be a deadlock, if the message dispatching is done as I show
above.
> > with message passing that is less than trivial, you just
> > send a message to yourself (or whatever). as for exploiting
> > parallelism the above mentioned project partly on a 4 way cpu and it
> > uses processes and message passing to get parallelism. in fact when
> > we added that feature, the time for a multiple query search went
> > down by factor that was almost linear with the number of parallel
> > processes running. the key to parallel processing is the IPC and
> > message passing can be simpler and cleaner than threads and locks.
> > also it is more scalable as the same architecture can be spread to
> > multiple boxes with no new coding and threads can't do that at all.
>
> I don't really understand most of that, as I'm not familiar with this
> project the you're talking about. Speaky generically, you have two
> choices if you want to get useful work done while blocking on I/O 1)
> You use threading, or 2) You make the I/O handler part of the event
> loop.
>
> 2) Is harder to get right,
Isn't it nice that people have already written code with the I/O
handling built into the event loop?
[snip]
[snip]
> However, I can't see how you avoid locking - with events you just
> force everything to be serialized, therefore you've lost any potential
> parallelism.
Well, all serialized within the one process, but you can have multiple
processes, which you talk to through I/O.
> And if you do hook your I/O events into the event loop,
> you're back to worrying about race conditions again (although DB
> transactions might deal with some of that for you, but what about
> files?).
I'm not sure what you mean by this.
[snip]
> I respectfully question this "real parallel scalability" assertion. I
> think you're being just a teensy bit zealot-ish here.
He's the president of "Stem Systems", whose main product, stem, is a
message passing system. What would you expect?
> I'm sure I can do just as well with a threaded server, and you can't
> *really* avoid race conditions (and locking) unless you throw
> parallelism out.
If you use multiprogramming instead of multithreading, any one process
is purely serial.
One can avoid deadlocks due to recursion simply by changing RPC of the
form: "send request and wait for *my* response, and *only* my response"
into: "send message and wait for *any* messages, dispatching those which
are requests, until one of those messages is my response"
Other forms of race conditions/deadlocks may still require work, but you
could create a centralized process which hands out locks, or something
like that.
> I don't see how your model as described can really exploit multiple
> CPUs,
Take those components which don't interact nicely into an event
dispatching model by themselves (DBI, for example), and put them into
their own processes (and talk to them via RPC/messages). The OS will
likely run those processes on the other CPUs.
> without exchanging more messages between seperate processes,
The way I see it, you send one message per request, and get one message
per response. Where do you see the extra messages?
> which is certainly a little inelegant.
It's only inelegant if it's visible to the user.
> Sure, it probably works in specific cases, but I'm writing an ORB, so
> I can't be telling people how they should be using it - I just have to
> give them all the options: that is, threads *and* event loops.
>
> I'm starting with threads, as that's what people expect, it's easier
> to get started with, and damnit, I want to show that it *works* in
> Perl!
Perl's threads work, but they are *not* lightweight things.
The idea of creating a short-lived thread which does a single task, then
exits, is only a good one if the cost of creating a thread is low.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 5 Oct 2002 15:33:05 -0700
From: tru64dog@yahoo.com (Doggy)
Subject: matching an unknown pattern.
Message-Id: <18239c3a.0210051433.fe4717@posting.google.com>
Is this possible in perl.
I would like match more than 5 instances of a one line pattern in a
file. Lets say for instance, in a file called data.txt, if a pattern
of "dog bite" appears more than 5 times to let me know. But remember,
I don't type in the pattern, the objective is PERL to find 5 or more
instances of an exact pattern w/o me telling what pattern to look for?
TIA
Rod
------------------------------
Date: Sat, 5 Oct 2002 16:51:58 -0700
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: matching an unknown pattern.
Message-Id: <3d9f7a96$1_3@nopics.sjc>
"Doggy" <tru64dog@yahoo.com> wrote in message
> Is this possible in perl.
>
> I would like match more than 5 instances of a one line pattern in a
> file. Lets say for instance, in a file called data.txt, if a pattern
> of "dog bite" appears more than 5 times to let me know. But remember,
> I don't type in the pattern, the objective is PERL to find 5 or more
> instances of an exact pattern w/o me telling what pattern to look for?
Please rephrase your question. If you don't indicate what pattern you are
looking for, how on earth does your script what to do?
------------------------------
Date: Sun, 06 Oct 2002 00:14:33 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: matching an unknown pattern.
Message-Id: <3d9f7d8a.619548849@news.erols.com>
tru64dog@yahoo.com (Doggy) wrote:
| I would like match more than 5 instances of a one line pattern in a
| file. Lets say for instance, in a file called data.txt, if a pattern
| of "dog bite" appears more than 5 times to let me know.
@ARGV = 'data.txt';
my $pat = qr/dog bite/;
my $matches = 0;
while( <> ) {
$matches++ if /$pat/;
last if $matches > 5;
}
print "Found more than five '$pat'" if $matches > 5;
| But remember, I don't type in the pattern,
So? How does that matter, unless the pattern comes from an external
source and you're concerned about it being tainted data?
------------------------------
Date: Sun, 06 Oct 2002 00:36:43 GMT
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: matching an unknown pattern.
Message-Id: <slrnapv16s.ot8.garry@zfw.zvolve.net>
On Sun, 06 Oct 2002 00:14:33 GMT, Jay Tilton <tiltonj@erols.com> wrote:
> tru64dog@yahoo.com (Doggy) wrote:
>
>| I would like match more than 5 instances of a one line pattern in a
>| file. Lets say for instance, in a file called data.txt, if a pattern
>| of "dog bite" appears more than 5 times to let me know.
>
> @ARGV = 'data.txt';
> my $pat = qr/dog bite/;
> my $matches = 0;
> while( <> ) {
> $matches++ if /$pat/;
> last if $matches > 5;
> }
> print "Found more than five '$pat'" if $matches > 5;
>
>
>| But remember, I don't type in the pattern,
>
> So? How does that matter, unless the pattern comes from an external
> source and you're concerned about it being tainted data?
I think the OP wants the program to _find_ repeating strings in the
file. He uses the term pattern, but it sounds like he means
substrings.
If that is the OP's question, then it sounds like a lot of
computation.
--
Garry Williams
------------------------------
Date: Sun, 06 Oct 2002 02:24:18 GMT
From: Vespasian <VES@VES.NET>
Subject: Re: matching an unknown pattern.
Message-Id: <aZ6fPdR+=ihrsaTIMVdd89DXfknD@4ax.com>
On 5 Oct 2002 15:33:05 -0700, tru64dog@yahoo.com (Doggy) wrote:
>Is this possible in perl.
>
>I would like match more than 5 instances of a one line pattern in a
>file. Lets say for instance, in a file called data.txt, if a pattern
>of "dog bite" appears more than 5 times to let me know. But remember,
>I don't type in the pattern, the objective is PERL to find 5 or more
>instances of an exact pattern w/o me telling what pattern to look for?
>
>TIA
>
>Rod
I don't think you can do the above for a phrase "dog bite", however, I
thik you can do it for single words, such as "dog" or "bite";
my %hash;
open(IN, "data.txt");
while(<IN>) {
while(/(\w+)/g) {
if(++$hash{$1} >= 5) { do_whatever; }
}
}
close(IN);
------------------------------
Date: 5 Oct 2002 18:27:51 -0700
From: jeffmott@twcny.rr.com (Jeff Mott)
Subject: Re: merging 2 strings
Message-Id: <f9c0ce19.0210051727.19f0bad2@posting.google.com>
> I am currently encrypting user data using encryption that uses a key.
I certainly hope it uses a key. Are you using a well known and proven
algorithm or something you slapped together? Are you using a block or
stream cipher? you cannot encrypt two different plaintexts with the
same key stream and still maintain security with a stream cipher.
> However, I would like to use a unique key for each user's data. This
> is so the encrypted strings will be different for each user even if
> said user's have identical data. I have decided I can do this by using
> one static string as the key and then merging it with something unique
> to each user, such as the username or user number.
This is bad. Using a username or number makes the key string
predicable for each user. What you need to do is just generate a
random string of bytes for each key. See sci.crypt.random-numbers for
good ways to do this.
> My problem is I
> have no idea how I can do this. I can't just use the dot operator to
> combine them.
Why not? (if it wasn't already a bad idea)
BTW, the "dot" operator is concatenation
> I need to sort of mix them together. Am I making any
> sense? If so, please help :)
A couple ways to mix two strings are 1) XOR them together, 2)
concatenate them and run the output through a hashing function
------------------------------
Date: 5 Oct 2002 20:44:29 -0700
From: angel@xev.net (Ken)
Subject: Re: merging 2 strings
Message-Id: <fafcc419.0210051944.4b2eed9d@posting.google.com>
Ok, I have decided that this will work, I just need to figure out how
to do the "merging". Merge has not been defined besically because the
solution to my problem would be the definition. I can't let the user
choose the keystring because I need to be able to decrypt this data.
I'll try to explain what I want a little better. I am encrypting user
information via the ENCODE() method in MySQL. This is for a website I
am creating that is powered by mod_perl, thus I am looking for a
solution in Perl. The ENCODE() method takes a key as an argument which
is used to encrypt data. The problem is that the encryption is easily
broken by studying multiple user records. This can be solved by
encrypting each record with a different key.
So I need a way of creating a unique key for each record, while still
being able to decrypt everything. I figured I could use one static key
and change it in some way with something that is unique to each record
such as the userid. I am pretty sure this can be done so that even if
an attacker knows that the userid was used in some way to encrypt the
data, he won't be able to decrypt it without knowing the original
static key.
So the merge would be combining a key which is a string of ASCII
characters with an integer no more than 10 characters in length. I
also could use the username instead of the userid. The username is a
string of 3-15 alphanumeric characters. I would prefer using the
userid though, since I may want to be able to change a user's
username.
One solution I was contemplating was using the userid to change the
ASCII characters in the static key. Since each ASCII character has a
numeric value, I could increase the ASCII value of each character in
the key by the integer value in the userid. Of course I would reach an
upper limit, so I suppose I would need to wrap around to the beginning
once I got to the last ASCII character. However, this would be rather
difficult to code and would be slow. I was hoping someone here could
suggest a better solution.
tiltonj@erols.com (Jay Tilton) wrote in message news:<3d9f43a5.604725919@news.erols.com>...
> angel@xev.net (Ken) wrote:
>
> | I am currently encrypting user data using encryption that uses a key.
> | However, I would like to use a unique key for each user's data. This
> | is so the encrypted strings will be different for each user even if
> | said user's have identical data.
>
> mmmkay
>
> | I have decided I can do this by using
> | one static string as the key and then merging it with something unique
> | to each user, such as the username or user number.
>
> In other words, you want the keystring itself to be encrypted from some
> piece of user-unique data. Sounds pretty iffy. Assuming the user-unique
> element is publicly available, if somebody lays hands on the algorithm,
> they can crank out the keystring for any and every user.
>
> Why not let each user choose their own keystring?
>
> | My problem is I
> | have no idea how I can do this. I can't just use the dot operator to
> | combine them. I need to sort of mix them together. Am I making any
> | sense? If so, please help :)
>
> Summing up,
>
> 1. Need to merge two strings, though "merge" hasn't been defined.
> 2. Concatenation is not acceptable, for unexplained reasons.
> 3. Need to "sort of mix them," for unknown values of "sort of" and "mix."
>
> The problem statement needs refinement. It's too vague.
>
> And it has nothing specifically to do with Perl.
------------------------------
Date: Sat, 5 Oct 2002 23:43:55 +0000 (UTC)
From: Nuba <nuba@turmalina.dcc.ufmg.br>
Subject: Re: newbie question - perl vs ?
Message-Id: <anntfr$rbn$1@dcc.ufmg.br>
tk <tk@windozedigiserv.net> wrote:
: As for your last comment.. you'll read snippets of others code, to see
: how a particular situation was dealt with by that coder, and you can
: then implement that into your own development. If you were looking for a
: simple string replace, you wouldn't need to read the source part
: regarding hashes and keys for example. I'll normally search google or
: the likes for something I'm after, look at various pieces of code, and
: try n work out the best way for _me_ to implement the same.
I am also learning perl from scratch and I have not enought words
to express how much valuable it's been for me to have a copy of the
Perl Cookbook reachable for when I'm lost into darkness :)
It helps me alot from keep reinventing the wheel, and gives also
a boost at my learning perfomance, thanks to the rich discussions for
each solution presented.
All good things,
Nuba
nuba@dcc.ufmg.br
------------------------------
Date: Sun, 06 Oct 2002 00:02:41 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: newbie question - perl vs ?
Message-Id: <navupu0gk3fiso5t72up8r601j5ht2udfp@4ax.com>
In a fit of excitement on Sat, 5 Oct 2002 23:43:55 +0000 (UTC), Nuba
<nuba@turmalina.dcc.ufmg.br> managed to scribble:
[snip]
| I am also learning perl from scratch and I have not enought words
| to express how much valuable it's been for me to have a copy of the
| Perl Cookbook reachable for when I'm lost into darkness :)
|
| It helps me alot from keep reinventing the wheel, and gives also
| a boost at my learning perfomance, thanks to the rich discussions for
| each solution presented.
Indeed. The most common 2 I use for reference, is the Perl Cookbook, and
Learning Perl (mainly for function listing and syntax reference).. so
far, with those and a lil scooting around on the net.. I can pretty much
find out anything I need to know.. regardless of how much I actually
knew before I looked.
Regards,
tk
$a[0]='wjist~jzqg';$a[3]='x~jpstr';$a[1]=
'fjwf';$a[2]='ktmhszg';foreach(
@a){@b=(split(//,reverse($_)));foreach(@b){$c.=chr(ord($_)-5);}}print substr
($c,0,10).' '.substr($c,10,3).' '.substr($c,13,1).' '.substr($c,14,5
).' '.substr($c,19,2).' '.substr($c,21,7);
remove WINDOZE to reply
http://www.digiserv.net/
------------------------------
Date: Sun, 06 Oct 2002 00:04:18 GMT
From: Tim B. <tim@ironwork.com>
Subject: Re: newbie question - perl vs ?
Message-Id: <3ivupu82mkqtr22tqoh0r4i1t99hoh524m@4ax.com>
On Sat, 5 Oct 2002 13:24:48 -0700, "Newbie" <mike_constant@yahoo.com>
wrote:
<snip>
>http://learn.perl.org (Learning Perl starting with A)
>http://www.perl.com (Once in a while, there's a good article for raising
>your Perl knowledge)
>http://perl.apache.org (Stas Beckman has loads of tricks to optimize Perl
>code)
Thanks for the links. I'll be spending a lot of time there, from what
I see.
Tim B.
------------------------------
Date: Sun, 06 Oct 2002 00:05:43 GMT
From: Tim B. <tim@ironwork.com>
Subject: Re: newbie question - perl vs ?
Message-Id: <dlvupuge1odsplj3k4iv0lnvpeb0n87t0m@4ax.com>
On 5 Oct 2002 14:02:28 -0700, angel@xev.net (Ken) wrote:
>The best way to learn perl is to program in Perl. Studying other
>people's code is also very helpful. Download some perl scripts and try
>making some changes to them. Learning Perl by simply reading books
>without doing any actual coding is going to be difficult at best. Just
>try writing or editing code with your Perl books in front of you. The
>more you program the less you'll find yourself flipping through your
>references.
>
>A great place to find scripts is at
>http://cgi.resourceindex.com/Programs_and_Scripts/Perl/
>
Thanks!! This link is a great source for perl scripts. They have a
PHP section too.
Tim B.
------------------------------
Date: Sat, 5 Oct 2002 21:54:30 -0400
From: "Andre Norman" <andre.norman@sympatico.ca>
Subject: Reproduce Datafile
Message-Id: <CJMn9.1139$G5.367054@news20.bellglobal.com>
Hello ,
I have a file (DATA.TMP) that contains approx 500,000 records.
The file's contents looks something like this:
987392D99873987324300000000756
897349A98734329873900000000676
272793A93742398739300000000879
439748D89874398898900000000765
673429A79349732493700000000234
173783D09337348939900000000756
I want to read each record and create a new file with all the records
that
dont have a D in the 7th position. I would also like to have the
eight 0's
converted to 20020101
The new file would look like this:
897349A98734329873920020101676
972793A93742398739320020101879
873429A79349732493720020101234
I'm thinking sed could rip through this problem but im not sure how to
implement it.
PLEASE NOTE: The actual record length could be 800
characters,and although D is followed by 3 digits in the example I
gave, it's not
always the case. What I do know is that D will always be in 98th
position and the eight 0s
will always be in the 600th position. Again I won't know how many
characters follow the 0s.
Thanks in advance for you reply.
Andre
------------------------------
Date: Sat, 5 Oct 2002 22:27:03 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Reproduce Datafile
Message-Id: <slrnapvbc7.33o.tadmc@magna.augustmail.com>
Andre Norman <andre.norman@sympatico.ca> wrote:
> The file's contents looks something like this:
[snip input data, repeated below]
> I want to read each record and create a new file with all the records
> that
> dont have a D in the 7th position. I would also like to have the
> eight 0's
> converted to 20020101
>
> The new file would look like this:
>
> 897349A98734329873920020101676
> 972793A93742398739320020101879
> 873429A79349732493720020101234
----------------------
#!/usr/bin/perl
use warnings;
use strict;
while ( <DATA> ) {
next if substr($_, 6, 1) eq 'D';
substr($_, 19, 8) = '20020101';
print;
}
__DATA__
987392D99873987324300000000756
897349A98734329873900000000676
272793A93742398739300000000879
439748D89874398898900000000765
673429A79349732493700000000234
173783D09337348939900000000756
----------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 3922
***************************************