[15538] in Perl-Users-Digest
Perl-Users Digest, Issue: 2948 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 4 11:11:23 2000
Date: Thu, 4 May 2000 08:10:14 -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: <957453014-v9-i2948@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 4 May 2000 Volume: 9 Number: 2948
Today's topics:
Re: How to print '%' character with printf ? <aqumsieh@hyperchip.com>
Re: How to print '%' character with printf ? <uackermann@orga.com>
Re: How to print '%' character with printf ? <d.courivaud@esiee.fr>
Re: How to print '%' character with printf ? <billy@arnis-bsl.com>
Re: Newbie needs help splitting file (Tad McClellan)
Newbie question (probably somthing simple) <franklint@mdot.state.mi.us>
Re: newbie: can't open text file in windows (path to fi <russ@css2.com>
Re: newbie: can't open text file in windows (path to fi <johny@supermedia.pl>
Re: newbie: can't open text file in windows <jeff@vpservices.com>
Re: Perl & delivering Databases? <jeff@vpservices.com>
Re: Problems with installing/making and recognising Per <jeff@vpservices.com>
Re: reg expressions assistance <aqumsieh@hyperchip.com>
Re: reg expressions assistance (Tad McClellan)
Re: Regex for not matching a particular string <lr@hpl.hp.com>
Tanspose rows to columns jimbob4334@my-deja.com
Re: where is the getopt::Std module <sariq@texas.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 04 May 2000 13:09:33 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: How to print '%' character with printf ?
Message-Id: <7avh0upilv.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
Daniel Courivaud <d.courivaud@esiee.fr> writes:
> Hello world,
>
> I'm a beginner with Perl and I have a probably very basic question but I
> found nothing in perldoc and faqs. I want to print a string containing
> '%' character:
>
> 50 % of the files
>
> and I try many things like __ printf(" %i \% of the
> files",$percentage); __ but none of them are working.
printf " %i %% of the files", $percentage;
But why are you using printf() here? print() is sufficient in this case.
--Ala
------------------------------
Date: Thu, 04 May 2000 15:14:32 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: How to print '%' character with printf ?
Message-Id: <391177B8.71FB022C@orga.com>
Daniel Courivaud wrote:
> found nothing in perldoc and faqs. I want to print a string containing
> '%' character:
> 50 % of the files
> and I try many things like __ printf(" %i \% of the
> files",$percentage); __ but none of them are working.
if you do not insist on using the printf function, why not format your
value with sprintf (e.g. my $percentage = 45.67; $percentage = sprintf
"%.d", $percentage;) and then use the print-function (print"
$percentage\% of the files\n";).
But I can not tell you, why your fprint-version did not work. :-(
Ulrich
--
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925
mailto:uackermann@orga.com
------------------------------
Date: Thu, 04 May 2000 15:33:23 +0200
From: Daniel Courivaud <d.courivaud@esiee.fr>
Subject: Re: How to print '%' character with printf ?
Message-Id: <39117C23.8412BDBB@esiee.fr>
$percentage is in fact a real value and I want to limit precision on the
screen:
$percentage=42.259321452 printed as 42.26 %
Ala Qumsieh a écrit :
> Daniel Courivaud <d.courivaud@esiee.fr> writes:
>
> > Hello world,
> >
> > I'm a beginner with Perl and I have a probably very basic question but I
> > found nothing in perldoc and faqs. I want to print a string containing
> > '%' character:
> >
> > 50 % of the files
> >
> > and I try many things like __ printf(" %i \% of the
> > files",$percentage); __ but none of them are working.
>
> printf " %i %% of the files", $percentage;
>
> But why are you using printf() here? print() is sufficient in this case.
>
> --Ala
--
---
Daniel COURIVAUD
---
Dpt Télécommunications et http://www.esiee.fr/tdsweb
Traitement du Signal
---
Groupe ESIEE Paris http://www.esiee.fr/
2 Bld Blaise Pascal
93162 Noisy le Grand
tél.: 01.45.92.67.87
fax: 01.45.92.66.99
------------------------------
Date: Thu, 04 May 2000 13:23:20 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: How to print '%' character with printf ?
Message-Id: <8ertjn$rmk$1@nnrp1.deja.com>
In article <391174F8.25D1C112@esiee.fr>,
Daniel Courivaud <d.courivaud@esiee.fr> wrote:
> Hello world,
>
> I'm a beginner with Perl and I have a probably very basic question but I
> found nothing in perldoc and faqs. I want to print a string containing
> '%' character:
>
> 50 % of the files
>
> and I try many things like __ printf(" %i \% of the
> files",$percentage); __ but none of them are working.
>
printf "%d %% of file", $percentage;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 4 May 2000 08:52:07 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Newbie needs help splitting file
Message-Id: <slrn8h2sjn.23o.tadmc@magna.metronet.com>
On 4 May 2000 08:35:15 GMT, Anamarija Kruljac <akruljac@rudjer.irb.hr> wrote:
>Can you give me an example script for the following problem or at least
>point me where should I look for more info on how to do something like that?
>I have something like a flatfile database, an large file with lots of
>records. Something like:
[ snip records, repeated in code below ]
>I'd like to select records from original file, based on different key
>values, and transfer those records to another file. For example, I want all
>records where Key1 contains "apple" and Key2 does not contain "blue" in
>another file.
-----------------------------------
#!/usr/bin/perl -w
use strict;
{ local $/ = "--END LINE--\n";
while (<DATA>) {
next if /^Key2: .*blue/m; # skip if Key2 contains "blue"
print if /^Key1: .*apple/m; # print if Key1 contains "apple"
}
}
__DATA__
--START LINE--
Key1: apple
Key2: blue
Key3: sky
Key4: high
--END LINE--
--START LINE--
Key1: apple
Key2: green
Key3: sky
Key4: high
--END LINE--
--START LINE--
Key1: apple
Key2: sky blue
Key3: sky
Key4: high
--END LINE--
-----------------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 04 May 2000 11:04:16 -0400
From: Tom Franklin <franklint@mdot.state.mi.us>
Subject: Newbie question (probably somthing simple)
Message-Id: <39119170.A3A1F@mdot.state.mi.us>
I installed a copy of Active Perl on an NT machine running Netscape
Enterprise web server. I followed all the instructions as far as "file
associations". I added the directories to BOTH the perl.exe file AND the
script directory to the PATH, and added a "PATHEXT" for .pl extentions.
From the command line, I can type "hello" and it will fire up the
infamaous Hello World script from a file called hello.pl. I can do this
from any directory, so I KNOW I have the associations set correctly. So,
here's my problem. I can't call the file from my browser. I've set up a
"shell cgi" directory under Netscape server and activated the MIME type
pl as "magnus-internal/shellcgi" with "pl" as the suffix. When I type
the URL http://myservername/shellcgi/hello, I get a:
Not Found
The requested object does not exist on this server. The link you
followed is either outdated, inaccurate, or the server has been
instructed not to let you have it.
When I check the error log I see:
[04/May/2000:10:55:01] warning ( 409): send-cgi:failed to get
associated file for (c:/netscape/suitespot/httpd/shellcgi/hello) Error 2
[04/May/2000:10:55:01] failure ( 409): for host 162.108.33.13 trying to
GET /shellcgi/hello, shellcgi-send reports: can't find file association
of c:/netscape/suitespot/httpd/shellcgi/hello for execution.
I have set security permissions for the perl directory, AND the shellcgi
directory to FULL for the user that the web server runs under (even
though I only need R and X...but I was grasping at straws here).
ANYBODY have ANY suggestions?
Thanx in advance
------------------------------
Date: Thu, 04 May 2000 13:32:18 GMT
From: "Russell England" <russ@css2.com>
Subject: Re: newbie: can't open text file in windows (path to file)
Message-Id: <CZeQ4.1296$tQ3.192914@news3.cableinet.net>
Thanks for your reply.
I just tried that but it didn't work. Is the ':' or '\' a special character?
"Jonathan Kazmierczak" <johny@supermedia.pl> wrote in message
news:39115D95.EDC3E4EA@supermedia.pl...
> Hello!
>
> > script is in c:\inetpub\wwwroot\cgi-bin and I use
> > http://localhost/cgi-bin/test/pl to run it. The html is returned okay.
>
> >
>
> > test.pl
> > $worked = open(oFile,">>mylog.log");
>
> Here you have error: current directory in Windows is c:\inetpub\wwwroot.
> You must specified full path:
> $worked = open(oFile,'>>c:\inetpub\wwwroot\cgi-bin\mylog.log');
>
> Johny.
>
>
------------------------------
Date: Thu, 04 May 2000 15:45:27 +0200
From: Jonathan Kazmierczak <johny@supermedia.pl>
Subject: Re: newbie: can't open text file in windows (path to file)
Message-Id: <39117EF6.2A2B7EBA@supermedia.pl>
> I just tried that but it didn't work. Is the ':' or '\' a special character?
'\' is a mask character. But it works only in double quotas.
> > $worked = open(oFile,'>>c:\inetpub\wwwroot\cgi-bin\mylog.log');
is equal to
$worked = open(oFile,">>c:\\inetpub\\wwwroot\\cgi-bin\\mylog.log");
Johny.
------------------------------
Date: Thu, 04 May 2000 06:45:50 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: newbie: can't open text file in windows
Message-Id: <39117F0E.B53433AB@vpservices.com>
Russell England wrote:
>
> My first script and I can't get it to work. The open file doesn't seem to
> work.
> #!/usr/bin/perl
Broken record: use -w and "use strict" to spot problems before they
occur.
> use CGI qw(:standard);
Add "use CGI::Carp qw(fatalsToBrowser)" to allow (many) errors to be
sent to your browser so you can see what is going on when something
fails.
> $worked = open(oFile,">>mylog.log");
Perl has a very nice feature that tells you if an open works or if not
why it fails. In fact, it is the only thing that can tell you why your
open isn't working, we can't guess from here. Change that line to:
$worked = open(oFile,">>mylog.log") or die $!;
The chances are that "mylog.log" is in some other directory than your
script is operating in (scripts can operate different places than you
think they might depending on server settings) so you'll probably need
to sepcify a full absolute file (not url) path to that file.
--
Jeff
------------------------------
Date: Thu, 04 May 2000 06:39:21 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl & delivering Databases?
Message-Id: <39117D89.8211A80A@vpservices.com>
ammar_aganovic@my-deja.com wrote:
>
> In article <39107876.F9D3FC49@vpservices.com>,
> Jeff Zucker <jeff@vpservices.com> wrote:
> > ammar_aganovic@my-deja.com wrote:
> > >
> > > I need to make a database residing on MySQL available to custom
> > > developed software which would be able to access the database
> directly.
> >
> > The slightest search of Perl materials for "MySQL" or of MySQL
> materials
> > for "Perl" would lead you to the Perl DBI module and its DBD::mysql
> > driver. It is a complete solution for accessing MySQL (with or
> without
> > ODBC) from Perl and also works with just about every other database
> > under the sun.
>
> I think you missed the point.
Yep, looks like I did, sorry.
> The MySQL DB would not let me connect directly ((My)ODBC, perl, php3)
> from any host other that localhost.
Why? Is it a permissions problem? If so, solving that sounds alot
simpler than the other route.
> I was thinking of building some
> sort of gateway between the Client & the Server but located at the
> server side. I have no problem reading the DBs either with PHP3 or
> Perl. the client, the Delphi client programm would hten read the stream and
> store it in it's internal database. After the internal stored DB would
> be modified, the information would go in other direction -> the client
> would then feed the records to some Perl script which would read the
> stream, and update the original database.
I guess I am still lost as to why you need to do all that rather than
operating on the original database directly.
--
Jeff
------------------------------
Date: Thu, 04 May 2000 06:19:37 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Problems with installing/making and recognising Perl modules
Message-Id: <391178E9.32852BF3@vpservices.com>
Miles Davenport wrote:
>
> #!/usr/bin/perl -- -*-perl-*-
Broken record: add -w and use strict to help you spot problems before
they occur.
> use lib '/users/perl/modules'; ## this is where all my modules go
No problem there.
> use XML::Parse
Needs an "r" at the end. The module is Parser.pm.
> Where modules will contain a sub directory like XML, and then Parse.pm. I
> have also tried require, adding the full path to @INC - but PERL will not
> pick up the new module (I don't think Perl likes the /users/perl/modules).
I can't think of any reason why it shouldn't. Is that directory on the
same drive as where the script is operating from?
> I think I am missing a really easy step, but can't find it.
Did you specify /users/perl/modules when you did your make steps by
setting PREFIX, or LIB, or PERL5LIB? (You did do the make steps rather
than just copying the .pm files, didn't you?)
> Can someone give me an idiots :) guide to doing this
perlfaq8: "How do I keep my own module/library directory?"
--
Jeff
------------------------------
Date: Thu, 04 May 2000 13:32:18 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: reg expressions assistance
Message-Id: <7asnvyphjz.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
"Lauren Smith" <lauren_smith13@hotmail.com> writes:
> spurcell <skpurcell@hotmail.com> wrote in message
> news:390f2f24$0$1862@wodc7nh1.news.uu.net...
> >
> > $fish =~ s/^\s*|\s*$//g;
>
> That doesn't strip leading and trailing blank spaces.
Ummm... it does:
% perl -wl
$fish = ' hello ';
$fish =~ s/^\s*|\s*$//g;
print ">>$fish<<";
__END__
>>hello<<
--Ala
------------------------------
Date: Thu, 4 May 2000 09:30:42 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: reg expressions assistance
Message-Id: <slrn8h2us2.2am.tadmc@magna.metronet.com>
On Thu, 04 May 2000 13:32:18 GMT, Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
>
>"Lauren Smith" <lauren_smith13@hotmail.com> writes:
>
>> spurcell <skpurcell@hotmail.com> wrote in message
>> news:390f2f24$0$1862@wodc7nh1.news.uu.net...
>> >
>> > $fish =~ s/^\s*|\s*$//g;
>>
>> That doesn't strip leading and trailing blank spaces.
^^^^^^^^^^^^
>Ummm... it does:
'blank spaces' are only a subset of what it deletes, since
it deletes _other_ whitespace characters as well.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 4 May 2000 07:02:16 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regex for not matching a particular string
Message-Id: <MPG.137b22c5e057ca298a9f3@nntp.hpl.hp.com>
In article <39112CEF.55B0FF12@eed.ericsson.se> on Thu, 04 May 2000
09:55:27 +0200, Joern Stein <eedjoes@eed.ericsson.se> says...
...
> how about this substitution:
>
> s#(http://)(.*)#$1www.mysite.com/redirect?$2# if $2;
>
> Would that help?
Hardly, because the value of $2 being tested is that derived from a
preceding match in the same scope, if any.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 04 May 2000 14:39:38 GMT
From: jimbob4334@my-deja.com
Subject: Tanspose rows to columns
Message-Id: <8es237$lu$1@nnrp1.deja.com>
Hi,
I have been trying to convert this:
4|3|7|0|2|0|2|0|2|1|1|0|2|3|0|0|0|0|0|0|0|0|0|0|1.1|
6|2|3|4|6|3|6|8|6|1|2|5|3|7|2|0|0|0|0|0|0|0|0|0|1.2|
0|0|0|0|0|0|0|0|0|0|0|0|0|5|3|0|0|0|0|0|0|0|0|0|1.3|
into this:
<PRO>
1.1
1.2
1.3
</PRO>
<DATA>
4 6 0
3 2 0
7 3 0
0 4 0
2 6 0
0 3 0
2 6 0
0 8 0
2 6 0
1 1 0
1 2 0
0 5 0
2 3 0
3 7 5
0 2 3
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
</DATA>
Thanks,
Jim
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 04 May 2000 09:19:48 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: where is the getopt::Std module
Message-Id: <39118704.504B6CAD@texas.net>
Jonathan Stowe wrote:
>
> On Wed, 03 May 2000 11:13:45 -0500 Tom Briles wrote:
> > vnguyen_1999@my-deja.com wrote:
> >>
> >> Hello Everyone,
> >>
> >> I want to download the getopt::Std module but could not find in CPAN.
> >
> > I don't know how you missed it on CPAN.
>
> Probably because the capitalization is wrong - it is Getopt::Std of course.
>
> /J\
Yes, I knew that (and perhaps you knew that I knew that :), but the
search on the CPAN isn't case sensitive.
A search on 'getopt' worked fine for me.
- Tom
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 2948
**************************************