[19195] in Perl-Users-Digest
Perl-Users Digest, Issue: 1390 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 27 06:05:45 2001
Date: Fri, 27 Jul 2001 03:05:08 -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: <996228308-v10-i1390@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 27 Jul 2001 Volume: 10 Number: 1390
Today's topics:
Re: Addressing WinNT Task Manager <bowman@montana.com>
FAQ: How do I expand function calls in a string? <faq@denver.pm.org>
Re: ftp hangs <Thomas@Baetzler.de>
Re: How do I make sure I get all form fields and values (Eric Bohlman)
Re: How do I make sure I get all form fields and values <godzilla@stomp.stomp.tokyo>
Re: How to loop over files whose names are listed in a <Graham.T.Wood@oracle.com>
Re: How to loop over files whose names are listed in a (Francois Boury)
Image Size <johannes_be@gmx.de>
Re: Image Size <ilya@martynov.org>
Re: Image Size <johannes_be@gmx.de>
Re: Image Size <ilya@martynov.org>
Re: Image Size <Thomas@Baetzler.de>
Re: Image Size <johannes_be@gmx.de>
Re: Image Size <johannes_be@gmx.de>
need a starting point (Kokijaz)
Re: need a starting point <ilya@martynov.org>
Need help on processing some data (Tim)
Re: Need help on processing some data <godzilla@stomp.stomp.tokyo>
Re: Need help on processing some data (Eric Bohlman)
Re: Need help on processing some data <jeff@vpservices.com>
Re: Need help on processing some data <godzilla@stomp.stomp.tokyo>
Re: Perl Docs <ilya@martynov.org>
Re: reading/writing email as (file)stream <pne-news-20010727@newton.digitalspace.net>
Re: successive foreach loop (=?ISO-8859-1?Q?Olivier_Bo=EBl?=)
Re: What's the idiomatic way for this? <Thomas@Baetzler.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Jul 2001 22:19:30 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: Addressing WinNT Task Manager
Message-Id: <DW587.19504$qT1.4096@newsfeed.slurp.net>
"Me" <madewildeNOSPAM@hotmail.com> wrote in message
news:3B5FDDAE.CBEF2A2B@hotmail.com...
>
> Or at any rate retrieving process id's from running windows programs (so
> NOT the ones you create yourself - those I can find...)?
on NT/2000, you can get the pid's by accessing HKEY_PERFORMANCE_DATA in the
Registry. This is actually an ephemeral hive that doesn't show up in
regedit. If psapi.dll is on the machine, it may also be used to enumerate
the processes.
A third alternative is using the WMI interface.
------------------------------
Date: Fri, 27 Jul 2001 06:17:33 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I expand function calls in a string?
Message-Id: <1I787.98$os9.173514752@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 do I expand function calls in a string?
This is documented in the perlref manpage. In general, this is fraught
with quoting and readability problems, but it is possible. To
interpolate a subroutine call (in list context) into a string:
print "My sub returned @{[mysub(1,2,3)]} that time.\n";
If you prefer scalar context, similar chicanery is also useful for
arbitrary expressions:
print "That yields ${\($n + 5)} widgets\n";
Version 5.004 of Perl had a bug that gave list context to the expression
in "${...}", but this is fixed in version 5.005.
See also ``How can I expand variables in text strings?'' in this section
of the FAQ.
-
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 coming 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 or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have 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 are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
04.20
--
This space intentionally left blank
------------------------------
Date: Fri, 27 Jul 2001 10:12:49 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: ftp hangs
Message-Id: <cp72mt4hni50rfnjurk49sn4427cngjul5@4ax.com>
Hi,
Giovanni Leoncini <leoncini@metsun1.met.sjsu.edu> wrote:
>we recently updated our OS from Red Hat 7.0 to 7.1. Now the perl script
>that ftps data into the machine hangs when retrieving a file or doing an
>ls. Using the debugger I noticed that other commands like cd, or size work
>fine and the instruction that waits for ever is
>
>$peer = accept($new,$sock) (line 177 of Socket.pm)
[...]
>Ftp to the same site, from the command line is still fine.
[...]
Is that so? Try conneting to that site from the command line again and
once you're logged in, enter "passive". You should see a message that
tells you that the passive ("PASV") transfer mode is now on (or off,
if you were on passive mode by default). Now try you "ls" again. If it
does not work anymore, you have identified the problem: an (or
several) intermediate firewall system(s) is blocking either active or
passive FTP transfers to the target site.
See perldoc Net::Config.pm on how to configure the FTP transfer mode
if that is indeed your problem.
HTH,
--
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.
------------------------------
Date: 27 Jul 2001 04:28:54 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: How do I make sure I get all form fields and values?
Message-Id: <9jqqm6$i77$1@bob.news.rcn.net>
M Hunt <mhunt5@nospam.net> wrote:
> I'm writing out a CSV file which contains all the names and values submitted
> from a form. My question is: for checkboxes and/or fields that were not
> answered, I get nothing back. This considered, how do I maintain the
> integrity of my fields in the CSV. What I need to do is somehow append a ",
> NULL" or something when fields are not filled in. This gets difficult when
> nothing is returned; with a checkbox for example.
> Also, I just saw in another thread where someone was saying that I can't
> even count on the form fields being returned in a particular order. How is
> this typically handled -- anyone with a code sample or something?
You need to iterate over a (literal) list of fieldnames in the order in
which you want to store them. Something like:
foreach my $field
(qw/name address city state zip phone opt1 opt2 opt3 opt4 opt5/) {
$csv .= ',' if length $csv;
$csv .= param($field);
}
------------------------------
Date: Thu, 26 Jul 2001 22:24:10 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: How do I make sure I get all form fields and values?
Message-Id: <3B60FAFA.FA541AA6@stomp.stomp.tokyo>
M Hunt wrote:
(snipped)
> I'm writing out a CSV file which contains all the names and values submitted
> from a form. My question is: for checkboxes and/or fields that were not
> answered, I get nothing back. This considered, how do I maintain the
> integrity of my fields in the CSV.
Any answers provided which contain code samples are
wild guesses. You have provided zero parameters and
have not provided information about your read and
parse methodology.
Iterate through your expected returns and set any null
return to whatever value is appropriate.
if (not whichever return)
{ return equals whatever }
Godzilla!
------------------------------
Date: Fri, 27 Jul 2001 09:17:48 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: How to loop over files whose names are listed in a file
Message-Id: <3B6123AB.1022B70A@oracle.com>
This is a multi-part message in MIME format.
--------------AF5C4735B2EAEA5BFABCF01E
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Francois Boury wrote:
> So I have a file (files_list.txt fro instance) that contains some file
> names.
>
> How to replace my actual piece of code that is :
> while(<*.html>)
> {
> my $fichier_out=$fichier . ".tmp";
> remplacerBreves($_,$fichier_out);
> }
>
> by the same thing for all the files listed in files_list.txt ?
---------------------------------------------------------------------------
# open the file, and if it doesn't open explain why
open(LIST,"files_list.txt") || die "Can't open files_list.txt $! \n";
# put each line from the file into @files array, removing the newline from
the end
chop(@files=<LIST>);
#close the file
close LIST;
#loop through each entry in the file
foreach(@files)
{
my $fichier_out=$fichier . ".tmp";
remplacerBreves($_,$fichier_out);
}
---------------------------------------------------------------------------
perldoc -f open will explain how to open a file.
Graham Wood
--------------AF5C4735B2EAEA5BFABCF01E
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------AF5C4735B2EAEA5BFABCF01E--
------------------------------
Date: 27 Jul 2001 01:20:35 -0700
From: fboury@lequipe.fr (Francois Boury)
Subject: Re: How to loop over files whose names are listed in a file
Message-Id: <fa18770.0107270020.368abcd9@posting.google.com>
Thanks a lot. It works fine.
------------------------------
Date: Fri, 27 Jul 2001 09:10:12 +0200
From: "Johannes B." <johannes_be@gmx.de>
Subject: Image Size
Message-Id: <9jr44l$57n$03$1@news.t-online.com>
Hi!
How can I get the width and height of an gif image which is located in a
folder of my server?
I need that because I'm running a little counter server with different
digits.
The CGI Script uses Fly to paste the little digits into a big image.
So I need the width and height of the digit to paste it correctly.
How can I get this data?
THX
Jojo
******** Deutsche Version*********
Hallo!
Ich muss für ein CGI Script die Breite und die Höhe eines GIF Bildes wissen,
welches auf meinem Server liegt.
I brauch die, weil ich einen kleinen Counterserver betreibe, bei dem sich
die User Ihre Digits aussuchen.
Das Counter Script benutzt Fly und die einzelnen Digits in das Endbild
einzufügen.
Dazu brauch ich aber die genaue höhe und breite des gewählten Bildes.
Wie finde ich das heraus?
Danke,
Jojo
------------------------------
Date: 27 Jul 2001 11:13:04 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Image Size
Message-Id: <87wv4uu9of.fsf@abra.ru>
JB> Hi!
JB> How can I get the width and height of an gif image which is located in a
JB> folder of my server?
JB> I need that because I'm running a little counter server with different
JB> digits.
JB> The CGI Script uses Fly to paste the little digits into a big image.
JB> So I need the width and height of the digit to paste it correctly.
JB> How can I get this data?
Use Image::Size from CPAN.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Fri, 27 Jul 2001 10:30:49 +0200
From: "Johannes B." <johannes_be@gmx.de>
Subject: Re: Image Size
Message-Id: <9jr8rq$trh$04$1@news.t-online.com>
Thx, but I don't have Image::Size on my server.
And I cant install it.
Is there another Way????
"Ilya Martynov" <ilya@martynov.org> wrote in message
news:87wv4uu9of.fsf@abra.ru...
>
> JB> Hi!
> JB> How can I get the width and height of an gif image which is located in
a
> JB> folder of my server?
> JB> I need that because I'm running a little counter server with different
> JB> digits.
> JB> The CGI Script uses Fly to paste the little digits into a big image.
> JB> So I need the width and height of the digit to paste it correctly.
> JB> How can I get this data?
>
> Use Image::Size from CPAN.
>
> --
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> | Ilya Martynov (http://martynov.org/)
|
> | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6
|
> | AGAVA Software Company (http://www.agava.com/)
|
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: 27 Jul 2001 12:33:47 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Image Size
Message-Id: <87snfirct0.fsf@abra.ru>
JB> Thx, but I don't have Image::Size on my server.
JB> And I cant install it.
JB> Is there another Way????
Install it from CPAN:
http://search.cpan.org/search?dist=Image-Size
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Fri, 27 Jul 2001 11:13:13 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Image Size
Message-Id: <6rb2mtcmotj79f46247f38otfsu4q5if8a@4ax.com>
Hi,
On 27 Jul 2001, Ilya Martynov <ilya@martynov.org> wrote:
>JB> Thx, but I don't have Image::Size on my server.
>JB> And I cant install it.
>JB> Is there another Way????
>
>Install it from CPAN:
>
> http://search.cpan.org/search?dist=Image-Size
Hm. Why is installing from CPAN different than installing? ;-)
Of course, he could probably grab the module and install it manually
in a sub-directory that he has access to. After adding the path to
@INC it would probably work.
Alternatives: If you have a fixed set of images for the numbers, why
not record the size of each image once and then use that static info
instead of recomputing it every time?
Another alternative would be to grab the GIF specs and parse the imge
header manually. At least for simple GIF images, that's pretty much
trivial.
HTH,
--
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.
------------------------------
Date: Fri, 27 Jul 2001 11:11:19 +0200
From: "Johannes B." <johannes_be@gmx.de>
Subject: Re: Image Size
Message-Id: <9jrb7n$v62$05$1@news.t-online.com>
I already tried it. But it doesn't work.
I can only login to the server via FTP.
"Ilya Martynov" <ilya@martynov.org> wrote in message
news:87snfirct0.fsf@abra.ru...
>
> JB> Thx, but I don't have Image::Size on my server.
> JB> And I cant install it.
>
> JB> Is there another Way????
>
> Install it from CPAN:
>
> http://search.cpan.org/search?dist=Image-Size
>
> --
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> | Ilya Martynov (http://martynov.org/)
|
> | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6
|
> | AGAVA Software Company (http://www.agava.com/)
|
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Fri, 27 Jul 2001 11:17:22 +0200
From: "Johannes B." <johannes_be@gmx.de>
Subject: Re: Image Size
Message-Id: <9jrbj2$fgd$03$1@news.t-online.com>
So...I noted the specs of all 100 digit sets down....
was really "easy"!
thx, for your support ;)
"Thomas Bätzler" <Thomas@Baetzler.de> wrote in message
news:6rb2mtcmotj79f46247f38otfsu4q5if8a@4ax.com...
> Hi,
>
> On 27 Jul 2001, Ilya Martynov <ilya@martynov.org> wrote:
> >JB> Thx, but I don't have Image::Size on my server.
> >JB> And I cant install it.
> >JB> Is there another Way????
> >
> >Install it from CPAN:
> >
> > http://search.cpan.org/search?dist=Image-Size
>
> Hm. Why is installing from CPAN different than installing? ;-)
>
> Of course, he could probably grab the module and install it manually
> in a sub-directory that he has access to. After adding the path to
> @INC it would probably work.
>
> Alternatives: If you have a fixed set of images for the numbers, why
> not record the size of each image once and then use that static info
> instead of recomputing it every time?
>
> Another alternative would be to grab the GIF specs and parse the imge
> header manually. At least for simple GIF images, that's pretty much
> trivial.
>
> HTH,
> --
> Thomas Baetzler - http://baetzler.de/ - Clan LoL -
http://lavabackflips.de/
> I am the "ILOVEGNU" signature virus. Just copy me to your signature.
> This post was infected under the terms of the GNU General Public License.
------------------------------
Date: 27 Jul 2001 00:00:59 -0700
From: drapot@net.hr (Kokijaz)
Subject: need a starting point
Message-Id: <39d07d19.0107262300.50e48479@posting.google.com>
Is it possible to make some kind of (C++) application and then to
embed some other language full functionality (preferable perl) into
this application. Something like Mic. Office and VBA. So the
application will be protected from client's hacking and clients will
have some more convinient tool for data processing and conversion.
I want to do some kind of application that will pick up and process
large amount of distributed data. The C++ part of the application
would be responsible for opening sockets, transfering files, ziping
and unziping, converting binaries to ASCII and vice versa and thinks
like that. I don't want to give access to that part of code. But I
want that user is able to add his functionality to processing of data
converted to ASCII. I don't know what kind of functionality he wants
and how often he will change that.
I believe that this thing is very much possible and allready
implemented in number of applications but I didn't find much
informations. (only s-lang stuff)
So if anybody has some informations, ideas or hints please share them
with me.
thanks
------------------------------
Date: 27 Jul 2001 11:12:34 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: need a starting point
Message-Id: <871yn2vo9p.fsf@abra.ru>
K> Is it possible to make some kind of (C++) application and then to
K> embed some other language full functionality (preferable perl) into
K> this application. Something like Mic. Office and VBA. So the
K> application will be protected from client's hacking and clients will
K> have some more convinient tool for data processing and conversion.
K> I want to do some kind of application that will pick up and process
K> large amount of distributed data. The C++ part of the application
K> would be responsible for opening sockets, transfering files, ziping
K> and unziping, converting binaries to ASCII and vice versa and thinks
K> like that. I don't want to give access to that part of code. But I
K> want that user is able to add his functionality to processing of data
K> converted to ASCII. I don't know what kind of functionality he wants
K> and how often he will change that.
K> I believe that this thing is very much possible and allready
K> implemented in number of applications but I didn't find much
K> informations. (only s-lang stuff)
K> So if anybody has some informations, ideas or hints please share them
K> with me.
K> thanks
Many scripting languages can be embedded into applications. If you are
looking for docs on embeding Perl in C read this:
http://perldoc.com/perl5.6/pod/perlembed.html
If you have no exact requirement for scripting language you can also
check Ruby and Python. AFAIK they can be embeded also. I have no idea
which scripting lanugage is simpler to embed or suits your needs
better. You should choose yourself.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: 26 Jul 2001 21:55:44 -0700
From: tvn007@hotmail.com (Tim)
Subject: Need help on processing some data
Message-Id: <21724be2.0107262055.1aab4bc2@posting.google.com>
Hi,
Could someone help me on this ?
I have a sample input as follow:
companyXYZ:ABC:1
companyXYZ:DEF:3
companyZZZ:ABC:5
companyZZZ:DEF:7
I would like to have the output as follow:
companyXYZ companyZZZ
ABC 1 5
DEF 3 7
Any help/hint would be greatly appreciate !
------------------------------
Date: Thu, 26 Jul 2001 22:11:46 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Need help on processing some data
Message-Id: <3B60F812.7911DF11@stomp.stomp.tokyo>
Tim wrote:
(snipped)
> Could someone help me on this ?
> I have a sample input as follow:
> I would like to have the output as follow:
Post your code you are developing to attain your goal.
People here will help you with your code.
Godzilla!
------------------------------
Date: 27 Jul 2001 06:23:02 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Need help on processing some data
Message-Id: <9jr1c6$ipi$1@bob.news.rcn.net>
Tim <tvn007@hotmail.com> wrote:
> Hi,
> Could someone help me on this ?
> I have a sample input as follow:
> companyXYZ:ABC:1
> companyXYZ:DEF:3
> companyZZZ:ABC:5
> companyZZZ:DEF:7
> I would like to have the output as follow:
> companyXYZ companyZZZ
> ABC 1 5
> DEF 3 7
#!/usr/bin/perl -w
use strict;
my (%columns,%rows);
while (<DATA>) {
chomp();
my ($col,$row,$cell)=split /:/;
$rows{$row}{$col}=$cell;
$columns{$col}=1;
}
print "\t",join("\t",sort keys %columns),"\n";
foreach my $row (sort keys %rows) {
print "$row\t";
foreach my $col (sort keys %columns) {
print $rows{$row}{$col} if exists $rows{$row}{$col};
print "\t";
}
print "\n";
}
__END__
companyXYZ:ABC:1
companyXYZ:DEF:3
companyZZZ:ABC:5
companyZZZ:DEF:7
companyQQQ:DEF:9
companyXYZ:GHI:2
Note how this will correctly handle empty cells.
------------------------------
Date: Thu, 26 Jul 2001 23:24:30 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Need help on processing some data
Message-Id: <3B61091E.D8A2D796@vpservices.com>
Tim wrote:
>
> I have a sample input as follow:
>
> companyXYZ:ABC:1
> companyXYZ:DEF:3
> companyZZZ:ABC:5
> companyZZZ:DEF:7
>
> I would like to have the output as follow:
>
> companyXYZ companyZZZ
> ABC 1 5
> DEF 3 7
Well, if your data is as regular as you show it, this oughta do it:
my($tmphash,$newstr,@cols,%is_col);
for my $row(<INPUT>) {
chomp $row;
my($c1,$c2,$c3) = split /:/,$row;
push @cols, $c1 unless $is_col{$c1}++;
$tmphash->{$c2} .= "\t$c3";
}
while (my($key,$val)= each %$tmphash) {
$newstr .= "$key\t$val\n";
}
$newstr = "\t" . join("\t", @cols) . "\n$newstr";
But since you didn't specify what kind of duplication there is in the
data or how set the order of the data is, there's no way to know if that
will work for you.
--
Jeff
------------------------------
Date: Fri, 27 Jul 2001 01:19:01 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Need help on processing some data
Message-Id: <3B6123F5.746633E1@stomp.stomp.tokyo>
Eric Bohlman wrote:
> Tim wrote:
(snipped)
> > I have a sample input as follow:
> > companyXYZ:ABC:1
> > I would like to have the output as follow:
> > companyXYZ companyZZZ
> > ABC 1 5
> #!/usr/bin/perl -w
> use strict;
> Note how this will correctly handle empty cells.
It is prudent to test code before posting. Performing
tests of your code will assist you in avoiding posting
code which does not work correctly.
Godzilla!
--
PRINTED RESULTS:
________________
companyQQQ companyXYZ companyZZZ
ABC 1 5
DEF 9 3 7
GHI 2
------------------------------
Date: 27 Jul 2001 11:23:04 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Perl Docs
Message-Id: <87snfiu97r.fsf@abra.ru>
DM> Hi,
DM> I'm a reasonably good tech writer and a reasonably decent programmer.
DM> I've recently spent about 8 hours tracking down a weird problem that
DM> would've never happened if a simple note existed in the Perl docs that
DM> cross-referenced two functions. (For some, the technique is probably
DM> old hat, but it happened to be something I had never used before.)
DM> I also see occasional grammatical problems, broken links in the HTML
DM> version of the POD (which is what I use exclusively), and just plain
DM> bad writing.
DM> I'm a decent programmer, but not a great one, so I probably can't
DM> contribute much in the way of new or unusual modules, but I would be
DM> delighted to contribute to the documentation.
DM> How do I go about submitting changes for inclusion in future releases
DM> of Perl?
If it is doc bugs in some external Perl module (taken from CPAN for
example) you should contact its maintainer.
If you want to help with Perl modules in Perl distro I think you
should subscribe perl5-porters maillist. See
http://lists.perl.org/showlist.cgi?name=perl5-porters
for subscription info.
I think it is appropriate place to submit documentation and code
patches.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Fri, 27 Jul 2001 08:05:51 +0200
From: Philip Newton <pne-news-20010727@newton.digitalspace.net>
Subject: Re: reading/writing email as (file)stream
Message-Id: <3uu1mt0f0jje9hh02mtpmp4lismf37cmfr@4ax.com>
On Thu, 26 Jul 2001 11:51:15 -0400, Jeremy Lavine <jlavine@mitre.org>
wrote:
> Is there any simple way to read/write emails as (file)streams?
It depends.
> Would I have to use a command-line email program?
For writing, that's probably the easiest way. As seen in examples all
over the place. Something like
open MAIL, '| /path/to/email/program -op -tio -ns'
or die "Can't open pipe to mail: $!";
print MAIL "whatever";
close MAIL
or die "Can't close pipe to mail; returned " . ($? >> 8);
Reading mail is more interesting; it depends on your installation. If
you have direct delivery e.g. via SMTP, check to see whether your mailer
can call a program on receipt (it'll usually pass the mail to your
script's STDIN so you can read with "while(<STDIN>) { ... }"); if you
fetch the mail yourself, you probably can't put a filehandle on it but
will have to use POP3 or whatever.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 26 Jul 2001 23:27:29 -0700
From: oboel@dorrboel.com (=?ISO-8859-1?Q?Olivier_Bo=EBl?=)
Subject: Re: successive foreach loop
Message-Id: <e8f69cf.0107262227.35842a6f@posting.google.com>
Tom,
Thank you for your help. Indeed, my code was buggy and it is now fixed.
Regards,
Olivier (Perl newbee)
"Tom Melly" <tom.melly@ccl.com> wrote in message news:<3b6025ee$0$3759$ed9e5944@reading.news.pipex.net>...
> "Olivier Boël" <oboel@dorrboel.com> wrote in message
> news:e8f69cf.0107260523.608ac220@posting.google.com...
>
> <snip>
>
> Your partial code will be fine - whatever problem you are experiencing lies
> elsewhere.
>
> Try this:
>
> @list = qw(a b c d);
> foreach $element(@list){
> print "foo: $element\n";
> }
>
> foreach $element(@list){
> print "bar: $element\n";
> }
------------------------------
Date: Fri, 27 Jul 2001 08:57:45 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: What's the idiomatic way for this?
Message-Id: <c642mt8ti8i4ms26lsoehs2cjb0rhsjm7p@4ax.com>
Hi,
Wolfram Pfeiffer <wolfram.pfeiffer@bigfoot.com> wrote:
>Thomas Bätzler <Thomas@baetzler.de> wrote:
>[snip]
>> my @data;
>> # just some dummy data to print each day
>> for( my $i = 1; $i <= 31; $i++ ){ push @data, $i; }
>Why not:
>my @data = (1..31);
That makes definitely sense, from a Perl-ish pov.
[snip]
>> sub print_calendar {
>> my( $start, $refdata ) = @_;
>> if( 0 <= $start && $start <= 6 ){
[snip]
>I suggest:
>
> everything_ok
> or die "error";
> code;
[snip]
I find that I'm using both styles as my fancy strikes me. Must be my
Pascal/Modula/C Heritage that's showing through from time to time.
Anyways, see my .sig for a more Perl-ish take on the matter :-)
Cheers,
Thomas
use strict;sub p{print@_,"\n"}my($d,$t,$l,$h,$s,$b,$r)=qw(TD> TABLE> 31
TH> 6 TR>);my @n=($b)x$s;push@n,(1..$l);@n=map{"<$d$_</$d"}(@n,(
$b)x(($s=@n%7)?7-$s:0));splice@n,0,0,map{"<$h$_</$h"}qw(Mon Tue Wed Thu
Fri Sat Sun);p"<$t";while(@n){p"<$r",splice(@n,0,7),"</$r";}p"</$t";
------------------------------
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 1390
***************************************