[7976] in Perl-Users-Digest
Perl-Users Digest, Issue: 1601 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 8 12:07:47 1998
Date: Thu, 8 Jan 98 09:00:30 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 8 Jan 1998 Volume: 8 Number: 1601
Today's topics:
Re: [Help] Capturing STDOUT under DOS ? <jack_h_ostroff@groton.pfizer.com>
Re: Blank rows, Data is missing. abrown@demon.net
Re: CgiWrap - perl: can't map file error <rootbeer@teleport.com>
Embedding Perl Win32 in C/C++ <cbaffour@thomtech.com>
File Format Query (tchorzewska)
Re: File Format Query <moc.care@hcajp>
Re: File Format Query (brian d foy)
Re: File Format Query <moc.care@hcajp>
Re: File Format Query <cmargoli@world.northgrum.com>
Re: file glob restrictions?! <tchrist@mox.perl.com>
Re: Good place to start in Perl 5 <tchrist@mox.perl.com>
Re: Good place to start in Perl 5 <tchrist@mox.perl.com>
Re: Hash Slice Syntax Question <rootbeer@teleport.com>
Re: Help with a sort (Greg Bacon)
Re: Help with passing parameters in URL's please <vfox@nbnet.nb.ca>
Re: how does 'require' work? (Greg Bacon)
Re: I tired to modify.... <defaultuser@domain.com>
Perl CGI - Apache 1.2 <rcapenegro@brookdale.cc.nj.us>
Re: Perl CGI - Apache 1.2 (brian d foy)
Please Help - Simple global counter using a file <mattdb@syntrillium.com>
print SOCK "Whatever"; <TobiasBugala@swol.de>
Re: problem executing getting output <rootbeer@teleport.com>
Re: range operator with decimal numbers <rootbeer@teleport.com>
Re: regex to escape {, } except in TeX commands (Bart Lateur)
Re: Running a perl script in the background on Windows <deflores@bigfoot.com>
Re: Running a perl script in the background on Windows <rootbeer@teleport.com>
running a program from PERL and capturing the output <craigg@servtech.com>
Re: running a program from PERL and capturing the outpu (brian d foy)
Search/sorting question <kevin@wx3.com>
Re: serious post about gmtime and year-1900 (was Re: Pe (Chip Salzenberg)
Re: serious post about gmtime and year-1900 (was Re: Pe <rootbeer@teleport.com>
Re: Testing for valid RegExps? (Greg Bacon)
Re: Unix perl shell ??? (Ed Avis)
Re: username:password crypt module (Greg Bacon)
Re: username:password crypt module <rootbeer@teleport.com>
what's wrong? can't match a range of number <feng@haas.berkeley.edu>
Re: what's wrong? can't match a range of number <tycage@infi.net>
Re: what's wrong? can't match a range of number <reibert@mystech.com>
Re: what's wrong? can't match a range of number <clark@s3i.com>
win32 drive letters (Alastair Rae)
Re: win32 drive letters <moc.care@hcajp>
Re: win32 drive letters <deflores@bigfoot.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 08 Jan 1998 09:08:35 -0500
From: "Jack H. Ostroff" <jack_h_ostroff@groton.pfizer.com>
Subject: Re: [Help] Capturing STDOUT under DOS ?
Message-Id: <34B4DDE3.12F5@groton.pfizer.com>
Augusto Cardoso wrote:
>
> What can I do to capture the output of Perl programs to a disk file
> insted of screen ? I tried all "redirection" and other "piping" I
> could think of, no results!
> Ex.
> POD2TEXT C:\PERL\README.POD
>
> ... I would like to catch the output for later printing ...
> Thanks for suggestions.
Doesn't
POD2TEXT C:\PERL\README.POD > savefile.txt
work?
------------------------------
Date: Thu, 08 Jan 1998 09:11:35 -0600
From: abrown@demon.net
Subject: Re: Blank rows, Data is missing.
Message-Id: <884271695.357171205@dejanews.com>
In article <34B428E0.E0A4D9E5@mayers.de>,
Christian Roth <cr@mayers.de> wrote:
>
> Hi!
>
> I got a little bit further.
> Now I am able to read out of my database! BUT all
> I get out of it are blank rows. I inserted a $count to count my rows.
> The number at the end is correct and matches the number of records in
> the database. But my table is filled with blank rows. NO DATA? WHERE IS
> THE DATA?
>
> Thanks for all of your help
>
> Christian
>
> Here my code:
>
>
> $count = 0;
You neen to add the folowing lines to your code to store the data in the
hash %data
>
> while ($db->fetchrow) {
undef %data;
%data = $db->DataHash();
You are also going to need to change the way you store the data as
follows.
> $company = $data{COMPANY};
> $postaddr = $data{POSTADDR};
> $locality = $data{LOCALITY};
> $town = $data{TOWN};
> $phone = $data{PHONE};
> $fax = $data{FAX};
> $mobile = $data{MOBILE};
> $title = $data{TITLE};
> $name = $data{NAME};
> $fname = $data{FIRST NANE};
> $heracode = $data{HERACODE};
>
Anthony
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 8 Jan 1998 07:02:05 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Piotr Klaban <makler@man.torun.pl>
Subject: Re: CgiWrap - perl: can't map file error
Message-Id: <Pine.GSO.3.96.980108065733.26818D-100000@user2.teleport.com>
On Thu, 8 Jan 1998, Piotr Klaban wrote:
> > http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
> The above URL has nothing to do with my problem.
> The problem is in the cgiwrap program configuration. There is an option
> limiting the virtual memory. I have found the answer in the CGIWRAP
> listserv group logs, yesterday. The solution is:
> not limit the virtual memory, because the limit is too low for
> loading the perl program into the memory. LD stops loading libraries
> during the execution of the perl script.
> De facto the problem is not a perl problem, but many users could
> find that problem only when they are running the perl CGI script
> from cgiwrap. That is why I think it is good to send current
> article also to the perl newsgroup.
Fair enough. But could you also send this information to someone who can
add it to the "Idiot's Guide"? That would make it even more helpful in the
future. There should be a contact address on that web page. Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 08 Jan 1998 16:12:13 +0000
From: Cecil Baffour <cbaffour@thomtech.com>
Subject: Embedding Perl Win32 in C/C++
Message-Id: <34B4FADC.C7DD8BC9@thomtech.com>
Has anyone ever embedded Perl in c/c++ i.e. invoved the perl interpreter
directly by calling perl_parse() , perl_run() etc
Basically I need to know if it is possible to do this under Win32 and if
so how would I go about doing it, do the instructions in perlembed
apply?
Thanks
Cecil.
------------------------------
Date: 8 Jan 1998 14:09:45 GMT
From: mtchorze@srd.bt.co.uk (tchorzewska)
Subject: File Format Query
Message-Id: <692mn9$nth$1@pheidippides.axion.bt.co.uk>
Is it possible to write from perl to a file in .xls format, so that it can be
picked up by an Excel spreadsheet? (Would this involve writing.csv file
first?)
TIA
Maria
------------------------------
Date: Thu, 8 Jan 1998 10:20:16 -0600
From: "Phil Jach" <moc.care@hcajp>
Subject: Re: File Format Query
Message-Id: <34b4fcb5.0@news1.ibm.net>
Yes, you can use Perl for Win32 to achieve this. Using API calls from
within Perl you can write information directly to an Excel worksheet. Check
out the information on Perl Win32 and you'll get the information on using
the API calls. Hope this helps.
tchorzewska wrote in message <692mn9$nth$1@pheidippides.axion.bt.co.uk>...
>Is it possible to write from perl to a file in .xls format, so that it can
be
>picked up by an Excel spreadsheet? (Would this involve writing.csv file
>first?)
>
>TIA
>
>Maria
>
------------------------------
Date: Thu, 08 Jan 1998 11:27:01 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: File Format Query
Message-Id: <comdog-0801981127010001@news.panix.com>
Keywords: just another new york perl hacker
In article <692mn9$nth$1@pheidippides.axion.bt.co.uk>, mtchorze@srd.bt.co.uk (tchorzewska) posted:
> Is it possible to write from perl to a file in .xls format, so that it can be
> picked up by an Excel spreadsheet? (Would this involve writing.csv file
> first?)
you can write any data in any format that you wish - Perl doesn't
care. you just have to know how to write the format.
since excel can read many formats, you might want to choose the one
that's easiest for you to code.
good luck :)
--
brian d foy <http://computerdog.com>
------------------------------
Date: Thu, 8 Jan 1998 10:25:00 -0600
From: "Phil Jach" <moc.care@hcajp>
Subject: Re: File Format Query
Message-Id: <34b4fdde.0@news1.ibm.net>
BTW, you will be using the Win32 OLE automation portion of the Perl Win32.
The documentation for this comes with Perl Win32 called OLEAUTO.HTML
Phil Jach wrote in message <34b4fcb5.0@news1.ibm.net>...
>Yes, you can use Perl for Win32 to achieve this. Using API calls from
>within Perl you can write information directly to an Excel worksheet.
Check
>out the information on Perl Win32 and you'll get the information on using
>the API calls. Hope this helps.
>
>tchorzewska wrote in message <692mn9$nth$1@pheidippides.axion.bt.co.uk>...
>>Is it possible to write from perl to a file in .xls format, so that it can
>be
>>picked up by an Excel spreadsheet? (Would this involve writing.csv file
>>first?)
>>
>>TIA
>>
>>Maria
>>
>
>
------------------------------
Date: Thu, 8 Jan 1998 16:31:40 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: File Format Query
Message-Id: <34B4FF6C.5812@world.northgrum.com>
tchorzewska wrote:
>
> Is it possible to write from perl to a file in .xls format, so that it can be
> picked up by an Excel spreadsheet? (Would this involve writing.csv file
> first?)
>
Yes, you can write a .csv file and then open that in Excel.
A good way to build .csv file records is to use the Text::CSV module
available on CPAN.
--
Charles G. Margolin DSSD Internal Information Services
cmargoli@world.northgrum.com Northrop Grumman Corp. 0624/23
margolin@acm.org Hawthorne, California 90250-3277
------------------------------
Date: 8 Jan 1998 14:04:12 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: file glob restrictions?!
Message-Id: <692mcs$1up$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, joseph@5sigma.com writes:
:We should emphasize that: readdir is like, WAY faster.
Critically so? I don't agree. And most of its users screw it up
anyway, which means if it's wrong, it doesn't matter how fast it is.
These are similar:
@files = glob("/etc/*.*");
versus
opendir(DIR, "/etc") || die "opendir /etc: $!";
@files = map { "/etc/$_" }
sort
grep { !/^\.\.?$/ && /\./ }
readdir(DIR);
closedir(DIR);
The first is obviously superior for its simplicity. It's really a shame
that it has difficulty in some situations. Just because the current
version of glob has problems doesn't mean that it should be removed.
It should be fixed. And on systems with tcsh installed, it has no
such problem.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
> (It's sorta like sed, but not. It's sorta like awk, but not. etc.)
Guilty as charged. Perl is happily ugly, and happily derivative.
--Larry Wall in <1992Aug26.184221.29627@netlabs.com>
------------------------------
Date: 8 Jan 1998 14:21:56 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Good place to start in Perl 5
Message-Id: <692ne4$3ok$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
gendress@symbios.com writes:
:I'm really interested in learning Perl 5 so I can begin writing my own
:CGI scripts. I was wondering if any of you had a recommendation of any
:good beginners books for me start with?
Semi-Beginning Programmers:
Learning Perl
Learning Perl for Win32
Cross-platform Perl
Serious Programmers:
Perl: The Programmer's Companion
Programming Perl
Advanced Perl Programming
Other Good Stuff:
Mastering Regular Expressions
How to Setup and Maintain Your Website
CGI Programming in C and Perl
HTML: The Definitive Reference
Web Client Programming in Perl
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
If you have ever seen the grim word "login:" on a screen, your mind
is now a wholly-owned subsidiary of The Death Star.
John Woods in <14105@ksr.com> of comp.unix.bsd
------------------------------
Date: 8 Jan 1998 15:57:17 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Good place to start in Perl 5
Message-Id: <692t0t$abi$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, lynchqvctc@aol.com (Lynchqvctc) writes:
:A little out of the "pack" of Camels and O'Reilleys etc., I would recommend
:(highly) Erik Strom's Perl CGI Programming: No Experience Required, by "Sybex."
That book has serious technical flaws throughout.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
: And it goes against the grain of building small tools.
Innocent, Your Honor. Perl users build small tools all day long.
--Larry Wall in <1992Aug26.184221.29627@netlabs.com>
------------------------------
Date: Thu, 8 Jan 1998 07:34:56 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: James Garrison <jhg@austx.tandem.com>
Subject: Re: Hash Slice Syntax Question
Message-Id: <Pine.GSO.3.96.980108072832.26818J-100000@user2.teleport.com>
On Wed, 7 Jan 1998, James Garrison wrote:
> print @$b->{Two,Three};
The arrow notation is a shortcut which can be used to access an individual
element of an array or hash, but not a slice. (The arrow may be used for
other purposes as well.) For slices (or entire hashes or arrays) you may
use the more cumbersome brace notation.
@{$b}{qw/Two Three/} # elements 'Two' and 'Three' from %$b
Of course, when the item inside the braces is a simple scalar variable
(and not an element of an array or hash) you may omit the braces.
@$b{qw/Two Three/} # same as above
Does this give you any of the missing pieces? Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 8 Jan 1998 15:24:36 GMT
From: gbacon@adtran.com (Greg Bacon)
To: mcfadyj@gov.on.ca (Jeff McFadyen)
Subject: Re: Help with a sort
Message-Id: <692r3k$fcc$2@info.uah.edu>
[Posted and mailed]
In article <690kni$rr1$1@news.gov.on.ca>,
mcfadyj@gov.on.ca (Jeff McFadyen) writes:
: I want to read in a data file, split the input into an array, sort the array
: and then printout a sorted - non-duplicated list. The code that I have been
: playing with will print out what I want an array field at
: a time but I can't get it to print an entire record.
Searching dejanews can often be helpful for problems like this.
: open(SORTIN,"c:\\ems\\sort\\subject.rpt");
You should check that return value.
: while (<SORTIN>) {
:
: chop();
chomp() is safer.
: $line=$_; #read in a line of data
No, you're copying a line you've already read in. You're not using $_
elsewhere within the loop body, so there's no point in lugging around
an extra copy.
: @linein=$line;
Not sure why you're doing this...
: @fields=split/\|/,$line; #split input line into array
:
: $fields[99]=$line;
: $lineout=$fields[99];
...or this.
: $emsno=$fields[0]; $omsno=$fields[1]; #define input fields
:
: $foo{$emsno}=$omsno; #define relationship based on ln
: $foo{$dataline}=$lineout;
: }
Why not just
$foo{$dataline} = $line;
since $lineout eq $fields[99] eq $line? Where is $dataline getting its
value anyway?
>From what I can eek out from your code, it seems that you want just a
simple sort on the zeroth field with no duplicate records.
You could do it in Perl with
#! /usr/bin/perl -w
my $infile = 'c:/ems/sort/subject.rpt';
open SORTIN, $infile or die "Failed open $infile: $!\n";
my %ems = ();
while (<SORTIN>) {
chomp;
$ems{(split /\|/)[0]} = $_;
## or use a regex; don't know if this is more efficient
# $ems{$1} = $_ if /^([^|]+)\|/;
}
my %seen = ();
for (sort keys %ems) {
print "$ems{$_}\n" unless $seen{$ems{$_}}++;
}
Perhaps monsieur would prefer somzing a leetle different:
#! /usr/bin/perl -w
my $infile = 'c:/ems/sort/subject.rpt';
open SORTIN, $infile or die "Failed open $infile: $!\n";
my %seen = ();
my @out = grep { not $seen{$_}++ }
map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [ $_, (split /\|/)[0] ] }
<SORTIN>;
print @out;
TMTOWTDI. :-)
If I've solved the wrong problem for you, please post a clearer
description, and we'll see what we can do to help.
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Thu, 8 Jan 1998 10:41:17 -0400
From: "Vaughn Fox" <vfox@nbnet.nb.ca>
Subject: Re: Help with passing parameters in URL's please
Message-Id: <692p4e$73u$1@usenet50.supernews.com>
I've been working on this script for months, checking everywhere I can think
of for help and have not been able to solve this. If anyone has any ideas
on how to beat this please let me know.
Thanks
>
>No, spaces are valid in Unix file names, too. And if _that_ is the
>problem, the solution is in the docs for the open() function. Hope this
>helps!
>
------------------------------
Date: 8 Jan 1998 15:59:08 GMT
From: gbacon@adtran.com (Greg Bacon)
To: "Michael Georgiadis" <michael.georgiadis@btinternet.com>
Subject: Re: how does 'require' work?
Message-Id: <692t4c$fcc$4@info.uah.edu>
[Posted and mailed]
In article <692lii$eca$1@mendelevium.btinternet.com>,
"Michael Georgiadis" <michael.georgiadis@btinternet.com> writes:
: when you say
:
: require cgi-lib.pl;
Oi! I know a better way to spell that. :-)
use CGI;
: where does this library need to be installed? does it have to reside in the
: cgi-bin and if so will its contents be available to any program that calls
: it in this way if they too are in the cgi-bin?
% perldoc -f require
Hope this helps,
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Thu, 08 Jan 1998 10:38:12 -0600
From: brian <defaultuser@domain.com>
To: Kriebel <kriebels@nauticom.net>
Subject: Re: I tired to modify....
Message-Id: <34B500F4.6F97E886@domain.com>
Kriebel wrote:
> hello..
> I tried to modify a scrip...but It didnt work..
> print FILE "</a></tr><td></table><br><hr width="70%"><br>\n";
> is there anything wrong with that..or could it been possibly be the script
it's probably the above line you need to escape the double quotes around 70%
with a backslash.
i.e.
print FILE "</a></tr><td></table><br><hr width=\"70%\"><br>\n";
-brian
------------------------------
Date: Thu, 8 Jan 1998 10:04:49 -0500
From: "Rich Capenegro" <rcapenegro@brookdale.cc.nj.us>
Subject: Perl CGI - Apache 1.2
Message-Id: <692p3n$b7i$1@jujube.brookdale.cc.nj.us>
I am having problems running ANY Perl scripts with Apache 1.2 under
FreeBSD. Whenever I run a Perl script The server returns Internal Server
Error, and in the error log it says Premature end of script headers. I know
the scripts work because I ran them with Personal Web Server under Win 95.
Any help will be GREATLY appreciated! Thanks in advance.
Rich
rcapenegro@brookdale.cc.nj.us
------------------------------
Date: Thu, 08 Jan 1998 11:14:09 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl CGI - Apache 1.2
Message-Id: <comdog-0801981114090001@news.panix.com>
Keywords: just another new york perl hacker
In article <692p3n$b7i$1@jujube.brookdale.cc.nj.us>, "Rich Capenegro" <rcapenegro@brookdale.cc.nj.us> posted:
> I am having problems running ANY Perl scripts with Apache 1.2 under
> FreeBSD. Whenever I run a Perl script The server returns Internal Server
> Error, and in the error log it says Premature end of script headers. I know
> the scripts work because I ran them with Personal Web Server under Win 95.
these questions are more appropriate for comp.infosystems.www.authoring.cgi
although your question may be answered by the resources in the CGI
Meta FAQ.
good luck :)
--
brian d foy <http://computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
scarred for life by sendmail
------------------------------
Date: 8 Jan 1998 09:04:00 -0700
From: "Matt Bieber" <mattdb@syntrillium.com>
Subject: Please Help - Simple global counter using a file
Message-Id: <01bd1c4e$fa266910$153ff5cc@matt>
Hi all-
I'm lite on Perl and was wondering what might be the best way to implement
a simple counter in a file (to be used in a CGI situation to create an 'ID'
number) which will be incremented++ each time the file is opened. The file
will likely be accessed simultaneously, so I would need to use flock() I
assume. Does this work on Win32 (I am using NT)? If anyone has an example
of this I would greatly appreciate seeing it.
Thanks!
-Matt
------------------------------
Date: Thu, 08 Jan 1998 17:13:05 +0100
From: Tobias Bugala <TobiasBugala@swol.de>
Subject: print SOCK "Whatever";
Message-Id: <34B4FB11.2F32@swol.de>
Why dosen't it work?
Well, I open up a Socket-Connection to a server, get the answer by
read SOCK, $c, 1;
print "read OK\n";
while ($c ne chr 10)
{
print ord $c, "\n";
read SOCK, $c, 1;
}
but if I want to reply by
print SOCK "Anything";
I don't get an answer. If I type exactly the same strings in a
telnet-session it works.
Can someone help me?
TOBI
------------------------------
Date: Thu, 8 Jan 1998 07:50:20 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ricky <ric@megsinet.net>
Subject: Re: problem executing getting output
Message-Id: <Pine.GSO.3.96.980108074728.26818L-100000@user2.teleport.com>
On Wed, 7 Jan 1998, Ricky wrote:
> i have a script (search.cgi) written in gawk. i need to execute the
> search.cgi script from a perl script.
> how can i pass it the needed query_string from the perl script if it
> takes the data as if it were coming from a form?
You'll need to use the CGI calling protocol to call a CGI script directly.
(Of course, this protocol is the same whether the calling program is
written in Perl, C, or any other language, so there's nothing
Perl-specific about doing this.) Check out the CGI spec or a newsgroup
about CGI programming for more information. Hope this helps!
http://hoohoo.ncsa.uiuc.edu/cgi/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 8 Jan 1998 08:07:54 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Byron Rendar <brendar@pcc.edu>
Subject: Re: range operator with decimal numbers
Message-Id: <Pine.GSO.3.96.980108075759.26818M-100000@user2.teleport.com>
On 7 Jan 1998, Byron Rendar wrote:
> The Learning Perl book (2nd edition) states on p.49 that (1.2 .. 5.2)
> gives the list (1.2, 2.2, 3.2, 4.2, 5.2). Using perl5.004_1 I tried
> @a = (1.2 .. 5.2); print "@a\n" and got a list of integers 1 through
> 5.
>
> Is the book wrong or am I missing something?
It seems to me that the book is mistaken and that .. never worked that
way even back in perl4. But you're the first person to notice. :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 08 Jan 1998 14:10:30 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: regex to escape {, } except in TeX commands
Message-Id: <34b5de19.20652623@news.tornado.be>
Eli the Bearded <*@qz.to> wrote:
>> I need a regex to escape braces, {}, translating them to \{, \},
>> except when they are part of a TeX command like \texttt{stuff}.
>
>What can "stuff" be? I've never looked closely at TeX source ([nt]roff
>suits me fine). If it can contain nested {} pairs, then you are out
>of luck for now. (See the matching ( ) thread currently going on.)
So he's out of luck. TeX source is indeed organised as nested blocks.
Bart.
------------------------------
Date: Thu, 08 Jan 1998 08:53:21 -0500
From: Deflores <deflores@bigfoot.com>
Subject: Re: Running a perl script in the background on Windows(95/NT)
Message-Id: <34B4DA51.784A@bigfoot.com>
Mike Noel wrote:
>
> Please forgive me if this is the wrong newsgroup. My newserver doesn't
> carry comp.lang.perl (but it carries c.l.p.misc...).
>
> I've written a perl script on a Windows95/NT system that I would like to
> run and have sit in the background. The script itself does a bit of
> processing, then sleeps for 5 minutes, over and over again.
>
> I come from a UNIX background where this sort of thing is trivial but I
> can't figure out how to do it in Windows. Right now, when the script
> starts, it seems to run through a DOS window. As long as the script is
> running the DOS window is on the screen (or minimized and on the taskbar).
> If I kill the DOS window the process quits. I'd like to set up the script
> so that it doesn't use the DOS window. I don't want it to show up on the
> taskbar.
>
> From looking at the task manager I see that Windows95/NT recognizes a
> difference between applications and processes. It seems that applications
> have an associated window and processes don't. So I guess I want to
> convert my perl script from an application to a process.
>
> How can I do this?
>
> Thanks.
>
> _M_
> noel@integrityonline.com
Use Win32::Process and launch your perl script as a detached process.
This works beautifully and the script won't show up on the task bar.
use Win32;
use Win32::Process;
#Create the process object.
Win32::Process::Create($ProcessObj,
"C:\\PERL5\\BIN\\PERL.EXE",
"perl f:\\scripts\\myscript.pl",
0, # Don't inherit.
DETACHED_PROCESS,
".") || # current dir.
die &print_error;
sub print_error {
print Win32::FormatMessage( Win32::GetLastError() );
}
Regards,
deflores
------------------------------
Date: Thu, 8 Jan 1998 07:41:28 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mike Noel <noel@integrityonline.com>
Subject: Re: Running a perl script in the background on Windows(95/NT)
Message-Id: <Pine.GSO.3.96.980108073919.26818K-100000@user2.teleport.com>
On 7 Jan 1998, Mike Noel wrote:
> My newserver doesn't
> carry comp.lang.perl (but it carries c.l.p.misc...).
That's the right thing to do; c.l.p is defunct. c.l.p.misc is the proper
home for most Perl questions which aren't answered in the docs. Have fun
with Perl!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 8 Jan 1998 11:12:33 -0800
From: "Craig Girard" <craigg@servtech.com>
Subject: running a program from PERL and capturing the output
Message-Id: <692tse$8ro$1@post.servtech.com>
I am trying to run a program on unix through PERL and capture its output.
The command is "run showpages". This works fine at the command prompt but
when I use open (PAGES, "run showpages |"); I get errors saying it doesn't
exist. I have also tried SYSTEM as well, that did not work either. Any
suggestions?
Thank you
------------------------------
Date: Thu, 08 Jan 1998 11:31:05 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: running a program from PERL and capturing the output
Message-Id: <comdog-0801981131050001@news.panix.com>
Keywords: just another new york perl hacker
In article <692tse$8ro$1@post.servtech.com>, "Craig Girard" <craigg@servtech.com> posted:
> I am trying to run a program on unix through PERL and capture its output.
> The command is "run showpages". This works fine at the command prompt but
> when I use open (PAGES, "run showpages |"); I get errors saying it doesn't
> exist. I have also tried SYSTEM as well, that did not work either. Any
> suggestions?
what happens if you use an absolute path?
--
brian d foy <http://computerdog.com>
------------------------------
Date: Thu, 08 Jan 1998 10:38:32 -0500
From: "Kevin J. Lin" <kevin@wx3.com>
Subject: Search/sorting question
Message-Id: <34B4F2F8.C62C819C@wx3.com>
For a client I have a database of items, from which a CGI script is
looking up various products (say, from the customers shopping cart). To
speed things up (it's a large database), the products are sorted by a
unique code. It's a binary lookup and quite fast.
Here's the problem. Testing was done with all numeric codes; it turns
out some codes have numerics as well, eg: 123456768X. The database (MS
Excel) sorts starting with all numbers, then going to numbers with
characters. So 99999 is BEFORE 1111X, but after 11111.
In the PERL script I have been doing a comparison of the int() values,
which obviously is no longer going to work. Here's a sample line
showing the comparison:
if (int($code) < int($order_code)) {
$slot=$slot+$division;
}
How might I rewrite my comparison routine to search through the list the
way Excel has chosen to sort them (ie., numbers first, then strings).
Thanks greatly in advance,
- Kevin
------------------------------
Date: Thu, 08 Jan 1998 14:31:31 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: serious post about gmtime and year-1900 (was Re: Perl not Y2K compliant)
Message-Id: <692nun$5ft$1@cyprus.atlantic.net>
According to Eli the Bearded <*@qz.to>:
>Chip Salzenberg <chip@pobox.com> wrote:
>> Well, the C runtime is an issue with your C compiler vendor, not
>> Perl's maintainers.
>
>Yes but he'd still like to see some code in the documentation so that
>you can check if perl's reliance on the underlying C is wise.
That's silly. Anyone who's got Y2K issues has to test their C runtime
anyway, whether or not they're using Perl.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
** Perl Training from Stonehenge Consulting Services: (503) 777-0095 **
"I stopped that bus and I saved them kids!" "All except one -- the one
you let drive!" "He showed me his license..." "He was seven!!!" // MST3K
------------------------------
Date: Thu, 8 Jan 1998 07:22:43 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: serious post about gmtime and year-1900 (was Re: Perl not Y2K compliant)
Message-Id: <Pine.GSO.3.96.980108072048.26818H-100000@user2.teleport.com>
On Wed, 7 Jan 1998, Russell Schulz wrote:
> I think that instead of the perl documentation saying ``it will just
> work, trust me'',
That's not what it says in my copy.
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 8 Jan 1998 14:38:16 GMT
From: gbacon@adtran.com (Greg Bacon)
To: tchrist@mox.perl.com (Tom Christiansen)
Subject: Re: Testing for valid RegExps?
Message-Id: <692oco$fcc$1@info.uah.edu>
[Posted and mailed]
In article <692k2m$sa3$2@csnews.cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> writes:
: [courtesy cc of this posting sent to cited author via email]
:
: In comp.lang.perl.misc,
: gbacon@adtran.com (Greg Bacon) writes:
: :Is there a reason local() shouldn't preserve pos()?
:
: Shouldn't or doesn't?
Shouldn't.
: It's because local doesn't make
: locals. I see no reason to promote the idea that it does. :-)
:
: $BRAIN =~ s/local/savevar/g
I'm perfectly clear on the difference between a local value and a
local variable. However, given the following, it seems to me that
pos() has more to do with a particular value than a particular variable:
[8:27] crp-201% cat try
#! /usr/bin/perl -w
$_ = 'foo bar baz';
print "pos \$_ = ", defined pos($_) ? pos($_) : "undefined", "\n";
scalar(/bar/g);
print "pos \$_ = ", defined pos($_) ? pos($_) : "undefined", "\n";
$_ = 'quux';
print "pos \$_ = ", defined pos($_) ? pos($_) : "undefined", "\n";
[8:28] crp-201% ./try
pos $_ = undefined
pos $_ = 7
pos $_ = undefined
It seems most logical IMHO that protecting a value with local() should
also protect the associated pos() value. I'd be interested in hearing
opinions to the contrary.
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Thu, 08 Jan 1998 14:22:14 GMT
From: epa@datcon.co.uk (Ed Avis)
Subject: Re: Unix perl shell ???
Message-Id: <34b4e0b8.80246638@news-direct>
On 7 Jan 1998 22:12:28 GMT, Zenin <zenin@best.com> wrote:
>Robert Jenks <eat@joes.nospam.deli> wrote:
>: Anyone written or writing a UNIX perl shell?
>
> RTFFAQ
Maybe one of you Perl experts out there could write an "automatic
responder" for this kind of message 8-)
Scan the Perl FAQ for a section which roughly matches the question
posted, and automatically reply to the newsgroup with a reference to
that section.
Or has it already been done...?
--
Ed Avis
------------------------------
Date: 8 Jan 1998 15:39:57 GMT
From: gbacon@adtran.com (Greg Bacon)
To: hpcwire@nic.cerf.net (Darnell Fall)
Subject: Re: username:password crypt module
Message-Id: <692s0d$fcc$3@info.uah.edu>
[Posted and mailed]
In article <691fqb$92g$1@news.cerf.net>,
hpcwire@nic.cerf.net (Darnell Fall) writes:
: Somewhere there has to be a quick and dirty module that will accept
: a username and password as input, and squirt out a username and
: encrypted password.
Bah.. a module in this case would be hunting rabbit with a tank.
#! /usr/bin/perl -w
my @salts = ( 'A' .. 'Z', 'a' .. 'z', 0 .. 9, '.', '/' );
my $salt;
my $user;
my $pass;
while (<>) {
chomp;
($user, $pass) = split /:/;
$salt = $salts[rand @salts] . $salts[rand @salts];
print $user, ":", crypt($pass, $salt), "\n";
}
Obviously, the lines in the input file(s) are usernames and plaintext
passwords, separated by a colon. The output is the same, except the
password is en-crypt(3)-ed.
% chmod 600 input-file
:-),
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Thu, 8 Jan 1998 08:17:58 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Darnell Fall <hpcwire@nic.cerf.net>
Subject: Re: username:password crypt module
Message-Id: <Pine.GSO.3.96.980108081619.26818O-100000@user2.teleport.com>
On 8 Jan 1998, Darnell Fall wrote:
> Somewhere there has to be a quick and dirty module that will accept
> a username and password as input, and squirt out a username and
> encrypted password.
There may be one, but I'd just use crypt() from the perl core. :-)
> It's the time pressure that's killing me.
Imagine how much faster you would have gotten this answer if you had used
the command 'perldoc -f crypt' instead of posting! :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 08 Jan 1998 06:44:12 -0800
From: Patience <feng@haas.berkeley.edu>
Subject: what's wrong? can't match a range of number
Message-Id: <34B4E63B.5405C5F0@haas.berkeley.edu>
Hi guys,
My script will validate user's birthday in format of 11/22/77 or
11/22/1977. I don't know why my code does not work.
if ($Pair{Birthday} != /(1..12)\/(1..31)\/(0..1986)/)
{
&Reject ('You had made a typo in your birthday. The format must
be similar to 11/30/76 or 11/30/1976');
}
Thanx a bunch in advance! : )
--
Patience (Pei-shen)
feng@haas.berkeley.edu OR psf@usa.net
------------------------------
Date: Thu, 08 Jan 1998 10:18:12 -0500
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: what's wrong? can't match a range of number
Message-Id: <34B4EE34.43FC48BA@infi.net>
Patience wrote:
>
> Hi guys,
I'd recommend reading the perlre man page.
> My script will validate user's birthday in format of 11/22/77 or
> 11/22/1977. I don't know why my code does not work.
>
> if ($Pair{Birthday} != /(1..12)\/(1..31)\/(0..1986)/)
Let's go through this expression...
/(1..12) # match 1 followed by two characters followed by 12
\/ # match a /
(1..31) # match 1 followed by two characters followed by 31
\/ # match a /
(0..1986)/x # match a 0 followed by two characters followed by 1986
So your expression would match something like
1xx12/1xx31/0xx1986
but not 11/30/1976
Matching dates isn't always easy, especially if you want to avoid things
like
02/31/97 and the like
I'd recommend reading "Mastering Regular Expressions" by Jeffrey Friedl
from O'Reilly & Associates, Inc. for more information on matching tricky
stuff like
that.
--
+---+
Ty Cage Warren tycage@wsol.net
Homepage: http://www.wsol.net/~tycage/
PGP Public Key: http://www.wsol.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78 B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------
------------------------------
Date: Thu, 08 Jan 1998 09:11:27 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: what's wrong? can't match a range of number
Message-Id: <34B4FAAF.3F4817B8@mystech.com>
Ty Cage Warren wrote:
> Patience wrote:
> >
> > Hi guys,
>
> I'd recommend reading the perlre man page.
>
> > My script will validate user's birthday in format of 11/22/77 or
> > 11/22/1977. I don't know why my code does not work.
> >
> > if ($Pair{Birthday} != /(1..12)\/(1..31)\/(0..1986)/)
>
> Let's go through this expression...
>
> /(1..12) # match 1 followed by two characters followed by 12
> \/ # match a /
> (1..31) # match 1 followed by two characters followed by 31
> \/ # match a /
> (0..1986)/x # match a 0 followed by two characters followed by 1986
>
> So your expression would match something like
> 1xx12/1xx31/0xx1986
> but not 11/30/1976
On top of that, the if statement will likely always evaluate true since the
pattern match is operating on $_, and returning true (1) or false ("") in
scalar context, which is numerically compared to the birth date which is not
a number! With -w on, Perl gives the warning:
Argument "11/22/77" isn't numeric in ne at junk.pl line 6.
(or something like that). Of course, what the author meant was to use the !~
operator!!!
-----------------------------
Mark S. Reibert, Ph.D.
Mystech Associates, Inc.
3233 East Brookwood Court
Phoenix, Arizona 85044
Tel: (602) 732-3752
Fax: (602) 706-5120
E-mail: reibert@mystech.com
-----------------------------
------------------------------
Date: 08 Jan 1998 11:44:17 -0500
From: Clark Dorman <clark@s3i.com>
Subject: Re: what's wrong? can't match a range of number
Message-Id: <dk9cac3vi.fsf@elmo.s3i.com>
Patience <feng@haas.berkeley.edu> writes:
> My script will validate user's birthday in format of 11/22/77 or
> 11/22/1977. I don't know why my code does not work.
>
> if ($Pair{Birthday} != /(1..12)\/(1..31)\/(0..1986)/)
> {
> &Reject ('You had made a typo in your birthday. The format must
> be similar to 11/30/76 or 11/30/1976');
> }
You would think that it might work, wouldn't you?
The problem (a problem anyway) is that the '.' in the above '..' is
interpreted as 'match any character (except newline)'
Consider the following code in blah.pl:
if ( $date =~ /(1..12)/) {
print " It matches #2\n";
}
else {
print " It doesnt #2\n ";
}
% blah.pl
4
It doesnt #2
% blah.pl
19912
It matches #2
%
The 1..12 matches something that has a '1', has two of anything, and
then has a '12'.
Personnally, I wouldn't like to use 0..1986 even if it _did_ work.
Why make the poor process make a temporary array of lenth 1987? I
would suggest that you split it, and check the parts of it
individually. That will also let you give a better diagnostic to the
user (like, make your month in the range 1 to 12 if the month breaks).
I like regular expressions too, but in perl there is more than one way
to do it and REs are not always the best, and especially are not the
clearest. Frequently, they provide too many ways to shoot yourself in
the foot.
--
Clark Dorman "Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html -Francis Crick
------------------------------
Date: Thu, 08 Jan 1998 10:11:16 -0600
From: arae@uk.mdis.com (Alastair Rae)
Subject: win32 drive letters
Message-Id: <884275293.543096842@dejanews.com>
[Sorry if you've seen this twice]
Is there a way to get a list of drive letters on a win32 system? Eg it
might return something like ( 'a:', 'c:', 'd:', 'e:' ).
Alternatively is there a way to test that a disk letter is valid?
TIA.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 8 Jan 1998 10:27:48 -0600
From: "Phil Jach" <moc.care@hcajp>
Subject: Re: win32 drive letters
Message-Id: <34b4fe78.0@news1.ibm.net>
Use Perl Win32 API called
Win32::GetNextAvailDrive
Returns a string in the form of "<d>:\" where <d> is the first available
drive letter
Hope this helps.
Alastair Rae wrote in message <884275293.543096842@dejanews.com>...
>[Sorry if you've seen this twice]
>
>Is there a way to get a list of drive letters on a win32 system? Eg it
>might return something like ( 'a:', 'c:', 'd:', 'e:' ).
>
>Alternatively is there a way to test that a disk letter is valid?
>
>TIA.
>
>-------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 08 Jan 1998 11:24:01 -0500
From: Deflores <deflores@bigfoot.com>
Subject: Re: win32 drive letters
Message-Id: <34B4FDA1.60E2@bigfoot.com>
Alastair Rae wrote:
>
> [Sorry if you've seen this twice]
>
> Is there a way to get a list of drive letters on a win32 system? Eg it
> might return something like ( 'a:', 'c:', 'd:', 'e:' ).
>
> Alternatively is there a way to test that a disk letter is valid?
>
> TIA.
>
> -------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
Why not parse the output of Net use?
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 1601
**************************************