[29497] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 741 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 10 14:09:50 2007

Date: Fri, 10 Aug 2007 11:09:11 -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           Fri, 10 Aug 2007     Volume: 11 Number: 741

Today's topics:
    Re: (Re)announcing APL 2007  rjp@ca.inter.net
    Re: Coding in Perl <yankeeinexile@gmail.com>
    Re: Coding in Perl <tzz@lifelogs.com>
    Re: Coding in Perl  usenet@DavidFilmer.com
        ExtUtils chmod on Windows?  kk_oop@yahoo.com
    Re: ExtUtils chmod on Windows? <sisyphus1@nomail.afraid.org>
        Help: Newbie Question <openlinuxsource@gmail.com>
    Re: Help: Newbie Question <josef.moellers@fujitsu-siemens.com>
    Re: Help: Newbie Question <tzz@lifelogs.com>
    Re: Help: Newbie Question <tzz@lifelogs.com>
    Re: How can I find out what changed betwen perl version <glennj@ncf.ca>
    Re: how to tranpose a huge text file <tzz@lifelogs.com>
    Re: how to tranpose a huge text file anno4000@radom.zrz.tu-berlin.de
    Re: how to tranpose a huge text file <tzz@lifelogs.com>
    Re: how to tranpose a huge text file xhoster@gmail.com
        In what order does readdir() see a directory? <mailbox@cpacker.org>
    Re: In what order does readdir() see a directory? <peter@makholm.net>
        Initial release of Kx-0.0.1 markpf@gmail.com
        match and group across 2 lines  ktlind@gmail.com
    Re: match and group across 2 lines <dummy@example.com>
    Re: match and group across 2 lines <noreply@gunnar.cc>
    Re: match and group across 2 lines <ktlind@gmail.com>
    Re: Out of memory in vec <tzz@lifelogs.com>
    Re: pass by reference anno4000@radom.zrz.tu-berlin.de
    Re: pass by reference (hymie!)
    Re: pass by reference <yankeeinexile@gmail.com>
    Re: pass by reference <glex_no-spam@qwest-spam-no.invalid>
    Re: pass by reference <yankeeinexile@gmail.com>
    Re: Using DBI, Bind with Update <mritty@gmail.com>
    Re: Using DBI, Bind with Update <tzz@lifelogs.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 10 Aug 2007 09:40:41 -0700
From:  rjp@ca.inter.net
Subject: Re: (Re)announcing APL 2007
Message-Id: <1186764041.534462.156660@e9g2000prf.googlegroups.com>

On Aug 6, 9:20 am, Paul Mansour <p...@carlislegroup.com> wrote:

> APL2007 Roll Call: Is anyone going to this?
>
> I'm thinking about going, but I don't want to the only one to show up,
> as in San Diego.

Here here.

Sorry to mention the elephant in the room, but this discussion begs
the obvious question:  what is the rationale for putting on this
conference?  Perhaps I missed that discussion, and if so, please
excuse me.

As we know, there are already two well-attended APL vendor conferences
in the world each year, plus several other more local gatherings.

Speaking as an APL consultant and product distributor, this puts
people in a tough spot, since we now have at least three events to
consider travelling to and attending (assuming APL2000 is hosting its
usual Florida event this year?).

I suppose I should be happy for another opportunity to meet and
network with potential APL colleagues and customers, but if it's
mainly the same small audience at each event, the costs are hard to
justify more than once per year.

I don't have any answers to this dilemma yet, but I think it requires
a lot more discussion. Just putting on a conference and hoping people
attend may, at this point I think, be somewhat counterproductive.

 ...richard




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

Date: 10 Aug 2007 09:24:55 -0500
From: Lawrence Statton <yankeeinexile@gmail.com>
Subject: Re: Coding in Perl
Message-Id: <87ejib8o20.fsf@hummer.cluon.com>

googler <pinaki_m77@yahoo.com> writes:
> Hello Perl users,
> 
> I have a few questions if anyone feels like answering them..

> 1. Is there a way I can improve my Perl expertise? I know the answer
> is to write more programs (scripts), but since I don't get a lot of
> chance to code in Perl, how do I go about it?

Learning to program *well* requires you to be emotionally invested,
and nobody but you can get you to that point -- anyone who just learns
to program to draw a paycheck or pass a course will naturally tune his
own output to the minimum required to draw the check or pass the
course.

What aspect of Perl programming appeals to you?  Do you get all warm
and fuzzy doing glitzy "Web 2.0" things? - So learn all about the
myriad XML modules and explore mod_perl beyond 'makes my CGI less
slow'.  Does playing with databases in interesting ways appeal to you?
Learn about and play with the modules in DBIx.  What parts of the
language to master strongly depends on the kinds of tasks you want to
solve -- I can go two months in my paying work without ever writing a
regexp.  Others can't go an afternoon without needing to craft ten of
them.

The second part of that is: The only way to learn to be an excellent
programmer is spend lots of time being a crappy one :) Read well
written code.  Alas, finding examples of well written code, especially
in Perl, can be an extreme challenge.  Sturgeon's law: 90% of
everything is crud.

One of the questions that will strongly affect your course of study --
honestly evaluate yourself as a *programmer*.  Do you jump out of bed
and eat complex data structures for breakfast?  Do you use the word
"thunk" in everyday conversation?  Are you learning to program (and
want to have Perl be your first platform) or are you already a skilled
programmer and just want to pick up Perl as another tool in your box?

> 2. How much of Perl coding do you guys do? How much experience do you
> have in Perl?

I spend about three hours a day coding for my paying clients, four or
five hours grading homework, tutoring students and preparing for
lectures.  Then I usually try to get another 3 hours in on some kind
of "fun" project playing with a technology that interests me.

I've been doing at least part of my programming in Perl since 1996
when some guy named Larry Wall signed up for ISDN service from the
small ISP where I was a systems programmer.  He convinced me this new
language "Perl" would be fun to play with.  [1] About 85% of all code
I write now is in Perl, the bulk of the remainder being Javascript to
handle the browser-side of Ajax.

The day job programming is dull as dishwater, doing minor boring
feature additions in the same boring codebase for the same boring
customers, but it pays really well, and affords me the opportunity to
do more important things.

> 3. What aspect of coding in Perl do you like most?

That I can put together a ten line program using a couple of modules
to convert a DBF file into XML.  Or quickly add a feature to a
client's web site to convert an XML data stream into an Excel
Spreadsheet.  Or write a quick tool to take an Excel spreadsheet and
use it to update the database.

To me, the two single most important features of Perl aren't features
of Perl per-se, they're CPAN and jobs.perl.org.

Footnotes:

[1] That's not *quite* true -- I had already started writing Perl code
when he signed up, and in fact my first words to him when he called
with a support question were , "Wow, it's really you ... I should say
something clever like require 'sycophany.ph' .... "


-- 
	Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
place them into the correct order.


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

Date: Fri, 10 Aug 2007 11:22:47 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Coding in Perl
Message-Id: <m2ps1v8ilk.fsf@lifelogs.com>

On Fri, 10 Aug 2007 05:37:33 -0000 googler <pinaki_m77@yahoo.com> wrote: 

g> 1. Is there a way I can improve my Perl expertise? I know the answer
g> is to write more programs (scripts), but since I don't get a lot of
g> chance to code in Perl, how do I go about it?

Perl is just a tool; to get better at programming Perl you should get
better at programming in general.  If you don't understand algorithmic
complexity or graph traversal or binary trees or databases, for example,
you will not solve problems that require that knowledge well in Perl or
in any other language.

Assuming you know programming well, to get better at Perl in particular
you should scratch an itch.  Find something that interests you and solve
it in Perl (if it's been done already, compare your effort to the
existing work).  Then ask a Perl expert to critique your code (this
newsgroup can do it too) and learn from the experience.

g> 2. How much of Perl coding do you guys do? How much experience do you
g> have in Perl?

I do Perl coding whenever it makes sense for the task.  I've been using
Perl since 1994 but didn't start using it heavily until 1997 or so.

g> 3. What aspect of coding in Perl do you like most?

The laziness.  I love writing simple, clean code with as few bugs as
possible.  This is why I like Lisp and Ruby as well, and am not too fond
of Javascript, C++, or Java for example.

Ted


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

Date: Fri, 10 Aug 2007 18:06:55 -0000
From:  usenet@DavidFilmer.com
Subject: Re: Coding in Perl
Message-Id: <1186769215.292699.156340@x40g2000prg.googlegroups.com>

On Aug 10, 2:38 am, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> Depends on the period. I would rate my experience as average...

Oh crap, then I need to seriously reassess my own experience level...




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

Date: Fri, 10 Aug 2007 05:57:32 -0700
From:  kk_oop@yahoo.com
Subject: ExtUtils chmod on Windows?
Message-Id: <1186750652.684374.15380@x40g2000prg.googlegroups.com>

Hi.  When running a Perl script on Windows, can the
ExtUtils::Command's chmod function be used to alter read-only status
of files?  See http://aspn.activestate.com/ASPN/docs/ActivePerl/5.8/lib/ExtUtils/Command.html
for the command.

Thanks!

Ken



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

Date: Fri, 10 Aug 2007 23:21:52 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: ExtUtils chmod on Windows?
Message-Id: <46bc666d$0$15276$afc38c87@news.optusnet.com.au>


<kk_oop@yahoo.com> wrote in message 
news:1186750652.684374.15380@x40g2000prg.googlegroups.com...
> Hi.  When running a Perl script on Windows, can the
> ExtUtils::Command's chmod function be used to alter read-only status
> of files?  See 
> http://aspn.activestate.com/ASPN/docs/ActivePerl/5.8/lib/ExtUtils/Command.html
> for the command.
>

Yes. For example, the following will turn off the "Readonly" attribute on 
file.ext (at least, it does for for me on Windows Vista):

perl -MExtUtils::Command -e chmod 0666 file.ext

Cheers,
Rob




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

Date: Fri, 10 Aug 2007 19:55:43 +0800
From: Amy Lee <openlinuxsource@gmail.com>
Subject: Help: Newbie Question
Message-Id: <pan.2007.08.10.11.55.42.230635@gmail.com>

Hi, all

I'm a newbie in Perl, and I have to make a Perl script that can solve the
question.

In our Bioinformatics Department, we need to convert some files into a
suitable formation. 

The original formation is:

>16jh_0101.b1.abi  Chromat File {descriptions......}
ATCCGTACTGC............................................

I hope that it can be this:

>16>jh_0101>ATCCGTACTGC............................................

In one file, there are many template like above, so I need a script can
solve the problem.

Thank you very much~

Regards,

Amy Lee


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

Date: Fri, 10 Aug 2007 14:19:27 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Help: Newbie Question
Message-Id: <f9hl4k$4b0$1@nntp.fujitsu-siemens.com>

Amy Lee wrote:
> Hi, all
>=20
> I'm a newbie in Perl,

Yes ... and?

> and I have to make a Perl script that can solve the
> question.

Yes ... and? What have you tried so far? You write "_I_ have to make ..."=
=2E
The department for ready-made scripts is at www.cpan.org, although they=20
only stock off-the shelf scripts and script snippets called modules.=20
Tailor-made scripts can be obtained by hiring a developer.

This department only serves to help when you have problems with a=20
certain script ("I tried <thisandthat> and expected <suchandsuch> but=20
got <somethingelse>") or it keeps people entangled in endless debates=20
about The True Way ;-)

Josef
--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html



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

Date: Fri, 10 Aug 2007 11:03:14 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Help: Newbie Question
Message-Id: <m23ayr9y2l.fsf@lifelogs.com>

On Fri, 10 Aug 2007 14:19:27 +0200 Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote: 

JM> Amy Lee wrote:
>> Hi, all
>> 
>> I'm a newbie in Perl,

JM> Yes ... and?

>> and I have to make a Perl script that can solve the
>> question.

JM> Yes ... and? What have you tried so far? You write "_I_ have to make ...".
JM> The department for ready-made scripts is at www.cpan.org, although
JM> they only stock off-the shelf scripts and script snippets called
JM> modules. Tailor-made scripts can be obtained by hiring a developer.

JM> This department only serves to help when you have problems with a
JM> certain script ("I tried <thisandthat> and expected <suchandsuch> but
JM> got <somethingelse>") or it keeps people entangled in endless debates
JM> about The True Way ;-)

I think this was fairly rude (not that it's unusual on c.l.p.m in the
last few years).  At least point the OP in the right direction.  I'll
follow up to her question separately.

Ted


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

Date: Fri, 10 Aug 2007 11:06:23 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Help: Newbie Question
Message-Id: <m2y7gj8jcw.fsf@lifelogs.com>

On Fri, 10 Aug 2007 19:55:43 +0800 Amy Lee <openlinuxsource@gmail.com> wrote: 

AL> The original formation is:

AL> >> 16jh_0101.b1.abi  Chromat File {descriptions......}
AL> ATCCGTACTGC............................................

AL> I hope that it can be this:

AL> 16> jh_0101>ATCCGTACTGC............................................

AL> In one file, there are many template like above, so I need a script can
AL> solve the problem.

Hi,

you're trying to do data transformations.  Perl is good at this.  You
need to look at regular expressions (perldoc perlretut) to extract the
interesting data from the line you showed.  Then you can print out the
data you extracted in a new format.

Start with "perldoc perlintro" if you don't have any previous Perl
experience.

Good luck
Ted


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

Date: 10 Aug 2007 14:17:14 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: How can I find out what changed betwen perl versions?
Message-Id: <slrnfbosra.sqn.glennj@smeagol.ncf.ca>

At 2007-08-09 06:53PM, "Bill H" wrote:
>  I have always used Active State perl v 5.005.03 for this program and
>  still have it installed on one machine. On my newer machine I have
>  v5.8.8.
>  
>  When I run the exact same program (last date modified on the program
>  was 6/5/7), on the exact same data (same size on both machines, under
>  v5.005.03 I get a resulting text file of 4833kb, but under 5.8.8
>  (again same program, same data, different machine) I get a resulting
>  text file size of 4607kb. What could cause such a size difference in
>  the resulting file (or any size difference)?

Line endings (\n vs \r\n).  The older machine is Windows (you use
ActivePerl), but you don't specify the other -- linux?

Off topic:  US date formats are maddening.  Do you mean May 6, 2007 or
June 5, 2007 or May 7, 2006?

-- 
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry


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

Date: Fri, 10 Aug 2007 10:33:30 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: how to tranpose a huge text file
Message-Id: <m27io39zg5.fsf@lifelogs.com>

On Wed, 08 Aug 2007 20:56:24 -0000 Jie <jiehuang001@gmail.com> wrote: 

J> I have a huge text file with 1000 columns and about 1 million rows,
J> and I need to transpose this text file so that row become column and
J> column become row. (in case you are curious, this is a genotype
J> file).

J> Can someone recommend me an easy and efficient way to transpose such
J> a large dataset, hopefully with Perl ?

I think your file-based approach is inefficient.  You need to do this
with a database.  They are built to handle this kind of data; in fact
your data set is not that big (looks like 10GB at most).  Once your data
is in the database, you can generate output any way you like, or do
operations directly on the contents, which may make your job much
easier.  

You could try SQLite as a DB engine, but note the end of
http://www.sqlite.org/limits.html which says basically it's not designed
for large data sets.  Consider PostgreSQL, for example (there are many
others in the market, free and commercial).

To avoid the 1000-open-files solution, you can do the following:

my $size;
my $big = "big.txt";
my $brk = "break.txt";
open F, '<', $big or die "Couldn't read from $big file: $!";
open B, '>', $brk or die "Couldn't write to $brk file: $!";

while (<F>)
{
 chomp;
 my @data = split ' ';                  # you may want to ensure the size of @data is the same every time
 $size = scalar @data;                  # but $size will have the LAST size of @data
 print B join("\n", @data), "\n";
}

close F;
close B;

Basically converting a MxN matrix into (MN)x1

Let's assume you will just have 1000 columns for this example.

Now you can write each inverted output line by looking in break.txt,
reading every line, chomp() it, and append it to your current output
line if it's divisible by 1000 (so 0, 1000, 2000, etc. will match).
Write "\n" to end the current output line.  

Now you can do the next output line, which requires lines 1, 1001, 2001,
etc.  You can reopen the break.txt file or just seek to the beginning.

I am not writing out the whole thing because it's tedious and I think
you should consider a database instead.  It could be optimized, but
you're basically putting lipstick on a pig when you spend your time
optimizing the wrong solution for your needs.

Ted


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

Date: 10 Aug 2007 15:52:09 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: how to tranpose a huge text file
Message-Id: <5i3ft9F3ncksoU1@mid.dfncis.de>

Ted Zlatanov  <tzz@lifelogs.com> wrote in comp.lang.perl.misc:
> On Wed, 08 Aug 2007 20:56:24 -0000 Jie <jiehuang001@gmail.com> wrote: 
> 
> J> I have a huge text file with 1000 columns and about 1 million rows,
> J> and I need to transpose this text file so that row become column and
> J> column become row. (in case you are curious, this is a genotype
> J> file).

[Nice single-file solution snipped]

>  $size = scalar @data;                  # but $size will have the LAST size of @data

Useless use of scalar() here.

Anno


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

Date: Fri, 10 Aug 2007 11:39:28 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: how to tranpose a huge text file
Message-Id: <m2ejib8htr.fsf@lifelogs.com>

On 10 Aug 2007 15:52:09 GMT anno4000@radom.zrz.tu-berlin.de wrote: 

a> Ted Zlatanov  <tzz@lifelogs.com> wrote in comp.lang.perl.misc:
>> $size = scalar @data;                  # but $size will have the LAST size of @data

a> Useless use of scalar() here.

I like to make scalar context explicit.  IMHO it makes code more
legible.  It's my style, and AFAIK it doesn't cause problems (I also
like to say "shift @_" and "shift @ARGV" to be explicit as to what I'm
shifting).

I'll be the first to admit my style is peculiar, e.g. single-space
indents, but at least I'm consistent :)

Ted


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

Date: 10 Aug 2007 16:40:41 GMT
From: xhoster@gmail.com
Subject: Re: how to tranpose a huge text file
Message-Id: <20070810124043.144$rx@newsreader.com>

Jie <jiehuang001@gmail.com> wrote:

> But I really doubt that either will work. So, can someone please throw
> some idea and hopefully code here?!

Hi Jie,

We've already thrown out several ideas.  Some take a lot of memory, some
take a lot of file-handles, some need to re-read the file once for each
column.

You haven't really commented on the suitability of any of these methods,
and the new information you provided is very minimal.  So I wouldn't expect
to get many more ideas just be asking the same question again!

What did you think of the ideas we already gave you?  Do they exceed your
system's memory?  Do they exceed your file-handle limit?  Do they just take
too long?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Fri, 10 Aug 2007 07:02:24 -0700
From:  Charles Packer <mailbox@cpacker.org>
Subject: In what order does readdir() see a directory?
Message-Id: <1186754544.281041.215530@j4g2000prf.googlegroups.com>

In what order does readdir() see the
entries in a directory (in a Unix
environment)? I'm posting about this
as a sort of public service -- a search
shows that nobody's posted herein about
this gotcha.

Tests on several directories seemed to
indicate that "." and ".." always come
first. The examples in "Perl Cookbook"
and other places include a check for these
inside the loop...but hey, if I'm processing
directories with thousands of files, as in

   while (defined($FileName = readdir(DIR))) {

seems not unreasonably anal to eliminate
those two pesky entries right away with two
premptive readdir() calls before entering
the loop, right? Bad idea!

--
Charles Packer
http://cpacker.org/whatnews
mailboxATcpacker.org



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

Date: Fri, 10 Aug 2007 14:46:05 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: In what order does readdir() see a directory?
Message-Id: <87odhfh2he.fsf@hacking.dk>

Charles Packer <mailbox@cpacker.org> writes:

> In what order does readdir() see the
> entries in a directory (in a Unix
> environment)?

The order of entries returned by readdir is not defined. It depends on
the filesystem, filesystem settings and for some filesystems the order
which the files is added and removed from the directory and for other
filestsyems is is purly based on their names.

Many (older) filesystems just allocated directory entries in some
blocks on the filesystem and scans these blocks lineary when doing a
readdir. Then '.' and '..' will always be the first. Ext3 on Linux
usually uses hashed b-trees to store directory entries. On these
systems the order is purly based on the name of the files in the
directory, but seemingly random due to hashing.


> directories with thousands of files, as in
>
>    while (defined($FileName = readdir(DIR))) {
>
> seems not unreasonably anal to eliminate
> those two pesky entries right away with two
> premptive readdir() calls before entering
> the loop, right? Bad idea!

That wouldn't work in a portable way.

//Makholm


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

Date: Fri, 10 Aug 2007 10:53:58 GMT
From: markpf@gmail.com
Subject: Initial release of Kx-0.0.1
Message-Id: <JMKD5K.1vAC@zorch.sf-bay.org>

NAME
    Kx - Perl extension for Kdb+ http://kx.com

SYNOPSIS
      use Kx;

DESCRIPTION
    Create a wrapper around Kdb+ and Q in Perl using the C interface
to Kdb+


This is Alpha code. It has had some reasonable testing but is really
just
experimental at the moment. I have run and tested this on Linux and
MacOSX only. MacOSX is my major development platform (x86 only).

INSTALLATION

first get a copy of c.o from kx.com for your architecture
make libkdb.a from c.o for easy linking
        ar -r libkdb c.o
or
        libtool -static -o libkdb.a c.o

perl Makefile.PL
make
make test     # you must have a 'q' process running on port 2222 (q -p
2222)
make install

cheers
markpf




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

Date: Fri, 10 Aug 2007 14:58:02 -0000
From:  ktlind@gmail.com
Subject: match and group across 2 lines
Message-Id: <1186757882.456127.270930@q4g2000prc.googlegroups.com>

I would like to group six numbers separated by commas into $1 thru $6.
The problem is that four of the numbers are on the first line and two
of the numbers are on the second line. Here is an example of those 2
lines:

SLN499 = LINE/994.455930,-49.320125,347.561019,994.456333 $
    ,-49.320486,347.560579

The $ on the end of the first line is a continuation symbol for the
next line.


I can group the first four numbers with:

^SLN\d\d\d = LINE\/(.*),(.*),(.*),(.*) \$$

How can I reach down one more line and get the other two numbers?


Thanks for your help.



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

Date: Fri, 10 Aug 2007 15:22:11 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: match and group across 2 lines
Message-Id: <Do%ui.72936$Io4.16030@edtnps89>

ktlind@gmail.com wrote:
> I would like to group six numbers separated by commas into $1 thru $6.
> The problem is that four of the numbers are on the first line and two
> of the numbers are on the second line. Here is an example of those 2
> lines:
> 
> SLN499 = LINE/994.455930,-49.320125,347.561019,994.456333 $
>     ,-49.320486,347.560579
> 
> The $ on the end of the first line is a continuation symbol for the
> next line.
> 
> 
> I can group the first four numbers with:
> 
> ^SLN\d\d\d = LINE\/(.*),(.*),(.*),(.*) \$$
> 
> How can I reach down one more line and get the other two numbers?

$ echo "SLN499 = LINE/994.455930,-49.320125,347.561019,994.456333 $
     ,-49.320486,347.560579

" | \
perl -lne'
   if ( s/\$$// ) {
     $_ .= <>;
     redo;
     }
   if ( s/^SLN\d\d\d = LINE\/// ) {
     @x = split /\s*,\s*/;
     print "@x";
     }
'
994.455930 -49.320125 347.561019 994.456333 -49.320486 347.560579



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Fri, 10 Aug 2007 17:25:52 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: match and group across 2 lines
Message-Id: <5i3eioF3lt3aqU1@mid.individual.net>

ktlind@gmail.com wrote:
> I would like to group six numbers separated by commas into $1 thru $6.
> The problem is that four of the numbers are on the first line and two
> of the numbers are on the second line. Here is an example of those 2
> lines:
> 
> SLN499 = LINE/994.455930,-49.320125,347.561019,994.456333 $
>     ,-49.320486,347.560579
> 
> The $ on the end of the first line is a continuation symbol for the
> next line.
> 
> 
> I can group the first four numbers with:
> 
> ^SLN\d\d\d = LINE\/(.*),(.*),(.*),(.*) \$$
> 
> How can I reach down one more line and get the other two numbers?

     ^SLN\d\d\d = LINE\/(.*),(.*),(.*),(.*) \$\s+,(.*),(.*)$

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Fri, 10 Aug 2007 15:55:49 -0000
From:  ktl <ktlind@gmail.com>
Subject: Re: match and group across 2 lines
Message-Id: <1186761349.629544.302590@e9g2000prf.googlegroups.com>

On Aug 10, 8:22 am, "John W. Krahn" <du...@example.com> wrote:
> ktl...@gmail.com wrote:
> > I would like to group six numbers separated by commas into $1 thru $6.
> > The problem is that four of the numbers are on the first line and two
> > of the numbers are on the second line. Here is an example of those 2
> > lines:
>
> > SLN499 = LINE/994.455930,-49.320125,347.561019,994.456333 $
> >     ,-49.320486,347.560579
>
> > The $ on the end of the first line is a continuation symbol for the
> > next line.
>
> > I can group the first four numbers with:
>
> > ^SLN\d\d\d = LINE\/(.*),(.*),(.*),(.*) \$$
>
> > How can I reach down one more line and get the other two numbers?
>
> $ echo "SLN499 = LINE/994.455930,-49.320125,347.561019,994.456333 $
>      ,-49.320486,347.560579
>
> " | \
> perl -lne'
>    if ( s/\$$// ) {
>      $_ .= <>;
>      redo;
>      }
>    if ( s/^SLN\d\d\d = LINE\/// ) {
>      @x = split /\s*,\s*/;
>      print "@x";
>      }
> '
> 994.455930 -49.320125 347.561019 994.456333 -49.320486 347.560579
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order.                            -- Larry Wall

Thanks for the quick response John.
But what is this?

      " | \





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

Date: Fri, 10 Aug 2007 11:26:17 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Out of memory in vec
Message-Id: <m2lkcj8ifq.fsf@lifelogs.com>

On 10 Aug 2007 07:35:48 GMT anno4000@radom.zrz.tu-berlin.de wrote: 

a> Mumia W. <paduille.4061.mumia.w+nospam@earthlink.net> wrote in comp.lang.perl.misc:
a> [...]

>> I then went to writing the transposition program. A gigabyte (1e6 rows × 
>> 1000 columns) is a lot of memory, so I wanted to avoid forcing each item 
>> to take an entire byte, and since A, C, T and G are only four distinct 
>> values, an entire byte is not needed to encode them, so I opted to use 
>> four bits for each item and the vec() function:

a> Why four?  You only need two bits to encode four bases.

"--" was also allowed as data besides a pair of letters, so you have

[ACGT][ACGT] = 4 bits (which is what Mumia means by "item", I think)
plus "--" as a value = 5 bits

Ted


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

Date: 10 Aug 2007 12:03:05 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: pass by reference
Message-Id: <5i32fpF3mpehuU1@mid.dfncis.de>

Billy Patton  <bpatton@ti.com> wrote in comp.lang.perl.misc:
> Larry wrote:
> > The following code snippet shows how I do "pass by reference" in
> > Perl.  It works fine, but I'm wondering... is there a less verbose way
> > to do this?

[...]

> Do you really want side effects ?
> Passing by reference does this.
> Guess this is too simple to make that decision.
> 
> sub squareMe($) {
>    my ($arg) = @_;
>    $arg *= $arg;
> }
> 
> my $n=7;
> $n = squareMe $n;  # no side effects
> I hate it when my variables get changed somewhere else and I have to 
> track it down for debugging!

That raises the question why you are using the mutator "*=" at all. It
doesn't do anything useful.

    sub square_me {
        my $arg = shift;
        $arg*$arg;
    }

would be exactly equivalent, as would be

    sub square_me { $_[0]*$_[0] }

Anno


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

Date: Fri, 10 Aug 2007 08:04:47 -0500
From: hymie_@_lactose.homelinux.net (hymie!)
Subject: Re: pass by reference
Message-Id: <bIydncVcC7ry_yHbnZ2dnUVZ_hGdnZ2d@comcast.com>

In our last episode, the evil Dr. Lacto had captured our hero,
  Tad McClellan <tadmc@seesig.invalid>, who said:

>I've heard it pronounced "dollar underwear".

Thanks for reminding me.  I have to go shopping tonight.

--hymie!    http://lactose.homelinux.net/~hymie    hymie@lactose.homelinux.net
------------------------ Without caffeine for 283 days ------------------------


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

Date: 10 Aug 2007 09:32:47 -0500
From: Lawrence Statton <yankeeinexile@gmail.com>
Subject: Re: pass by reference
Message-Id: <87absz8now.fsf@hummer.cluon.com>

Michele Dondi <bik.mido@tiscalinet.it> writes:
> On Thu, 09 Aug 2007 11:28:07 -0700, Jim Gibson
> <jgibson@mail.arc.nasa.gov> wrote:
> 
> >$_ is a name, just not a pronounceable one!
> 
> In English, it's "it".

In English.pm it's "$ARG" ...  :) 

lawrence@hummer - /tmp % cat ex-1
#!/usr/bin/perl
use strict;
use warnings;
use English;

sub square_me {
  $ARG[0] *= $ARG[0];
}

my $foo = 5;
square_me($foo);
print "$foo\n";

lawrence@hummer - /tmp % perl ex-1
25

-- 
	Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
place them into the correct order.


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

Date: Fri, 10 Aug 2007 11:12:04 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: pass by reference
Message-Id: <46bc8e54$0$10306$815e3792@news.qwest.net>

Lawrence Statton wrote:
> Michele Dondi <bik.mido@tiscalinet.it> writes:
>> On Thu, 09 Aug 2007 11:28:07 -0700, Jim Gibson
>> <jgibson@mail.arc.nasa.gov> wrote:
>>
>>> $_ is a name, just not a pronounceable one!
>> In English, it's "it".
> 
> In English.pm it's "$ARG" ...  :) 

Shouldn't that be Pirates.pm?


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

Date: 10 Aug 2007 12:05:15 -0500
From: Lawrence Statton <yankeeinexile@gmail.com>
Subject: Re: pass by reference
Message-Id: <87643n8gms.fsf@hummer.cluon.com>

"J. Gleixner" <glex_no-spam@qwest-spam-no.invalid> writes:

> Lawrence Statton wrote:
> > Michele Dondi <bik.mido@tiscalinet.it> writes:
> >> On Thu, 09 Aug 2007 11:28:07 -0700, Jim Gibson
> >> <jgibson@mail.arc.nasa.gov> wrote:
> >>
> >>> $_ is a name, just not a pronounceable one!
> >> In English, it's "it".
> > In English.pm it's "$ARG" ...  :)
> 
> Shouldn't that be Pirates.pm?

Ahh, no -- tehre it's $ARRRRRRRRRRRRRRRRRRRRRRRR 


-- 
	Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
place them into the correct order.


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

Date: Fri, 10 Aug 2007 05:47:18 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: Using DBI, Bind with Update
Message-Id: <1186750038.659735.59280@i13g2000prf.googlegroups.com>

On Aug 10, 5:58 am, Jason <jwcarl...@gmail.com> wrote:
> I haven't been able to find any real documentation on using bind other
> than the CPAN info on the DBI module,  and I'm finding VERY limited
> information on the MySQL site, so if you guys know where I can read up
> on this, I would appreciate a link.
>
> I'm very confused on the use (and necessity) of bind_param. I need to
> make an update to a live MySQL table, and was hoping you guys could
> make sure that my logic was sound before I do it:
>
> # an example of @rows; the real array has around 17,000 values
> $rows[0] = "1000" . "|" . "Test" . "|" . "20070809" . "|" . "Jason" .
> "|" . "jwcarl...@gmail.com" . "|" . "Test Comment";

Gah.  How do you read something like that?  Why not simply
$rows[0] = "1000|Test|20070809|Jason|jwcarl...@gmail.com|Test
Comment";

> my $sth_subjects = $dbh->prepare(<<SQL);
> UPDATE subjects SET lastmodified=?, firstname=?, shortdesc=? WHERE id=?
> SQL
>
> foreach $key (@rows) {
>   my ($id, $lastdate, $subject, $firstname, $lastname, $size,
> $shortdesc) = split(/\|/, $key);
>
>   $sth_subjects->bind_param(1, $lastdate);
>   $sth_subjects->bind_param(2, $firstname);
>   $sth_subjects->bind_param(3, $shortdesc);
>   $sth_subjects->bind_param(4, $id);
>   $sth_subjects->execute;
> }
>
> Am I correct in my understanding that the number used in bind_param
> refers to the position that the column is in? Meaning, since
> "lastmodified" was the first one listed in the UPDATE query, then it's
> considered # 1. And if I had reversed "lastmodified" and "firstname",
> then the numbers would have also reversed.

90% correct.  It's not the name of the field that matters, or how many
arguments are in the SET or WHERE clauses.  It's the number of
placeholders (ie, question marks) in the query.  If you used a real
value for the third one:
UPDATE subjects SET lastmodified=?, firstname=?, shortdesc="foobar"
WHERE id=?
then you would bind parameters 1 for lastmodified, 2 for firstname,
and 3 for id.

> I'm also guessing that $sth_subjects->execute($lastmodified,
> $firstuser, $shortdesc, $key) wouldn't be the same?

Assuming you meant $id here instead of $key, no, that's not correct.
They would be exactly the same.  From the DBI docs:
If any arguments are given, then execute will effectively call
"bind_param" for each value before executing the statement. Values
bound in this way are usually treated as SQL_VARCHAR types unless the
driver can determine the correct type (which is rare), or unless
bind_param (or bind_param_inout) has already been used to specify the
type.

Calling execute with a list of parameters is a shortcut for having to
call bind_param however many times.

Paul Lalli



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

Date: Fri, 10 Aug 2007 11:10:05 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Using DBI, Bind with Update
Message-Id: <m2tzr78j6q.fsf@lifelogs.com>

On Fri, 10 Aug 2007 05:47:18 -0700 Paul Lalli <mritty@gmail.com> wrote: 

PL> On Aug 10, 5:58 am, Jason <jwcarl...@gmail.com> wrote:
>> # an example of @rows; the real array has around 17,000 values
>> $rows[0] = "1000" . "|" . "Test" . "|" . "20070809" . "|" . "Jason" .
>> "|" . "jwcarl...@gmail.com" . "|" . "Test Comment";

PL> Gah.  How do you read something like that?  Why not simply
PL> $rows[0] = "1000|Test|20070809|Jason|jwcarl...@gmail.com|Test
PL> Comment";

Whenever I see something like the OP's code, I must point out join()

Ted


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 741
**************************************


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