[13285] in Perl-Users-Digest
Perl-Users Digest, Issue: 695 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 1 12:07:19 1999
Date: Wed, 1 Sep 1999 09:05:14 -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 Wed, 1 Sep 1999 Volume: 9 Number: 695
Today's topics:
Appending and Writing <richara@ecf.toronto.edu>
Blat on NT <stevencNOSPAM@nbnet.nb.ca>
Calling Perl from C (Win32) jonsson@sii.com
Re: Calling Perl from C (Win32) <ibelgaufts@gfc-net.de>
Re: Case insensitive SQL query <nospam.newton@gmx.net>
Comment modifier un fichier dans un =?iso-8859-1?Q?r=E9 <lcn@afp.com>
Re: Comment modifier un fichier dans un =?ISO-8859-1?Q? <revjack@radix.net>
Re: Comment modifier un fichier dans un =?iso-8859-1?Q? (Larry Rosler)
Re: Convert dbf files to ASCII text <msupadhyaya@mmm.com>
Re: Creating runtime variables. (M.J.T. Guy)
Re: Creating runtime variables. <aqumsieh@matrox.com>
directory processing <Laurent.Cordon@afp.com>
Re: EMPLOYMENT OPPORTUNITY:Perl/Web Developer <nospam.newton@gmx.net>
How to see documentation on HTTP and CGI modules <Mark.Conlin@bridge.bellsouth.com>
Need your help. <timukas@udu.ee>
Re: Need your help. <Mark@Mark.Com>
Newbie question about Perl executable <c@d.e>
Re: Perl/ HTML form mail attachments dominicj@my-deja.com
Re: Perl/ HTML form mail attachments dominicj@my-deja.com
Re: Perl/ HTML form mail attachments <gellyfish@gellyfish.com>
PPT I have a diff XSUB agutier@my-deja.com
Re: Printing problems NT and PERL <bauer@zrz.tu-berlin.de>
Q: regex: bug in subsituyr?? erik_lembke@my-deja.com
Re: Q: regex: bug in subsituyr?? <crdevilb@mtu.edu>
Re: Redirecting STDERR to STDOUT (on NT) (Bart Lateur)
Re: Redirecting STDERR to STDOUT (on NT) (Larry Rosler)
Re: Simulating Carriage Returns <paulm@dirigo.com>
Re: Simulating Carriage Returns <paulm@dirigo.com>
Re: Simulating Carriage Returns <cs004@wg.waii.com>
Re: Simulating Carriage Returns <gellyfish@gellyfish.com>
Re: subtraction error <Mark@Mark.Com>
Tracking progress of a Net::FTP download <ecliptica.ww@nospam.virgin.net>
Re: using ppm with proxy servers (Larry Rosler)
Re: What is DBI? <eyounes@aol.com>
Re: What is DBI? <nospam.newton@gmx.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 1 Sep 1999 15:14:23 GMT
From: RICHARDS AMANDA DAWN <richara@ecf.toronto.edu>
Subject: Appending and Writing
Message-Id: <Pine.SGI.3.96.990901111137.2865B-100000@skule.ecf>
I was wondering if there would be any way besides copying the contents of
a file, changing them and then writing a totally new file to change some
(well...one) bit of information in a file (ie get rid of the old bit in
the file and replace it with a new bit) and also append at the same time.
Would "+>>" let me do this??
Thanks a lot
Amanda
------------------------------
Date: Wed, 1 Sep 1999 12:46:30 -0300
From: "Caper" <stevencNOSPAM@nbnet.nb.ca>
Subject: Blat on NT
Message-Id: <7qjhpl$6km$1@garnet.nbnet.nb.ca>
I'm having trouble using the blat command to send an email with WinNT. The
whole script works but never sends out the email. When I did the
installation, I simply put Blat -install <smtp server> <my email> Is this
the problem or something else? In the option line [retry[port[profile]]],
what is the profile for?? Thanks
------------------------------
Date: Wed, 01 Sep 1999 14:13:49 GMT
From: jonsson@sii.com
Subject: Calling Perl from C (Win32)
Message-Id: <7qjcah$jcr$1@nnrp1.deja.com>
I'm working on a C project (NOT C++, can't use it because of some
limitation outside of my control) and need to link in Perl (I know this
can be done..) BUT the trick is that the Perl Scripts I need to execute
are using OLE Automation to access the Lotus Notes OLE Interface.
Has anyone any idea if this is possible or not?
Sverrir
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 01 Sep 1999 17:49:23 +0100
From: =?iso-8859-1?Q?J=FCrgen?= Ibelgaufts <ibelgaufts@gfc-net.de>
Subject: Re: Calling Perl from C (Win32)
Message-Id: <37CD5913.E75BD23B@gfc-net.de>
Yes it is possible. Read the perlembed documentation that comes with your Perl
distribution.
Juergen Ibelgaufts
------------------------------------------------
jonsson@sii.com schrieb:
>
> I'm working on a C project (NOT C++, can't use it because of some
> limitation outside of my control) and need to link in Perl (I know this
> can be done..) BUT the trick is that the Perl Scripts I need to execute
> are using OLE Automation to access the Lotus Notes OLE Interface.
>
> Has anyone any idea if this is possible or not?
>
> Sverrir
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
------------------------------
Date: Wed, 01 Sep 1999 15:51:59 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: Case insensitive SQL query
Message-Id: <37CD2F7F.E10F5780@gmx.net>
HHH wrote:
>
> elephant wrote:
> >
> > if I were to take a
> > wild stab in the dark - I'd say their web page is probably
> > www.mysql.com
>
> Actually, it is http://www.tcx.se/
Either works just fine. Or pick a mirror closer to you.
Cheers,
Philip
------------------------------
Date: Wed, 01 Sep 1999 16:00:35 +0200
From: Laurent Cordon <lcn@afp.com>
Subject: Comment modifier un fichier dans un =?iso-8859-1?Q?r=E9pertoire?=
Message-Id: <37CD3183.E78D2DC@afp.com>
--------------BAA224A5FEBB8D7EF071AD68
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Je suis un novice en perl et aimerais savoir comment afficher et
modifier un fichier qui se trouve dans un répertoire de façon simple
Merci par avance
--
*************************************************************
|Laurent Cordon Tel +00 1 40417739 |
| Fax +00 1 40417854 |
|Adresse : 4, Rue de la Bourse 75002 PARIS FRANCE |
|Email : Laurent.Cordon@afp.com |
|Web : http://www-ems.par.afp.com |
*************************************************************
--------------BAA224A5FEBB8D7EF071AD68
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Je suis un novice en perl et aimerais savoir comment afficher et modifier
un fichier qui se trouve dans un répertoire de façon simple
<br>Merci par avance
<pre>--
*************************************************************
|Laurent Cordon Tel +00 1 40417739 |
| Fax +00 1 40417854 |
|Adresse : 4, Rue de la Bourse 75002 PARIS FRANCE |
|Email : Laurent.Cordon@afp.com |
|Web : <A HREF="http://www-ems.par.afp.com">http://www-ems.par.afp.com</A> |
*************************************************************</pre>
</html>
--------------BAA224A5FEBB8D7EF071AD68--
------------------------------
Date: 1 Sep 1999 14:43:11 GMT
From: revjack <revjack@radix.net>
Subject: Re: Comment modifier un fichier dans un =?ISO-8859-1?Q?r=E9pertoire?=
Message-Id: <7qje1v$7t9$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight
Laurent Cordon explains it all:
:Je suis un novice en perl et aimerais savoir comment afficher et
:modifier un fichier qui se trouve dans un répertoire de façon simple
:Merci par avance
Pouvez-vous donner un exemple de ce que vous voulez faire? Vous pourriez
vouloir lire la documentation au sujet de "open" et comment lire un
fichier.
------------------------------
Date: Wed, 1 Sep 1999 07:54:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Comment modifier un fichier dans un =?iso-8859-1?Q?r=E9pertoire?=
Message-Id: <MPG.1236de00c5393129989f02@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37CD3183.E78D2DC@afp.com> on Wed, 01 Sep 1999 16:00:35
+0200, Laurent Cordon <lcn@afp.com> says...
> Je suis un novice en perl et aimerais savoir comment afficher et
> modifier un fichier qui se trouve dans un répertoire de façon simple
Touts fichiers se trouvent dans des répertoires, non?
Veuillez lire cette FAQ de perlfaq5: "How do I change one line in a
file/delete a line in a file/insert a line in the middle of a
file/append to the beginning of a file?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 01 Sep 1999 10:41:22 -0500
From: Mani Upadhyaya <msupadhyaya@mmm.com>
Subject: Re: Convert dbf files to ASCII text
Message-Id: <37CD4922.7B97900C@mmm.com>
Hi!
I need to read a *.dbf file and extract a column out. Today, we are
loading the dbf file into Microsoft Excel and cutting out the column we
need. I want to automate this process hence the need for a perl module.
Is there a perl module out there that can help me?
Thanks,
Mani.
------------------------------
Date: 1 Sep 1999 15:50:02 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Creating runtime variables.
Message-Id: <7qjhva$712$1@pegasus.csx.cam.ac.uk>
In article <7qgnm1$88u$1@kemer.cc.metu.edu.tr>,
baris sertkaya <e109775@orca.cc.metu.edu.tr> wrote:
>Hi folks..
>I am trying to create runtime variables like that:
>-----------------------------------
>for $n (0..2) {
> $a="var$n";
> $$a=$n;
> print "\$$a:$$a\n";
>}
>-----------------------------------
>that works...
>My question is : Is it possible to do the same operation without
>using that $a variable as a helper..
>I want to do this assignments(below) at one expression...
> $a="var$n";
> $$a=$n;
Well, you can do it as { no strict; ${"var$n"} = $n };
But TomC's reply quoting the FAQ explains why you shouldn't.
Mike Guy
------------------------------
Date: Wed, 1 Sep 1999 10:23:52 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Creating runtime variables.
Message-Id: <x3y906qww0y.fsf@tigre.matrox.com>
baris sertkaya <e109775@orca.cc.metu.edu.tr> writes:
> I am trying to create runtime variables like that:
> -----------------------------------
> for $n (0..2) {
> $a="var$n";
> $$a=$n;
> print "\$$a:$$a\n";
> }
> -----------------------------------
> that works...
Yes. But it is very inefficient. I also find it a bit confusing, not
to mention ugly.
> My question is : Is it possible to do the same operation without
> using that $a variable as a helper..
> I want to do this assignments(below) at one expression...
> $a="var$n";
> $$a=$n;
What I would do is use a hash of variables. The keys would be the new
variable name, and the value would be its value:
my %new_vars;
for my $n (0..2) {
$new_vars{"var$n"} = $n;
}
More tips:
If you new vars will simply be called "var" followed by some number
(as in the example above), then I suggest you use a regular array:
my @new_vars;
for my $n (0..2) {
push @new_vars => $n;
}
Like that, you can access var5 as $new_vars[5].
Also, you really should get in the habit of use()ing the strict
pragma. Just add the following line as the second line in your
programs:
use strict;
Read more about strict using perldoc:
% perldoc strict
HTH,
--Ala
------------------------------
Date: Wed, 1 Sep 1999 15:19:50 +0200
From: Laurent Cordon <Laurent.Cordon@afp.com>
Subject: directory processing
Message-Id: <936192058.1487441125@news.par.afp.com>
I would like to update a file in a directoty
--
*************************************************************
|Laurent Cordon Tel +00 1 40417739 |
| Fax +00 1 40417854 |
|Adresse : 4, Rue de la Bourse 75002 PARIS FRANCE |
|Email : Laurent.Cordon@afp.com |
|Web : http://www-ems.par.afp.com |
*************************************************************
------------------------------
Date: Wed, 01 Sep 1999 16:10:16 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: EMPLOYMENT OPPORTUNITY:Perl/Web Developer
Message-Id: <37CD33C8.336CFBB6@gmx.net>
hrdept@tucows.com wrote:
>
> #!/usr/bin/perl
#!/usr/bin/perl -w
use strict;
(Above two lines according the Magic Rules of clpm)
(This means that most of the variables below will need 'my' in front)
>
> use Employee qw(:WebProgrammer);
> use CGI;
> use DBI;
>
> $You = new Employee;
> $in = new CGI;
> $use_mod_perl = ((exists $ENV{'GATEWAY_INTERFACE'}
> and $ENV{'GATEWAY_INTERFACE'} =~ /CGI-Perl/)
> or exists $ENV{'MOD_PERL'} );
> $os = $in->param('os') || 'Linux' || 'Solaris' || 'BSD';
> $knowledge = "/usr/local/lib/required";
Some people will prefer you to use single instead of double quotes if
you're not interpolating.
> open(REQUIRED, "$knowledge");
"<$knowledge", properly (or, if you use the "open for reading by
default", $knowledge -- without quotes); and you missed the "or die"
bit.
> while (<REQUIRED>) {
> next if (/Do not understand this message/);
> ($apache, $SQL, $HTML, $Javascript) = split;
> }
> close(REQUIRED)
Scalar found where operator expected at job.pl line 20, at end of line
(Missing semicolon on previous line?)
syntax error at job.pl line 20, near ")
$knowledge "
> $knowledge = "/usr/local/lib/helpful";
> open(BENEFICIAL, "$knowledge");
See above
> $nice_to_have = <BENEFICIAL>;
> $nice_to_have =~ m/(sendmail)(MySQL)(Oracle)(DNS\/BIND)(Java)/;
Avoid LTS by using e.g. m!! or m|| (especially since you're already
using m// instead of just plain //). And use (?:....) if you're not
using the return value in list context, nor making use of $1 and
friends.
> close(BENEFICIAL);
>
> $dbh = DBI->connect('dbi:mysql:TUCOWS','you','hired') || die "can't
> connect";
> $query = "SELECT the_best FROM applicants WHERE experience like 'at
> least 1-2 year%';
Scalar found where operator expected at job.pl line 30, at end of line
(Might be a runaway multi-line "" string starting on line 28)
(Missing operator before ?)
syntax error at job.pl line 30, near "$sth = $dbh->prepare("$query"
(and lots of follow-on errors)
> $sth = $dbh->prepare("$query");
Lose those quotes; they're unnecessary here.
> $sth->execute;
> $sth->finish;
> $dbh->disconnect;
>
> if ($interested) {
> $email = 'hrdept@tucows.com';
> $fax = "416-239-8409";
> $phone !~ /good/;
> }
You didn't mention where on the planet the job is (Kazakhstan? Maldive
Islands?). And your code doesn't even compile.
Cheers,
Philip (just trying to be helpful :))
------------------------------
Date: Wed, 01 Sep 1999 09:31:40 -0400
From: Mark Conlin <Mark.Conlin@bridge.bellsouth.com>
Subject: How to see documentation on HTTP and CGI modules
Message-Id: <37CD2ABC.CF535941@bridge.bellsouth.com>
I was under the impression that I cold use pod2man on modules
and then I could view the man pages for them.
Easy enough.
Where are the modules ?
Mark
------------------------------
Date: Wed, 01 Sep 1999 15:20:36 +0300
From: Dimka <timukas@udu.ee>
Subject: Need your help.
Message-Id: <37CD1A14.40CF4295@udu.ee>
Hello!
Is there anyone who can help with one small Perl program.
I know it is easy, but for me its a mucho problem (i've just started
learning perl).
Well i need a program that will do following:
Open file (for example /etc/passwd), split values by ":", and then
output all values in a HTML table.
____________________________________
<table><tr><td>NAME</td><td>HOME
DIR</td><td>SHELL</td><td>UID</td><td>GID</td></tr>**********</table>
Instead of ******* in need to start another table row and so on to the
end.
I've done program that will write to another file , but i can't output
is to HTML file. For Perl gurus it's easy, and please dont blame me for
stupid question.
Thanks in advance:
Dimka
d.stoljarov@hansa.ee
------------------------------
Date: Wed, 01 Sep 1999 14:30:10 +0100
From: Mark <Mark@Mark.Com>
Subject: Re: Need your help.
Message-Id: <37CD2A62.F143A859@Mark.Com>
Dimka wrote:
> Hello!
>
> Is there anyone who can help with one small Perl program.
> I know it is easy, but for me its a mucho problem (i've just started
> learning perl).
>
> Well i need a program that will do following:
>
> Open file (for example /etc/passwd), split values by ":", and then
> output all values in a HTML table.
> ____________________________________
This is a CGI script that does what you want:
use CGI;
my $q = new CGI;
$q->print ($q->header);
$q->print ($q->start_html (-title=>"Password File"));
if (not open (PASSWD,"/etc/passwd"))
{
$q->print($q->h3("Failed to open /etc/passwd $!"));
}
else
{
undef @tableRows;
while (<PASSWD>)
{
push @tableRows,$q->td([split(':')]);
}
$q->print($q->table($q->Tr([@tableRows])));
}
If you want to o/p t a file, just replace the $q->print appropriately
Mark
------------------------------
Date: 1 Sep 1999 09:21:33 -0500
From: "a" <c@d.e>
Subject: Newbie question about Perl executable
Message-Id: <01bef47c$60ecb440$8a2116ac@FH2750.compuware.com>
I am doing some programming which involves string manipulation.
Right now I am using C to do it.
Right now the software calls the C procedures for some
formatting of the fields. The C procedures are in the form of
a Dll.
I would like to know if I can use Perl instead of C.
BTW it is not a web program.
The question is :
Can I execute a Perl executable from a m/c that does not
have a Perl interpretor.
Thanks for any reply.....
------------------------------
Date: Wed, 01 Sep 1999 13:58:49 GMT
From: dominicj@my-deja.com
Subject: Re: Perl/ HTML form mail attachments
Message-Id: <7qjbej$ijl$1@nnrp1.deja.com>
Saiid
You mentioned a number of Perl modules to carry out this work for you.
Do you have any names.
I am looking to attach Binaries
Many thanks
Dominic
In article <37BB1E97.3BD68FB4@news.com>,
news <news@news.com> wrote:
> If you offer users the opportunity to attach documents when using an
> HTML form, e.g.
> using something like:
>
> <INPUT TYPE="File" NAME="attachment" VALUE="">
>
> How do you then attach the file in the perl script that calls
sendmail?
> The example below
> will just send the path and name of the file that was attached and not
> the file itself.
>
> ....
> open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
> print MAIL "To: $recipient\n";
> print MAIL "From: $user\n";
> print MAIL "Subject: Subject\n\n";
> print MAIL "Reply-to: $user\n";
> print MAIL
> "------------------------------------------------------------\n";
> print MAIL "$FORM{'first_name'} $FORM{'last_name'} sent the
> following\n";
> print MAIL "Phone: $FORM{'phone'}\n";
> print MAIL "Email: $FORM{'email'}\n";
> print MAIL "Attachment: $FORM{'attachment'}";
> close (MAIL);
>
> Any help would be much appreciated.
> Thanks.
> Saiid.
> saiid@excite.com
>
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 01 Sep 1999 14:04:28 GMT
From: dominicj@my-deja.com
Subject: Re: Perl/ HTML form mail attachments
Message-Id: <7qjbp4$iui$1@nnrp1.deja.com>
Saiid
You mentioned a number of Perl modules to carry out this work for you.
Do you have any names.
I am looking to attach Binaries
Many thanks
Dominic
In article <37BB1E97.3BD68FB4@news.com>,
news <news@news.com> wrote:
> If you offer users the opportunity to attach documents when using an
> HTML form, e.g.
> using something like:
>
> <INPUT TYPE="File" NAME="attachment" VALUE="">
>
> How do you then attach the file in the perl script that calls
sendmail?
> The example below
> will just send the path and name of the file that was attached and not
> the file itself.
>
> ....
> open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
> print MAIL "To: $recipient\n";
> print MAIL "From: $user\n";
> print MAIL "Subject: Subject\n\n";
> print MAIL "Reply-to: $user\n";
> print MAIL
> "------------------------------------------------------------\n";
> print MAIL "$FORM{'first_name'} $FORM{'last_name'} sent the
> following\n";
> print MAIL "Phone: $FORM{'phone'}\n";
> print MAIL "Email: $FORM{'email'}\n";
> print MAIL "Attachment: $FORM{'attachment'}";
> close (MAIL);
>
> Any help would be much appreciated.
> Thanks.
> Saiid.
> saiid@excite.com
>
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 1 Sep 1999 16:13:06 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl/ HTML form mail attachments
Message-Id: <37cd4282_1@newsread3.dircon.co.uk>
dominicj@my-deja.com wrote:
> Saiid
>
> You mentioned a number of Perl modules to carry out this work for you.
>
> Do you have any names.
>
> I am looking to attach Binaries
>
> Many thanks
>
The module MIME::Lite
/J\
--
"I managed to take her completely by surprise" - Prince Edward
------------------------------
Date: Wed, 01 Sep 1999 15:44:44 GMT
From: agutier@my-deja.com
Subject: PPT I have a diff XSUB
Message-Id: <7qjhl8$noj$1@nnrp1.deja.com>
I have an XSUB that is based off of GNU diff. It works very well. It
runs under Linux and Windows NT. What do I do now? How do I submit it
to PPT?
Alan Gutierrez
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 01 Sep 1999 17:16:06 +0200
From: Christoph Bauer <bauer@zrz.tu-berlin.de>
To: Mark <tox911@hotmail.com>
Subject: Re: Printing problems NT and PERL
Message-Id: <37CD4336.46B43544@zrz.tu-berlin.de>
Hi,
Mark wrote:
>
> Anyone have any information about printing to NT printers? We are having a
> problem.
>
> print /d:\\server\printer test.txt works from the command line, and when
> sent as a system command works from perl, but only AFTER the same command
> has been sent from the command line. Log off, and it's back to not working
> again. There has got to be a better way.
Not sure, but maybe it's some weird eof problem.
i had problems, where an additional cr lf helped.
HTH
Christoph
------------------------------
Date: Wed, 01 Sep 1999 14:35:08 GMT
From: erik_lembke@my-deja.com
Subject: Q: regex: bug in subsituyr??
Message-Id: <7qjdir$kcj$1@nnrp1.deja.com>
Hi folks,
i had following line in my code:
$line =~ s/^(.{80})(.+)/$2/;
this line should delete the first 80 caracters from a line.
Problem: It worked sometimes. (not everytime)
I added following line after the substitute statement:
$line = $2;
and everything worked fine.
($line becomes the rest of $line)
Q: Where is the Problem/fault/bug ??
cheers Erik
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 1 Sep 1999 15:04:02 GMT
From: Colin R. DeVilbiss <crdevilb@mtu.edu>
Subject: Re: Q: regex: bug in subsituyr??
Message-Id: <7qjf92$n0g$1@campus1.mtu.edu>
erik_lembke@my-deja.com wrote:
> $line =~ s/^(.{80})(.+)/$2/;
> this line should delete the first 80 caracters from a line.
> Problem: It worked sometimes. (not everytime)
IF the line is at least 81 characters long. If the match fails (because
there are fewer than 81 characters--80 for the first part, at least
1 for the second), the substitution fails also.
perhaps the simpler
substr($line, 0, 80) = ''
is what you wanted.
> I added following line after the substitute statement:
> $line = $2;
the reason this works is because the attempted match clears $2, IIRC.
ciao,
Colin DeVilbiss
------------------------------
Date: Wed, 01 Sep 1999 13:20:29 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Redirecting STDERR to STDOUT (on NT)
Message-Id: <37cd25a3.339820@news.skynet.be>
Paulius wrote:
>how can I redirect STDERR to STDOUT so die "string" would work
>correctly?
>
>Is it possible at all?
Two easy ways:
a) redirecting STDERR:
open STDERR, '>&STDOUT';
b) setting a $SIG{__DIE__} and/or $SIG{__WARN__} handler, which may
format the output in whatever way it likes. Do this in a BEGIN block if
you want to see compile time errors in the same way.
#! perl -w
BEGIN {
$SIG{__WARN__} = sub { print STDOUT "Oops: @_"; };
$SIG{__DIE__} = sub {
print STDOUT "Argh!: @_"."I'm dead."; die "\n" };
}
print $x/$y;
print "Heh.\n"; # you won't see this.
I'm not quite happy about that { die "\n" } hack, though (die
"silently").
--
Bart.
------------------------------
Date: Wed, 1 Sep 1999 07:24:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Redirecting STDERR to STDOUT (on NT)
Message-Id: <MPG.1236d6e3441fc5fb989f01@nntp.hpl.hp.com>
In article <37cd25a3.339820@news.skynet.be> on Wed, 01 Sep 1999 13:20:29
GMT, Bart Lateur <bart.lateur@skynet.be> says...
....
> #! perl -w
> BEGIN {
> $SIG{__WARN__} = sub { print STDOUT "Oops: @_"; };
> $SIG{__DIE__} = sub {
> print STDOUT "Argh!: @_"."I'm dead."; die "\n" };
> }
> print $x/$y;
> print "Heh.\n"; # you won't see this.
>
> I'm not quite happy about that { die "\n" } hack, though (die
> "silently").
How about this clever replacement for your 'die "\n"':
exit;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 01 Sep 1999 15:13:26 GMT
From: Stone Cold <paulm@dirigo.com>
Subject: Re: Simulating Carriage Returns
Message-Id: <7qjfq9$m8k$1@nnrp1.deja.com>
Um, thanks for the info (I think). I was using the localtime() module
but when I print the output to a file, it wouldn't put zero's in front
of the month or day if the string was 1. For example, if the current
date was 1999-9-1, it would print the date as 1999-9-1. I need it in
the form of 1999-09-01, therefore if the length of the month and/or day
is 1 digit, then it needs to add a zero. Make sense?
I guess I could manipulate the localtime output, but wasn't familiar
with the length function. I need to write an if statement?
I'm such a novice, sorry for being such an idiot (sarcastically I say).
:-#
In article <MPG.1236408d494ff4559896e3@nntp1.ba.best.com>,
moseley@best.com (Bill Moseley) wrote:
> Stone Cold (paulm@dirigo.com) seems to say...
> > Is there a way to simulate a carriage return in perl when calling an
> > external DOS command.
>
> Yes, but that's not your problem. (But, you can pipe open a program
and
> feed it whatever you like).
>
> > For example, I'm pulling the system date from my
> > machine by doing the following:
> >
> > $now=`date`;
> > ($junk1,$junk2,$junk3,$junk4,$current) = split(/\s+/,$now);
> > print $current;
> > exit 0;
>
> Oh. If you want the date use the built-in localtime(); perlfaq4 has
a
> bunch of stuff on dates.
>
> > Because it gives other info as well, I'm splitting on the other
> > stuff to not see it.
>
> In general, try this:
> > ($current) = (split(/\s+/,$now))[4];
>
> > Does anyone know what I can do to correct this?
>
> Yes, use another method to get your dates.
>
> --
> Bill Moseley mailto:moseley@best.com
> pls note the one line sig, not counting this one.
>
--
Paul R. Mesker
System Engineer
Dirigo Inc.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 01 Sep 1999 15:16:41 GMT
From: Stone Cold <paulm@dirigo.com>
Subject: Re: Simulating Carriage Returns
Message-Id: <7qjg0b$mc7$1@nnrp1.deja.com>
I could use the localtime mod, but it doesn't print out zeros in front
of the months and/or days that are only 1 digit (e.g. 1999-9-1 --->
need this to be 1999-09-01).
Any experience with the length statement? Need to write an if
statement that will print out "01" if month/day is 1 digit.
In article <37CCDE7E.D0FBDD19@synersoft.fr>,
Roman Stawski <roman.stawski@synersoft.fr> wrote:
> Stone Cold wrote:
> >
> > Is there a way to simulate a carriage return in perl when calling an
> > external DOS command. For example, I'm pulling the system date from
my
> > machine by doing the following:
> >
> > $now=`date`;
> > ($junk1,$junk2,$junk3,$junk4,$current) = split(/\s+/,$now);
> > print $current;
> > exit 0;
> >
> > This will run the date shell command and give me back the current
> > date. Because it gives other info as well, I'm splitting on the
other
> > stuff to not see it.
> >
> > What happens is that when I run the script externally
> > (C:/Perl/.../...test.pl), it just hangs there. I think it has
> > something to do with there NOT being a carriage return after the
`date`
> > command because if I print $now, it doesn't even give me the date.
> > --
>
> Your script hangs when `Date` prompts you for a new date. Are you
> obliged
> to use the DOS date? or can you get away with just
>
> print scalar localtime() ;
>
> ?
> --
> :-{)}
>
--
Paul R. Mesker
System Engineer
Dirigo Inc.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 01 Sep 1999 10:40:00 -0500
From: Art Haas <cs004@wg.waii.com>
Subject: Re: Simulating Carriage Returns
Message-Id: <37CD48D0.3C0BEB4@wg.waii.com>
Stone Cold wrote:
>
> I could use the localtime mod, but it doesn't print out zeros in front
> of the months and/or days that are only 1 digit (e.g. 1999-9-1 --->
> need this to be 1999-09-01).
>
> Any experience with the length statement? Need to write an if
> statement that will print out "01" if month/day is 1 digit.
>
Length, schmength. You want sprintf ...
#!/usr/local/bin/perl
use strict;
my ($day, $mon, $year) = (localtime(time)) [3..5];
$year += 1900;
$mon += 1;
#
# both formats print the same ...
#
print sprintf "%d-%.2d-%.2d\n", $year, $mon, $day;
print sprintf "%d-%02d-%02d\n", $year, $mon, $day;
Running this produces ...
1999-09-01
1999-09-01
Now give me a hell yeah ...
--
###############################
# Art Haas
# (713) 689-2417
###############################
------------------------------
Date: 1 Sep 1999 16:50:00 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Simulating Carriage Returns
Message-Id: <37cd4b28_1@newsread3.dircon.co.uk>
Stone Cold <paulm@dirigo.com> wrote:
> In article <MPG.1236408d494ff4559896e3@nntp1.ba.best.com>,
> moseley@best.com (Bill Moseley) wrote:
>> Stone Cold (paulm@dirigo.com) seems to say...
>> > Is there a way to simulate a carriage return in perl when calling an
>> > external DOS command.
>>
>> Yes, but that's not your problem. (But, you can pipe open a program
> and
>> feed it whatever you like).
>>
>> > For example, I'm pulling the system date from my
>> > machine by doing the following:
>> >
>> > $now=`date`;
>> > ($junk1,$junk2,$junk3,$junk4,$current) = split(/\s+/,$now);
>> > print $current;
>> > exit 0;
>>
>> Oh. If you want the date use the built-in localtime(); perlfaq4 has
> a
>> bunch of stuff on dates.
>>
>> > Because it gives other info as well, I'm splitting on the other
>> > stuff to not see it.
>>
>> In general, try this:
>> > ($current) = (split(/\s+/,$now))[4];
>>
>> > Does anyone know what I can do to correct this?
>>
>> Yes, use another method to get your dates.
>>
> Um, thanks for the info (I think). I was using the localtime() module
> but when I print the output to a file, it wouldn't put zero's in front
> of the month or day if the string was 1. For example, if the current
> date was 1999-9-1, it would print the date as 1999-9-1. I need it in
> the form of 1999-09-01, therefore if the length of the month and/or day
> is 1 digit, then it needs to add a zero. Make sense?
>
> I guess I could manipulate the localtime output, but wasn't familiar
> with the length function. I need to write an if statement?
>
Why would you want to use the length function. Usually one would do
something like:
($day,$month,$year) = (localtime)[3,4,5];
$date = sprintf("%d-%.02d-%.02d", $year + 1900, $month + 1, $day);
print $date,"\n";
Please the perlfunc manpage entries for localtime and sprintf .
/J\
--
"The most frightening thing on television since Anthea Turner revealed
she had a sister" - Suggs
------------------------------
Date: Wed, 01 Sep 1999 14:11:00 +0100
From: Mark <Mark@Mark.Com>
Subject: Re: subtraction error
Message-Id: <37CD25E4.7908536D@Mark.Com>
Larry Rosler wrote:
<Snip>
> The only way it can help is by papering over a fundamentally flawed
> approach -- dealing with dollars and cents as floating-point numbers in
> dollar units, instead of as integers in cent units.
>
> It should be ingrained into all programmers not to do this in financial
> calculations! This is a basic issue of professional competence.
Hear, Hear!
I have spend a number of months working on a billing system developed by a
'reputable' software house that represents
currency as floating points. Jeez, the trouble we had trying to sort it out.
The only solution was to reengineer the whole thing,
code, database tables, etc, etc. Ignorance of basic maths, I'd say.
Programming 1.0.1!
>
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
------------------------------
Date: Wed, 01 Sep 1999 16:43:16 +0100
From: cb <ecliptica.ww@nospam.virgin.net>
Subject: Tracking progress of a Net::FTP download
Message-Id: <37CD4994.49691ADB@nospam.virgin.net>
Hi folks ...
I'm working on a Perl program which automates a regular download of
files using Net::FTP with Perl 5.005 and FreeBSD 3.2 UNIX on a P2/300.
It works fine, but, as it is, the best ways I can come up with of
telling whether the download is proceeding normally are (1) watch the
Hard Drive light to see whether stuff is being written to disk, or (2)
open another TTY console and issue "ls -l [filename]" commands to see
(hopefully) the number of bytes increasing.
I reckon there must be some easy-ish way of automating method (2) above
with a child process (invoked by the FTP program as parent(?))
extracting the number of bytes retrieved (i.e. the current length of the
local file) and at the least just echoing them to the console.
The trouble is I'm fairly new to the language, and the sections of the
Perl Cookbook which may well deal with how to do this sort of thing seem
a tad opaque to say the least.
Does anyone know of a website which might offer an "idiots guide" to
addressing this kind of task? Any pointers or helpful advice would be
most gratefully received.
With thanks in advance
Cheers ... CB ....
------------------------------
Date: Wed, 1 Sep 1999 06:07:12 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: using ppm with proxy servers
Message-Id: <MPG.1236c4d198e21528989f00@nntp.hpl.hp.com>
In article <7qip19$rjg$1@lure.pipex.net> on Wed, 1 Sep 1999 09:42:09
+0100, jon <me@my.com> says...
> Does anyone know how to configure ppm to use a proxy server when accessing
> websites with perl packages ?
The documentation knows!
ActivePerl Components:Using PPM:PPM, Proxies and Firewalls
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 1 Sep 1999 15:21:35 +0200
From: "Ysteric's" <eyounes@aol.com>
Subject: Re: What is DBI?
Message-Id: <7qj945$h0t@news.vtcom.fr>
DBI is the abstract level for databases acces, and, DBD the real DB driver.
You'll need DBI + DBD::ODBC to make your script work
and, one day, if you change your DataBase, you'll just have to change your
DBD driver.
here is a sample, make a selection :
# --- Start
#!c:/perl/bin/perl.exe
# Shebang pour windows...
use CGI;
use DBI;
$query = new CGI;
print "Content-type: text/html\n\n";
print qq{
<head>
<title>Recherche emplyé</title>
</head>
<body>
<center>
};
@val = $query->param('num_ss');
$no_secu = $val[0];
@val = $query->param('jj');
$jj = $val[0];
@val = $query->param('mm');
$mm = $val[0];
@val = $query->param('aa');
$aa = $val[0];
@val = $query->param('cp');
$cp = $val[0];
#$date = $jj . '/' . $mm . '/' . $aa;
$date = $aa . $mm . $jj;
print "connexion ...";
$dbh = DBI->connect('dbi:ODBC:Secu') || die('$DBI::errstr');
###### i use the DBD::ODBC driver, and
my DSN is 'Secu'
print "...connexion OK";
$sth = $dbh->prepare(qq{select
NOSS,NAISSANCE,EMPLOI,NOM,PRENOM,NUMERO,ADRESSE1,COMMUNE,CODEPOSTAL from
testrg
where NOSS = '$no_secu' and CODEPOSTAL='$cp' and NAISSANCE='$date'});
$sth->execute || die('$DBI::errstr');
$cnt = 0;
print qq{<font face="Arial,Helvetica" width=600><table>
};
$no_secu =~ s/ /+/g;
if( @rows = $sth->fetchrow_array) {
print
<table width="400" border=0 bgcolor="#000000">
<th><font face="Arial, Helvetica" color="#FFFFFF"
size="5"><center><b>Fiche employé<br> </b></center></font>
<A HREF="modify.pl?noss=$no_secu"><IMG SRC="modif.gif"
alt="modidier cette fiche"></a>
<A HREF="delete.pl?noss=$no_secu"><IMG SRC="delete.gif"
alt="modidier cette fiche"></a>
</th>
</table>
<table width="400" border="0" CELLPADDING=3>
<tr>
<td bgcolor="#000000"><font face="Arial, Helvetica, sans-serif"
color="#FFFFFF"><b>N° Sécurité
sociale :</b></font></td>
<td bgcolor="#F0F0F0"> $rows[0]</td>
</tr>
<tr>
<td bgcolor="#000000"><font face="Arial, Helvetica, sans-serif"
color="#FFFFFF"><b>Date de naissance :</b></font></td>
<td bgcolor="#F0F0F0"> $rows[1]</td>
</tr>
<tr>
<td bgcolor="#000000"><font face="Arial, Helvetica, sans-serif"
color="#FFFFFF"><b>Emploi :</b></font></td>
<td bgcolor="#F0F0F0"> $rows[2]</td>
</tr>
<tr>
<td bgcolor="#000000"><font face="Arial, Helvetica, sans-serif"
color="#FFFFFF"><b>Nom :</b></font></td>
<td bgcolor="#F0F0F0"> $rows[3]</td>
</tr>
<tr>
<td bgcolor="#000000"><font face="Arial, Helvetica, sans-serif"
color="#FFFFFF"><b>Prénom :</b></font></td>
<td bgcolor="#F0F0F0"> $rows[4]</td>
</tr>
<tr>
<td bgcolor="#000000"><font face="Arial, Helvetica, sans-serif"
color="#FFFFFF"><b>Adresse :</b></font></td>
<td bgcolor="#F0F0F0"> $rows[5], $rows[6]</td>
</tr>
<tr>
<td bgcolor="#000000"><font face="Arial, Helvetica, sans-serif"
color="#FFFFFF"><b>Ville :</b></font></td>
<td bgcolor="#F0F0F0"> $rows[7]</td>
</tr>
<tr>
<td bgcolor="#000000"><font face="Arial, Helvetica, sans-serif"
color="#FFFFFF"><b>Code Postal :</b></font></td>
<td bgcolor="#F0F0F0"> $rows[8]</td>
</tr>
</table>
};
} else {
print qq{
<table width="400" border=0 bgcolor="#000000">
<th><font face="Arial, Helvetica" color="#FFFFFF"
size="5"><center><b>Fiche employ&eatute;<br> </b></center></font></th>
<tr>
<td><hr><font face="Arial, Helvetica, sans-serif"
color="#FFFFFF"><b>Désolé aucune fiche ne correspond a vos
critès </b></font><hr></td>
</tr>
</table>
};
}
$sth->finish;
$dbh->disconnect;
print qq{
</font>
</center>
</form>
</body>
</html>
};
# ---- End
Good luck
Eric - FRANCE
------------------------------
Date: Wed, 01 Sep 1999 16:19:25 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: What is DBI?
Message-Id: <37CD35ED.F0722734@gmx.net>
Ysteric's wrote:
>
> $dbh = DBI->connect('dbi:ODBC:Secu') || die('$DBI::errstr');
'$DBI::errstr' is very unlikely to be interesting. Perhaps you want
double quotes? (Or leave them off entirely, if that's all you're
printing.)
(And I personally dislike people foisting their choice of font on me,
*especially* if it's Arial or Helvetica, since that shows up much too
small with my settings -- but that's another rant for another group.)
Cheers,
Philip
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
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 695
*************************************