[18590] in Perl-Users-Digest
Perl-Users Digest, Issue: 758 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 25 00:06:26 2001
Date: Tue, 24 Apr 2001 21:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <988171509-v10-i758@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 24 Apr 2001 Volume: 10 Number: 758
Today's topics:
Activestate 5.6.1 and MRTG 2.9.12 <dannygul@ionictech.com>
Re: Compression (to .zip/.gz) using system/backticks <webmaster@webdragon.unmunge.net>
Re: counter <Jonathan.L.Ericson@jpl.nasa.gov>
Email to MySQL <j2lab@my-deja.com>
Re: Execute command within the script <Jonathan.L.Ericson@jpl.nasa.gov>
Re: execution of perl script <Jonathan.L.Ericson@jpl.nasa.gov>
Re: fakessi <bart.lateur@skynet.be>
Re: How to send a URL to Win32 so it opens with the def <bart.lateur@skynet.be>
Re: How to send a URL to Win32 so it opens with the def <none@nope.net>
Re: How to send a URL to Win32 so it opens with the def <none@nope.net>
Re: Idiom: the expression of a copied & substituted str <johnlin@chttl.com.tw>
idiotic behaviour of the symboltable ( how to call a su <murat.uenalan@gmx.de>
Re: operators: != vs. ne, strange behaviour (Abigail)
Re: operators: != vs. ne, strange behaviour (Martien Verbruggen)
Re: Please help (pat)
Re: Please help (pat)
Re: Please help <wyzelli@yahoo.com>
Re: Please help <wyzelli@yahoo.com>
Re: Please help <joe+usenet@sunstarsys.com>
Re: pointer/reference question (Gwyn Judd)
Re: Problem - PERL mail script sends HTML formating as <Jonathan.L.Ericson@jpl.nasa.gov>
Reading from a file into a matrix (Falc2199)
Re: Reading from a file into a matrix <murat.uenalan@gmx.de>
Re: Reading from a file into a matrix <uri@sysarch.com>
Re: regexp matching with optional part (Abigail)
sorting filenames alphanumerically <motivus_BLAHdiBLAH@hotmail.com>
total newbie <ELINENTHAL@new.rr.com>
Re: total newbie (Gil G.)
Re: total newbie (Tad McClellan)
Re: weird 'use constant' behaviour. Suggestions? <webmaster@webdragon.unmunge.net>
Re: weird 'use constant' behaviour. Suggestions? (Jay Tilton)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 25 Apr 2001 03:09:57 GMT
From: "DG" <dannygul@ionictech.com>
Subject: Activestate 5.6.1 and MRTG 2.9.12
Message-Id: <9erF6.178216$lk6.16646752@typhoon.midsouth.rr.com>
Have just downloaded AS5.6.1 and MRTG and installed on W2k. Everything
appeared to go ok. However, I can create the html and png files and attempt
to load in my IE browser. The text part of the html loads ok, however, the
png files will not display. I check the properties on the .png files and
find that these files are really GIFs. I then save the png files as png
files and all works ok.
Has anyone experienced this problem? I am fairly new to MRTG and perl.
Thanks
dg
------------------------------
Date: 25 Apr 2001 01:38:43 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Compression (to .zip/.gz) using system/backticks
Message-Id: <9c59r3$2vm$0@216.155.33.49>
In article <tebmm59pkvh5a3@corp.supernews.com>,
Chris Stith <mischief@velma.motion.net> wrote:
| Scott R. Godin <webmaster@webdragon.unmunge.net> wrote:
|
| > heh, no I know about that -- I have CPAN.pm installed on my shell and
| > have dozens of locally installed modules via
| > LIB=~/perl/lib/perl5/site_perl;PREFIX=~/perl/lib/perl5/site_perl :-)
|
| So do this with everything else, including Archive::Tar and
| Compress::Zlib. Both are pure Perl.
|
| Compress::Zlib does require that zlib be installed, but if your
| hosting company does not have zlib installed, find a better
| hosting company.
I have two -- my own ISP (which I could change at any time but have NO
reason to -- I'm quite satisfied with them) and the site that's hosting
planetunreal.com for us Unreal Tournament gamers and we're plain stuck
with 'em.
| > and they just upgraded the box to FreeBSD 4.3-STABLE and Perl 5.005
| > <grin> More new stuff to learn.
|
| If they just upgraded to Perl 5.005 now that 5.6.1 is out, you might
| think about finding a better hosting company.
no, no, you're mixing up my hosting companies and don't know the
circumstances... :)
this is my ISP here.. the box/drive/something that the shell was on just
died, (which was IIRC sun4-solaris or something like it (which was what
perl put in my ~/perl/lib folder) *shrug*) and they are now using
FreeBSD and it came with Perl 5.005_03 which is a step up from the
previous 5.004 on the old dead box/drive. I wasn't expecting them to
upgrade, and although circumstances have forced their hand, I'm quite
pleased with the results.. since now, when I install modules via CPAN,
they take the group settings of the containing directory and I don't
have to beg the admins to change the group settings for every module I
make a marginal update for, now. MUCH better :)
Plus, Chris Nandor is working on the next MacPerl port to 5.6.1, so
_that_ I can wait for -- so that I have local perldocs again for the new
version.. reading perldocs via telnet is just slightly more fun than
peeling my fingernails off one by one. It's do-able, but a PITA too. :)
I expect the ISP will get around to installing a 5.6.1 perl sometime
soon, which will reside in a different location from the current
install. I'm not in any rush as long as my scripts don't start breaking
on me :)
| > -- what I meant was getting the admins at this other site to add any
| > modules I ftp over, into the 'www' group so that they are accessible by
| > the web, hence my comment about 'group'.
|
| They should be able to set your site up to run as your user. They
| should also be able to determine whether or not the modules will
| break anything. If they can't do one or the other, then you should
| probably find a better hosting company.
I totally agree with you -- I've been at them for over 5 months to
install the damn modules I need and all but two (CGI and File::Spec) are
not yet installed (and thus won't break anything), and the two that ARE,
are close enough in version numbers to what's current that it's only
bugfixes -- for example they're already past the change in CGI.pm that
requires the -no_xhtml switch if you desire the old behaviour.
| You could always look into colocting a server instead of changing
| hosting providers. If you do colocate, though, be ready to secure
| your own box. I enjoy no part of my job less than rebuilding a
| customer-managed colocation box and trying to recover all data,
| then billing the customer for my services all while I could be
| working on my own systems, keeping my own boxes secure and running.
It's a thought. Probably unlikely as I'm NOT well-heeled at the moment.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: 25 Apr 2001 01:01:58 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: counter
Message-Id: <86lmopbxmh.fsf@jon_ericson.jpl.nasa.gov>
"Kris van der Mast" <kris.v@net2view.be> writes:
> If anyone knows where I can find such scripts, please let me know.
Umm... www.google.com?
Jon
------------------------------
Date: Tue, 24 Apr 2001 20:25:50 -0700
From: John Smith <j2lab@my-deja.com>
Subject: Email to MySQL
Message-Id: <3AE643BD.8FF79ABB@my-deja.com>
I'm trying to come up with a method to do the following:
I'm planning on receiving hundreds of emails to one of my mail accounts
sitting on a Sendmail box. Each mail message will be unique and I want
to parse each message and put all the information in a MySQL database as
a separate entry. Once the message has been parsed and entered into the
database, I would delete the original mail message.
Are there any modules that I should look at for doing something like
this?
Any help will be greatly appreciated.
John
------------------------------
Date: 25 Apr 2001 01:41:40 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Execute command within the script
Message-Id: <86d7a1bvsb.fsf@jon_ericson.jpl.nasa.gov>
"yc" <leongyc@tp.edu.sg> writes:
> How to execute a command within a perl script?
From perlembed:
Read about back-quotes and about "system" and "exec"
in the perlfunc manpage.
Jon
------------------------------
Date: 25 Apr 2001 01:14:57 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: execution of perl script
Message-Id: <86hezdbx0u.fsf@jon_ericson.jpl.nasa.gov>
Gleason Sackmann <gsackmann@classroom.com> writes:
> I am new to this newsgroup, so I hope I'm in the right one.
Have you read it? Then you would know.
> I need some advice on a perl script that I am trying to execute as a
> batch file:
> C:\WINDOWS\COMMAND.COM /C ""C:/perl/bin/perl test.pl text.txt""
>
> When the batch file is executed, I always receive the following
> response:
> C:\TEMP>test
>
> C:\TEMP>C:\WINDOWS\COMMAND.COM /C ""C:\perl\bin\perl test.pl
> text.txt""
> Can't open perl script "test.pl": No such file or directory
From perldiag:
Can't open perl script ""%s"": %s
(F) The script you specified can't be opened for the
indicated reason.
Perhaps test.pl doesn't exist?
Might I suggest (as an aside) that you put C:/perl/bin in your PATH?
Jon
------------------------------
Date: Wed, 25 Apr 2001 01:31:30 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: fakessi
Message-Id: <t7acetgbptgmsgddq4ulvg408grl9usmrt@4ax.com>
John Michael wrote:
>I know you guys are busy, but never to busy to send a smart comment. I did
>try altavista before coming here and got quite a few sites that also led to
>either the same site or nothing. I will try a different one since I seem to
>have offened you guys.
Try Google. <www.google.com>.
--
Bart.
------------------------------
Date: Wed, 25 Apr 2001 01:33:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to send a URL to Win32 so it opens with the default browser
Message-Id: <jcacet02biavs4hmq6k8fu3pgsvrub9bte@4ax.com>
BigMacAttack wrote:
>I want to send a web page address to Windows in Active Perl
>5.6 and have whatever browser is configured as the
>default to open it.
system('start', 'http://www.perl.com/');
--
Bart.
------------------------------
Date: Tue, 24 Apr 2001 22:16:35 -0400
From: BigMacAttack <none@nope.net>
Subject: Re: How to send a URL to Win32 so it opens with the default browser
Message-Id: <ppccetg56psgoiap34l1kmqq2hna35m6l3@4ax.com>
On Wed, 25 Apr 2001 00:45:16 GMT, tiltonj@erols.com (Jay Tilton)
wrote:
>Use system() to call the Win32 'start' program, which automatically
Thanks for the speedy reply!
------------------------------
Date: Tue, 24 Apr 2001 22:17:16 -0400
From: BigMacAttack <none@nope.net>
Subject: Re: How to send a URL to Win32 so it opens with the default browser
Message-Id: <dsccets247b198m6mcqk0h0pl7j5osc7qk@4ax.com>
On Wed, 25 Apr 2001 01:33:36 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:
> system('start', 'http://www.perl.com/');
Thanks!!
------------------------------
Date: Wed, 25 Apr 2001 10:28:55 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Idiom: the expression of a copied & substituted string
Message-Id: <9c5cle$2cp@netnews.hinet.net>
Although maybe eventually you will feel this question is not worthy discussing,
I think I still need to explain and make clear what I was talking about...
"Chris Stith" wrote
> my $original = 'hello-world.pl';
> my $new = $original =~ s/\.pl$/.bak/;
> rename $original, $new;
Let's take this for example. It takes two "statements" to bring the
"copied and substituted string" into "rename" as its parameter.
If we want to do it in "one expression", the current answer I have is
do { (my $new = $original) =~ s/\.pl$/.bak/; $new }; # copied & substituted
that is
rename $original, do { (my $new = $original) =~ s/\.pl$/.bak/; $new };
Generally (I encounter this kind of problems quite often) we have to say
(my $expression1 = $original) =~ s/\.pl$/.bak/;
(my $expression2 = $original) =~ ... blah blah blah ...;
(my $expression3 = $original) =~ ... ;
...
finally_call_the_sub_with ($expression1,$expression2,$expression3 ...);
My goal is
directly_call (expression1_here, expression2_here, expression3_here);
For example:
directly_call(
do { (my $new = $original) =~ s/\.pl$/.bak/; $new },
do { (my $new = $original) =~ s/\.pl$/.pm/; $new },
do { (my $new = $original) =~ s/\.pl$//; $new }
)
The do{} is so cumbersome. I imagine there is something like
local $_ = $original;
directly_call(local(s/\.pl$/.bak/), local(s/\.pl$/.pm/), local(s/\.pl$//));
(Not in Perl, I invent it. : p)
That's why I ask here. Sorry, I didn't make my question understood.
Hmm... There is no such idiom; the answer is "just use TWO statements", right?
I think I am hairsplitting.
John Lin
--
P.S. a real case:
expand("A%CB%D") { => recursively call
expand("AACB%D"), # the string by replacing first % with A
expand("ABCB%D"), # the string by replacing first % with B
expand("ACCB%D"), # the string by replacing first % with C
expand("ADCB%D") # the string by replacing first % with D
}
I have both "two statements" version and "one expression" version.
------------------------------
Date: Wed, 25 Apr 2001 05:17:25 +0200
From: "Murat Uenalan" <murat.uenalan@gmx.de>
Subject: idiotic behaviour of the symboltable ( how to call a subroutine of an EXPLICIT package without an inherited one (from the ISA) ) ????
Message-Id: <9c5fjk$c1846$1@ID-71895.news.dfncis.de>
IS THIS IMPOSSIBLE ?!
I try to implement a code which calls a subroutine 'pre_init' (if it exists)
for every package in an ISA array. But it is fatal for me if perl calls a
parent 'pre_init' because its "inherited", i really just want the one of the
package !!!!! This code-snippet doesn't seem to work, because when tracking
the symbol-table (at the end) it shows the misere -> perl just simply copies
subroutine-symbolnames to the ISA packages (urghhhh...) THAT SEEMS TO DRAG
MY LEGS FROM THE GROUND -> HOW TO SOLVE MY PROBLEM ?
package Object;
sub Object::pre_init : method
{
my $this = shift;
$this->{ref($this).'::PRE_INIT_CALLED'} = __LINE__;
}
package Vehicle;
@ISA = qw( Object );
package Car;
@ISA = qw( Vehicle );
package main;
foreach my $parent ( @{ inheritance_isa( ref( $this ) || die ) } )
{
no strict 'refs';
if( defined *{ $parent.'::pre_init' }{CODE} )
{
*{ $parent.'::pre_init' }->( $this, $args );
}
}
__END__
The symboltable after the code executed !
main::Object::
main::Object::Debugable:: (package)
main::Object::ISA
main::Object::MODIFY_CODE_ATTRIBUTES
main::Object::post_init
main::Object::pre_init
main::Vehicle::
main::Vehicle::ISA
main::Vehicle::post_init
main::Vehicle::pre_init
main::Car::
main::Car::ISA
main::Car::post_init
main::Car::pre_init
------------------------------
Date: Wed, 25 Apr 2001 01:10:55 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: operators: != vs. ne, strange behaviour
Message-Id: <slrn9ec90v.3sc.abigail@tsathoggua.rlyeh.net>
Ren Maddox (ren@tivoli.com) wrote on MMDCCXCIII September MCMXCIII in
<URL:news:m3lmoqx75q.fsf@dhcp9-172.support.tivoli.com>:
^^
^^ There's obviously *something* special about strings starting with
^^ "NAN".
Yes, there is. And the differences you see even with the same version
of Perl are because of the interaction with the underlying C libraries.
It's a mess that should be fixed, and hopefully Perl 5.8 will behave much
better with respect to 'NaN' and 'Inf'.
Abigail
--
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;
sub _ {push @_ => /::(.*)/s and goto &{ shift}}
sub shift {print shift; @_ and goto &{+shift}}
Hack ("Just", "Perl ", " ano", "er\n", "ther "); # 20010425
------------------------------
Date: Wed, 25 Apr 2001 11:37:43 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: operators: != vs. ne, strange behaviour
Message-Id: <slrn9ecaj6.hu4.mgjv@martien.heliotrope.home>
On 24 Apr 2001 17:30:25 -0500,
Ren Maddox <ren@tivoli.com> wrote:
> On Tue, 24 Apr 2001, comdog@panix.com wrote:
>
>> In article <m3d7a2ywy0.fsf@dhcp9-172.support.tivoli.com>, Ren Maddox
>> <ren@tivoli.com> wrote:
>>
>>> $ perl -e 'print "Gotcha!\n" if "NAN" != "NAN"'
>>> Gotcha!
>>
>> which version of perl are you using?
And which platform are you on? looks like you've got a sonay vaio, if I
interpret the machine name correctly, but which OS are you running on
it?
>> vaio_brian[1789]$ perl5.00503 -e 'print "Gotcha!\n" if "NAN" != "NAN"'
>> vaio_brian[1790]$ perl5.6.0 -e 'print "Gotcha!\n" if "NAN" != "NAN"'
>> vaio_brian[1791]$
>
> $ perl -v
>
> This is perl, v5.6.0 built for i386-linux
> ...
>
> Something else interesting that I've found is:
>
> $ perl -le 'print "NON"+0'
> 0
> $ perl -le 'print "NAN"+0'
> nan
I can confirm this on
Linux martien 2.2.16-3 #1 Mon Jun 19 18:10:14 EDT 2000 i686 unknown
with glibc 2.1.3
$ perl -le 'print "NAN"+0'
nan
$ perl -v
This is perl, v5.6.1 built for i686-linux
$ perl5.00503 -le 'print "NAN"+0'
nan
$ perl5.00503 -v
This is perl, version 5.005_03 built for i686-linux
$ /opt/perl4/bin/perl -le 'print "NAN"+0'
nan
$ /opt/perl4/bin/perl -v
This is perl, version 4.0
$RCSfile: perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $
Patch level: 36
I suspect it has something to do with the GNU libc, and the fact that
isnan(3) is present. There are tests for this in Configure. I am not
sure what Perl does on systems where isnan(3) is not present, but it may
very well show a different behaviour.
Try something like
$ perl -MConfig -le 'print $Config{d_isnan}'
define
$ perl -MConfig -le 'print $Config{d_isnanl}'
define
to see whether Configure defined these when perl was built.
I won't comment on whether I think the behaviour is the right
behaviour.
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Wed, 25 Apr 2001 01:39:11 GMT
From: tulask@hotmail.com (pat)
Subject: Re: Please help
Message-Id: <Xns908DDE9C2tulask@24.215.0.21>
"John W. Krahn" <krahnj@acm.org> wrote in <3AE50B3C.CDFD559B@acm.org>:
>Joe Schaefer wrote:
>>
>> % perl -MMorse a1-q3.pl
>> 101, 102, 103, 104, 105, 106, 107, 108, 109, tenth
>> 111, 112, 113, 114, 115, 116, 117, 118, 119, tenth
>> 121, 122, 123, 124, 125, 126, 127, 128, 129, tenth
>> 131, 132, 133, 134, 135, 136, 137, 138, 139, tenth
>> 141, 142, 143, 144, 145, 146, 147, 148, 149, tenth
>
>You should have used the Bleach module. :-)
>
>
>John
@first=(101..150 ,"\n");
$"=", ";
go (@first);
dis (@first,@second);
print "@second \n"; #this is only here to do a test
sub go{
local (@second)=@_;
my ($rep)="tenth";
@second[10,20,30,40,50 ]=$rep;
print "@second \n";
}
sub dis{
local (@third)=@_;
@third=@second[0,1,2,3,4,5,6,7,8,9,10];
#@four=@second[11,12,13,14,15,16,17,18,19,20];
#@five=@second[21,22,23,24,25,26,27,28,29,30];
#@six=@second[31,32,33,34,35,36,37,38,39,40];
#@seven=@second[41,42,43,44,45,46,47,48,49,50];
#print "@third \n";
#print "@four \n";
#print "@five \n";
#print "@six \n";
#print "@seven \n";
}
------------------------------
Date: Wed, 25 Apr 2001 01:55:52 GMT
From: tulask@hotmail.com (pat)
Subject: Re: Please help
Message-Id: <Xns908DDBB7Atulask@24.215.0.21>
"John W. Krahn" <krahnj@acm.org> wrote in <3AE50B3C.CDFD559B@acm.org>:
>Joe Schaefer wrote:
>>
>> % perl -MMorse a1-q3.pl
>> 101, 102, 103, 104, 105, 106, 107, 108, 109, tenth
>> 111, 112, 113, 114, 115, 116, 117, 118, 119, tenth
>> 121, 122, 123, 124, 125, 126, 127, 128, 129, tenth
>> 131, 132, 133, 134, 135, 136, 137, 138, 139, tenth
>> 141, 142, 143, 144, 145, 146, 147, 148, 149, tenth
>
>You should have used the Bleach module. :-)
>
>
>John
Ok you got me Assignment 1 question 3
all this prints is
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
If you guy Know a better mothods Please let me know.
thanks a million $-)
@first=(101..150 ,"\n");
$"=", ";
go (@first);
dis (@first,@second);
print "@second \n"; #this is only here to do a test
sub go{
local (@second)=@_;
my ($rep)="tenth";
@second[10,20,30,40,50 ]=$rep;
print "@second \n";
}
sub dis{
local (@third)=@_;
@third=@second[0,1,2,3,4,5,6,7,8,9,10];
@four=@second[11,12,13,14,15,16,17,18,19,20];
@five=@second[21,22,23,24,25,26,27,28,29,30];
@six=@second[31,32,33,34,35,36,37,38,39,40];
@seven=@second[41,42,43,44,45,46,47,48,49,50];
print "@third \n";
print "@four \n";
print "@five \n";
print "@six \n";
print "@seven \n";
}
------------------------------
Date: Wed, 25 Apr 2001 11:41:42 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Please help
Message-Id: <5jqF6.4$fZ4.2757@vic.nntp.telstra.net>
"pat" <tulask@hotmail.com> wrote in message
news:Xns908DDBB7Atulask@24.215.0.21...
> "John W. Krahn" <krahnj@acm.org> wrote in <3AE50B3C.CDFD559B@acm.org>:
>
> If you guy Know a better mothods Please let me know.
> thanks a million $-)
@a=(101..150);@a=c(@a);for(@a){if(m/[^\d]/){print;
print"\n"}else{print;print', '}}sub c{for(1..@_){
next if($_%10);$_[$_-1]='tenth'}return @_}
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Wed, 25 Apr 2001 11:44:15 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Please help
Message-Id: <tlqF6.5$fZ4.2957@vic.nntp.telstra.net>
"pat" <tulask@hotmail.com> wrote in message
news:Xns908DDBB7Atulask@24.215.0.21...
>
> If you guy Know a better mothods Please let me know.
> thanks a million $-)
And a variation....
sub c{for(1..@_){next if($_%10);$_[$_-1]='tenth'}
return@_}@a=(101..150);@a=c(@a);for(@a){if(m/n/){
print;print"\n"}else{print;print', '}}
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: 24 Apr 2001 23:41:59 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Please help
Message-Id: <m3k849wsqg.fsf@mumonkan.sunstarsys.com>
tulask@hotmail.com (pat) writes:
> Ok you got me Assignment 1 question 3
> all this prints is
> ,,,,,,,,,
> ,,,,,,,,,
> ,,,,,,,,,
> ,,,,,,,,,
> ,,,,,,,,,
>
> If you guy Know a better mothods Please let me know.
> thanks a million $-)
Generally speaking it's not appropriate to ask for help with
classroom assignments here. However, I don't see anything wrong
with asking for help with some code you wrote yourself, so long
as the context is "what am I doing wrong here" and not "please
do my homework for me".
In that spirit, I'll offer some comments on what you've done so
far.
>
use strict;
use warnings;
# use comments :-)
> @first=(101..150 ,"\n");
^^ ^^^^
my not numeric, so it doesn't belong in your first array.
> $"=", ";
> go (@first);
> dis (@first,@second);
^^^^^^^
No - there's no use for a second array.
> print "@second \n"; #this is only here to do a test
>
> sub go{
> local (@second)=@_;
^^^^^^^^^^^^^^
You should be using "my", not "local". Also, this idiom conflicts with
your prior lack of interest in the return value of go(@first). If you
wish to alter some of the elements in @first, you should work directly
with the elements of @_ instead of copying it to @second.
> my ($rep)="tenth";
> @second[10,20,30,40,50 ]=$rep;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is a list assignment- the left side is an array slice with 5
elements, but the right side is a list with only one element. I
don't think it does what you expect it to.
Also, the tenth element in an array usually has index 9.
> print "@second \n";
> }
> sub dis{
> local (@third)=@_;
~~~~~
my
> @third=@second[0,1,2,3,4,5,6,7,8,9,10];
^^^^^^^^^^^^^^^^^^^^^^
@second is empty, but even if it weren't, @third would have eleven
elements. And on the prior line you assigned @third to @_. Make up
your mind already :-)
It might help if you tried to use more thoughtful names for your
arrays.
> @four=@second[11,12,13,14,15,16,17,18,19,20];
> @five=@second[21,22,23,24,25,26,27,28,29,30];
> @six=@second[31,32,33,34,35,36,37,38,39,40];
> @seven=@second[41,42,43,44,45,46,47,48,49,50];
^^
my
one "my" for each new array.
> print "@third \n";
> print "@four \n";
> print "@five \n";
> print "@six \n";
> print "@seven \n";
> }
With some decent array names and more careful array indexing,
you should be able to make this work. However, it would still
be wrong since it is comment-free code. In the long run, it's
far better to have a well-commented but broken script than an
inscrutable yet bug-free one. Understandable code can be fixed,
modified, and reused; but that is rarely true of the comment-free
variety.
YMMV
--
Joe Schaefer "I'll sleep when I'm dead."
-- Warren Zevon
------------------------------
Date: Wed, 25 Apr 2001 03:29:21 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: pointer/reference question
Message-Id: <slrn9ecl11.1gh.tjla@thislove.dyndns.org>
In article <slrn9ebu39.3sc.abigail@tsathoggua.rlyeh.net>,
Abigail <abigail@foad.org> wrote:
>xris (xris@dont.send.spam) wrote on MMDCCXCII September MCMXCIII in
><URL:news:xris-2BAAF9.23015022042001@news.evergo.net>:
>==
>== yeah, I think this is more what I'm after.. a world in which:
>==
>== \$x = \$y;
> *x = *y;
> $x = 1;
> $y ++;
> print $x;
... has side effects:
$y{hi} = 'hello';
print $x{hi};
sub y
{
print "hi";
}
x();
... and so on. Is there a way to alias one type of variable without
doing the whole typeglob?
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
RAM wasn't built in a day.
------------------------------
Date: 25 Apr 2001 01:00:42 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Problem - PERL mail script sends HTML formating as part of plain text message
Message-Id: <86pue1bxol.fsf@jon_ericson.jpl.nasa.gov>
"rthkid" <yourguru@whkjcssss.com> writes:
> I'm trying to have a PERL script email a message with HTML formating.
> The problem is that the HTML is sent as part of the plain text message.
> What command will force it to be sent as intended ?
I imagine this question is about MIME or some mail client, and only
tangentially perl related. You should post code, expected output and
sample input if this is really a perl issue.
Jon
------------------------------
Date: 25 Apr 2001 03:20:56 GMT
From: falc2199@aol.comNOJUNK (Falc2199)
Subject: Reading from a file into a matrix
Message-Id: <20010424232056.15333.00000691@ng-xc1.aol.com>
Can someone help me figure out what sure go into the following code....
I have 4 files with seperate lines of text ( sentences ) each of which I want
to be an element of 4 arrays. I want to open all four files, read the elements
into the four arrays, all in one loop.
First I have an array for the four files....
@file = ['thread.txt', 'object.txt','layout.txt', 'basic.txt'];
for ($i = 1; $i < $file; i++) # then I have my loop.
{
open(HANDLE, "<$file");
matrix[4][i]= <HANDLE>; # Now this is the line of code that has me stumped.
# matrix is supposed to be an array of
arrays with
# each internal array a collection of
sentences from one
# of the files in the @file array. The
external arrays
# represent one of those four files ( so
there should be
# four of them)
close(HANDLE);
}
Anyone have any ideas on how I should write that line so that I can properly
read in each of the sentences from each of the four lines.
Thanks in advance for any help
Falc
To e-mail, remove NOJUNK
------------------------------
Date: Wed, 25 Apr 2001 05:40:11 +0200
From: "Murat Uenalan" <murat.uenalan@gmx.de>
Subject: Re: Reading from a file into a matrix
Message-Id: <9c5gu7$c0n8k$1@ID-71895.news.dfncis.de>
First,
Not..
@file = ['thread.txt', 'object.txt','layout.txt', 'basic.txt'];
Try..
@file = ( 'thread.txt', 'object.txt','layout.txt', 'basic.txt' );
or even shorter
@file = qw( thread.txt object.txt layout.txt basic.txt );
Because..
Carefull with the brackets. You assigned a reference of an anonymous array
(the [ .. ]) to an array which is not what you want. You should use @array =
(), or $ref_to_array = [] ....not mixing it !
Second,
Not..
for ($i = 1; $i < $file; i++)
Try..
foreach my $file ( @file )
{
}
No more help: Just go and read the perl manpages or better read a book on
perl and try posting again.
Good Luck,
Murat
"Falc2199" <falc2199@aol.comNOJUNK> schrieb im Newsbeitrag
news:20010424232056.15333.00000691@ng-xc1.aol.com...
>
> Can someone help me figure out what sure go into the following code....
>
> I have 4 files with seperate lines of text ( sentences ) each of which I
want
> to be an element of 4 arrays. I want to open all four files, read the
elements
> into the four arrays, all in one loop.
>
> First I have an array for the four files....
>
> @file = ['thread.txt', 'object.txt','layout.txt', 'basic.txt'];
>
> for ($i = 1; $i < $file; i++) # then I have my loop.
> {
>
> open(HANDLE, "<$file");
>
> matrix[4][i]= <HANDLE>; # Now this is the line of code that has me
stumped.
> # matrix is supposed to be an array
of
> arrays with
> # each internal array a collection of
> sentences from one
> # of the files in the @file array. The
> external arrays
> # represent one of those four files (
so
> there should be
> # four of them)
> close(HANDLE);
>
> }
>
>
> Anyone have any ideas on how I should write that line so that I can
properly
> read in each of the sentences from each of the four lines.
>
> Thanks in advance for any help
> Falc
>
>
>
>
>
> To e-mail, remove NOJUNK
------------------------------
Date: Wed, 25 Apr 2001 03:43:07 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Reading from a file into a matrix
Message-Id: <x77l09iqzv.fsf@home.sysarch.com>
>>>>> "F" == Falc2199 <falc2199@aol.comNOJUNK> writes:
F> I have 4 files with seperate lines of text ( sentences ) each of
F> which I want to be an element of 4 arrays. I want to open all four
F> files, read the elements into the four arrays, all in one loop.
F> First I have an array for the four files....
F> @file = ['thread.txt', 'object.txt','layout.txt', 'basic.txt'];
that is not an array with 4 files. that is an array which has a single
anonymous array which has 4 file names.
you probably want (note the name is now @files):
@files = qw( thread.txt object.txt layout.txt basic.txt ) ;
F> for ($i = 1; $i < $file; i++) # then I have my loop.
F> {
that makes no sense. you never assigned anything to $file. that is not
the same as @file (which was assigned incorrectly). in general you
rarely need for loops in perl. use a foreach:
foreach my $file ( @files ) {
F> open(HANDLE, "<$file");
ALWAYS check your open calls for failure. if you did, you would have
seen that the file never opens as you don't have anything in $file
F> matrix[4][i]= <HANDLE>; # Now this is the line of code that has
F> me stumped.
F> # matrix is supposed to be an
F> array of arrays with # each internal array a collection of
F> sentences from one # of the files in the @file array. The external
F> arrays # represent one of those four files ( so there should be #
F> four of them) close(HANDLE);
you are unclear with what is in the files and how you want their data to
be in memory. show some example file data and the resulting data
structure you want.
read these perl documents for much more on those code areas:
perlopentut
perllol
perldsc
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Wed, 25 Apr 2001 01:07:18 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: regexp matching with optional part
Message-Id: <slrn9ec8q6.3sc.abigail@tsathoggua.rlyeh.net>
Greg Bacon (gbacon@HiWAAY.net) wrote on MMDCCXCIII September MCMXCIII in
<URL:news:tebteq1savjp86@corp.supernews.com>:
""
"" How about these apples?
""
"" % cat try
"" #! /usr/local/bin/perl -w
""
"" use strict;
""
"" for ('x--x', 'x-abc', 'abc-x', 'x-abc-x', 'abc') {
"" if (/ ^ x- (.+) -x $
"" | ^ x- (.+) (?<!-x$) $
"" | ^ (?!x-) (.+) -x $
"" | ^ (?!x-) (.+) (?<!-x$) $
"" /x)
"" {
"" print "ACCEPT '$_': '$+'\n";
"" }
"" else {
"" print "REJECT '$_'\n";
"" }
"" }
"" % ./try
"" REJECT 'x--x'
"" ACCEPT 'x-abc': 'abc'
"" ACCEPT 'abc-x': 'abc'
"" ACCEPT 'x-abc-x': 'abc'
"" ACCEPT 'abc': 'abc'
""
That apple rejects 'x-x'.
Abigail
------------------------------
Date: 25 Apr 2001 01:29:11 GMT
From: "bmm" <motivus_BLAHdiBLAH@hotmail.com>
Subject: sorting filenames alphanumerically
Message-Id: <9c5997$mr0@dispatch.concentric.net>
Hi. How would I perform an alphanumeric sort on filenames that abide by the
following naming convention:
intelVrambus_0001.csv
intelVrambus_0002.csv
...
intelVrambus_0255.csv
When I read the directory that contains the load files with the following
code
my @loadfiles;
find sub { push @loadfiles, $File::Find::name if /\.csv\z/ && -f; },
$loaddir;
I find that the files are not subsequently processed in alphanumeric order.
I suppose I need to sort the array, perhaps using the Schwartzian
Transformation -- but perhaps someone can step me through this beast and
give me a hint on how to adapt it?
@sorted = map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [ $_, uc( (/\d+\s*(\S+)/)[0]) ] } @data;
Danke,
Brian
------------------------------
Date: Wed, 25 Apr 2001 02:06:33 GMT
From: "Edward Linenthal" <ELINENTHAL@new.rr.com>
Subject: total newbie
Message-Id: <JiqF6.8467$V6.510456@typhoon.mn.mediaone.net>
I have been running windows for almost all the time I have had a computer.
However, I just downloaded Red Hat Linux 7.0, and I am learning how to
program Perl but I can't find the compiler in Linux. Whoever reads this
will probably think I am an idiot but Linux is totally new to me
Thanks,
Jake
------------------------------
Date: Wed, 25 Apr 2001 03:00:10 GMT
From: gil@nospam-keskydee.com (Gil G.)
Subject: Re: total newbie
Message-Id: <3ae63cf6.5374905@news-server>
On Wed, 25 Apr 2001 02:06:33 GMT, "Edward Linenthal"
<ELINENTHAL@new.rr.com> wrote:
>I have been running windows for almost all the time I have had a computer.
>However, I just downloaded Red Hat Linux 7.0, and I am learning how to
>program Perl but I can't find the compiler in Linux. Whoever reads this
>will probably think I am an idiot but Linux is totally new to me
>Thanks,
>Jake
>
>
Hello Jake,
There is no compiler, but an interpreter...
You don't really need to worry about it at this time.
Just make sure that to set your scripts to be executable, like so:
chmod 755 myscript.pl
Then execute it like this:
./myscript.pl
or
perl myscript.pl
I hope that helps, sincerely,
Gil.
PS: Don't forget, the first line of your scripts probably should be:
#!/usr/bin/perl
------------------------------
Date: Tue, 24 Apr 2001 23:00:02 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: total newbie
Message-Id: <slrn9ecfdi.rgv.tadmc@tadmc26.august.net>
Edward Linenthal <ELINENTHAL@new.rr.com> wrote:
>I have been running windows for almost all the time I have had a computer.
Everybody has problems.
>However, I just downloaded Red Hat Linux 7.0,
God bless you.
>and I am learning how to
>program Perl but I can't find the compiler in Linux.
try typing:
which perl
it should say something like:
/usr/bin/perl
or
/usr/local/bin/perl
If that doesn't work, see if perl is in your path:
perl -e 'print "perl must be in my path\n"'
If that runs, then start looking through the directories in your PATH
environment variable.
If _that_ doesn't work, you can try searching the Whole Darn File System:
find / -name perl
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Apr 2001 01:52:16 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: weird 'use constant' behaviour. Suggestions?
Message-Id: <9c5akg$2vm$1@216.155.33.49>
In article <9c53q9$9p6$0@216.155.33.49>,
"Scott R. Godin" <webmaster@webdragon.unmunge.net> wrote:
| I've tried like every variation I can think of
|
| use constant USE_SAVEFILE => exists($opts{'f'}) ? '1' : '0';
|
| use constant USE_SAVEFILE => (exists($opts{'f'}) ? '1' : '0');
|
| use constant USE_SAVEFILE => (exists($opts{'f'}) ? '1' : '0')[0];
|
| and this:
|
| my $save = exists($opts{'f'}) ? '1' : '0';
| use constant USE_SAVEFILE => $save;
| print "Constant = ", USE_SAVEFILE, "save = $save\n";
|
| gives me
| Use of uninitialized value at /home1/users/sgodin/bin/moduletest line 26.
| Constant = and save = 1
just to follow up and show other things I tried as well
originally I had written it as
use constant USE_SAVEFILE => exists($opts{'f'});
that didn't work, so I tried
use constant USE_SAVEFILE => exists($opts{'f'}) ? 1 : 0;
and went from there to the above.
I'm still scratching my head over this one.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Wed, 25 Apr 2001 03:05:06 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: weird 'use constant' behaviour. Suggestions?
Message-Id: <3ae63dde.12198287@news.erols.com>
On 25 Apr 2001 01:52:16 GMT, "Scott R. Godin"
<webmaster@webdragon.unmunge.net> wrote:
>I'm still scratching my head over this one.
Before eroding more of your scalp, you would do well to investigate
which statements are executed at compile time, and which are executed
at run time.
------------------------------
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 758
**************************************