[7468] in Perl-Users-Digest
Perl-Users Digest, Issue: 1093 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 28 15:17:22 1997
Date: Sun, 28 Sep 97 12:00:41 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 28 Sep 1997 Volume: 8 Number: 1093
Today's topics:
Re: [Q] Append to last line in file? (Jeff Stampes)
Re: Advanced Perl Programming - Error p. 91??? <rootbeer@teleport.com>
Re: Can't See Pattern (Steve Bowen)
Re: Can't See Pattern (Tom Grydeland)
commercial packages w/ perl? Tivoli, ClearCase, DDTS, (Richard A. Stewart)
Re: Directly Access to wtmp file (Nicholas J. Leon)
Re: file globbing with spaces in the name <rootbeer@teleport.com>
Re: file globbing with spaces in the name (Andrew M. Langmead)
Re: formatting output <rootbeer@teleport.com>
Re: HELP! on Attaching files to email. <rootbeer@teleport.com>
help! <merata@pearl.sums.ac.ir>
Re: Help! (Andrew M. Langmead)
Re: Help: Regular Expression Substitution (Mike Stok)
Re: I have an error with my script (brian d foy)
Re: I have an error with my script <rootbeer@teleport.com>
Java CGI Post to Perl Script (Peter)
Re: Java CGI Post to Perl Script (brian d foy)
Re: Julian Date Routine (Derek Bell)
Re: launch Windows 3.1 app from within Perl? (Danny Aldham)
Need help with syntax in perl <masroor@bga.com>
Re: Need help with syntax in perl (brian d foy)
Re: newbie - source for Perl 5 w/WWW libs for Win 95 <rootbeer@teleport.com>
Re: Newbie URL Redirection Question <jefpin@bergen.org>
Re: Perl4 is *not* Y2K (was Re: Y2K) <fearless@io.com>
Re: Searching a directory <jefpin@bergen.org>
Re: sysread() question (Tom Grydeland)
Re: sysread() question <rootbeer@teleport.com>
Re: sysread() question <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Sep 1997 20:02:35 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: [Q] Append to last line in file?
Message-Id: <60joor$fql$1@neocad.com>
thalerj_NOSPAM@wwa._NOSPAM.com wrote:
: Currently I'm attempting the following:
: open FP, "+>>$filename";
: seek FP, 0, 0;
: print FP, "$newtext ";
: close FP;
: But it's still printing the newtext on a new line at the end.
I doubt it.
Do you realize that with that seek statement, you are setting
the file pointer to the BEGINNING of the file?
Why is everyone so determined to avoid temporary storage, and
want to edit files in place?
You want to append to the last line? Why not something like:
open THIS, "+<$filename" or die $! ## open for read/write
## without clobbering
my @array = (<THIS>); ## Slurp it into an array
chomp $array[-1]; ## Take the newline off the last line
$array[-1] .= "## a comment\n"; ## append a comment to the end
seek THIS,0,0; ## File pointer to the beginnine
print THIS @array; ## Dump it to the file
close THIS; ## Close it
Of course, if this is data you consider important, this is not
an adequate routine. If it's truly important, you would make
a backup copy first, and have a signal handler be prepared to
restore the backup if the program was interrupted while the file
is open.
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Sun, 28 Sep 1997 11:01:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ronjeet Lal <rsl3047@unix.tamu.edu>
Subject: Re: Advanced Perl Programming - Error p. 91???
Message-Id: <Pine.GSO.3.96.970928105749.12117H-100000@usertest.teleport.com>
On Sat, 27 Sep 1997, Ronjeet Lal wrote:
> I am reading "Advanced Perl Programming" from O'Reilly & Assoc.
> I think I found an error on p.91.
> Should the "use Account" lines be "use BankAccount" since the
> package name is BankAccount?
Yes, or they could fix the name of BankAccount to be Account. It looks to
me as if somebody got halfway through changing the name of the module and
didn't finish. :-)
Could you send a note about this (and any other errors you find in their
books) to O'Reilly's comments address? It's listed in the Preface of each
book, if I'm not mistaken. 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: Sun, 28 Sep 1997 14:42:22 GMT
From: steveb@cottagesoft.com (Steve Bowen)
Subject: Re: Can't See Pattern
Message-Id: <342f6cbb.8687451@news.cottagesoft.com>
On Thu, 25 Sep 1997 01:25:12 GMT, steveb@cottagesoft.com (Steve Bowen)
wrote:
>I'm pulling my hair out, trying to figure why Perl can't see the following:
>
>open (IN, $ARGV[0]) or die "Can't open $ARGV[0].\n";
>
>while (<IN>) {
> if (/.+(..):(..):(..)/s) { # This is proving FALSE (with or without
> # /s), thus
> $hour = $1; #can't see
> $minute = $2; #ditto
> $second = $3; #ditto
> }
>...more stuff that all parses without error.
Thanks for all the help. Yes, it does match. Unfortunately, I was
applying it a little differently than I posted.
while (<IN>) {
if (/Acct-Status-Type = Start/) {
if (/.+(..):(..):(..)/s) {
...
In this form the "time" line isn't read. All your comments made me
recognize that it couldn't, if Perl is reading only one line at time.
However, this seems to be a continuing problem I have understanding how the
above construct works. Perl seems to "see" the entire list (<IN>), and
operates on that principle in other ways. For example, regardless which
order I present the matching lines, Perl responds sequentially to <IN>,
matching later lines of my script before previous lines, which in turn
produces initialization errors.
I am trying to extract data from Livingston's "detail" file and print it in
some orderly fashion. I want to match the Start record's authentication
with the corresponding user's Stop record, and gather the information from
the Stop record. Yet, when I think I have the data, I seem to have a
problem with the end of record line, which is a blank line between. Is
there a regular expression that identifies some default end of record?
Steve Bowen
steveb@cottagesoft.com
------------------------------
Date: 28 Sep 1997 15:56:53 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Can't See Pattern
Message-Id: <slrn62svi4.qet.Tom.Grydeland@mitra.phys.uit.no>
On Sun, 28 Sep 1997 14:42:22 GMT,
Steve Bowen <steveb@cottagesoft.com> wrote:
> However, this seems to be a continuing problem I have understanding how the
> above construct works. Perl seems to "see" the entire list (<IN>), and
> operates on that principle in other ways.
When using while (<>) {...}, perl reads one line at a time9 and runs the
body of the loop once for each line.2
> I want to match the Start record's authentication with the
> corresponding user's Stop record, and gather the information from the
> Stop record. [...] Is there a regular expression that identifies some
> default end of record?
Could be. Depends on your end-of-record marker. I don't know the
format of the file in question, but you could look into something like:
while (<>) {
next unless /START_RECORD/ .. /STOP_RECORD/;
# Process the data within the record
}
or you could fiddle with the input record separator, $/.
> Steve Bowen
-------------
9 unless you've changed the input record separator, $/.
2 unless you've played with redo.
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: 28 Sep 1997 15:12:47 GMT
From: ras1@mtras1.mt.lucent.com (Richard A. Stewart)
Subject: commercial packages w/ perl? Tivoli, ClearCase, DDTS, ... :-)
Message-Id: <60ls5f$h4k@nntpb.cb.lucent.com>
Are there any lists of commercial packages that formally
include and/or utilize perl? Could folks please post
such lists (URL's) or the names of other packages like
Tivoli, ClearCase & DDTS that now include & use perl.
One can almost (:-) always find a way and reason to
make some use of perl even when working with other
commercial software packages & applications.
It's fully reasonable & now seems to becoming increasingly
common for perl modules, scripts plus perl itself to be
formally bundled in with commercial software distribution,
e.g. Tivoli, ClearCase & DDTS.
Perl brings strength, speed, robustness & flexibility
while also allowing for easy yet powerful customizations.
Thought it would be interesting to see a list of the
commercial packages that now embrace the use of perl.
Is there currently any such list? Checked perl.com, FAQ's,
Advocacy ... but noted no such list; also tried CPAN ...
DejaNews, AltaVista & HotBot turned up lots of job
postings seeking folks to with perl skills interested
in working on commercial packages that make use of perl.
It might be both interesting & useful in expanding the
commercial adoption/embrace of perl to have a list of
commercial packages making use of perl.
Would be delighted see even some partial listings (URL?)
and/or some posting naming other commercial packages that
include and/or making use of perl.
If a formal list were developed & maintained it might
be annotated with respect to:
Function (e.g. system admin), name, provider & URL's
Perl (4 &/or 5) included in distribution.
Primary package (fully) written in perl.
Primary package makes use of perl, e.g. icw audits & reports.
Auxiliary, e.g. conversion & load, functions utilize perl.
Perl modules included or available from archive.
Perl scripts included or available from archive.
Next formal release reported to make use of perl.
Customer contributed perl scripts & modules
included or available from archive.
Could be some ORA/Perl books out there for some folks to write
and reap $$$ from, e.g. "Making the best use of perl with ..."
-ras Richard A Stewart
Lucent Technologies, BCS
MT/3D441, (732) 957-2782
rs@lucent.com
Brent's Standard Disclaimer
http://comedy.clari.net/rhf/jokes/87/4487.html
Lawrence's wrt Checks for Software
http://comedy.clari.net/rhf/jokes/91q4/softcheq.html
&/or AT&T website terms may apply :-)/:-(
http://www.att.com/terms.html
------------------------------
Date: 28 Sep 1997 15:55:22 GMT
From: nicholas@neko.binary9.net (Nicholas J. Leon)
Subject: Re: Directly Access to wtmp file
Message-Id: <slrn62svf5.3fh.nicholas@neko.binary9.net>
In article <342A5C3E.C61C0AC0@micso.it>, Emiliano Bruni wrote:
>Someone know if (and how) it's possible to access to wtmp Digital and
>Linux file from a perl script without, obviously, using an external
>shell program (like lastlog) and read loggind data in it.
>
>Thanks for Every kind of info.
Funny you should ask this :) I just solved this issue by finding a
program called "pstruct" on my system.
You can create a perl pack string by something along these lines:
> pstruct -p -sutmp /usr/include/utmp.h > mylib.pl
Then by including mylib.pl, you have access to $utmp'typedef which is
a string suitable for using with pack (untested):
#!/usr/bin/perl
use strict;
require "mylib.pl";
my $buff='';
my @arr=();
open(IN,"</etc/utmp") || die $!;
while (!eof(IN)) {
read(IN,$buff,$utmp'sizeof);
print join(' ',unpack($utmp'typedef,$buff))."\n";
}
close IN;
------------------------------
Date: Sun, 28 Sep 1997 10:42:02 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: David Ransier <david_ransier@intercept.com>
Subject: Re: file globbing with spaces in the name
Message-Id: <Pine.GSO.3.96.970928103911.12117C-100000@usertest.teleport.com>
On 28 Sep 1997, David Ransier wrote:
> I'm writing a recursive routine that will walk down a directory
> structure deleting files and sub directories.
It sounds as if you should be using File::Find, or something like that.
> It works fine until it runs into a directory with a space in the name.
> Files are OK, but not directories.
If you must do this yourself, don't use globbing. (And globbing on * won't
get every file, anyway.) Use readdir and friends, which have no problems
with funny filenames. (But use defined() in a conditional, so that you
won't have problems with a file named '0'. And be sure to watch out for
'.' and '..' and symlinks. :-)
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: Sun, 28 Sep 1997 17:41:38 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: file globbing with spaces in the name
Message-Id: <EH8BtF.3z@world.std.com>
"David Ransier" <david_ransier@intercept.com> writes:
>I'm writing a recursive routine that will walk down a directory structure
>deleting files and sub directories.
You might want to think about changing from fileglobbing to
opendir()/readdir() calls, maybe with the DirHandle object wrapper.
use DirHandle;
my $dir = new DirHandle "$dirName";
foreach $file (map "$dirName/$_", $dir->read()) {
}
Or maybe use File::Find to handle the recursion as well.
--
Andrew Langmead
------------------------------
Date: Sun, 28 Sep 1997 10:52:55 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: maso96 <C.S.I@dial.pipex.com>
Subject: Re: formatting output
Message-Id: <Pine.GSO.3.96.970928104828.12117G-100000@usertest.teleport.com>
On 27 Sep 1997, maso96 wrote:
> below is an output from a script that calculates size
> differences from week to week project by project.
> how do i get from this which is the best i can get
>
> file1 file2 file3
> Proj1 100 ( 90) 89 1204 ( 80)
> Proj2 120 1234 ( 24) 700 ( 300)
> etc......
>
> to -
>
> file1 file2 file3
> Proj1 100 (90) 89 1024 (80)
> Proj2 120 1234 (24) 700 (300)
>
> where the figure in brackets is the difference from last week
> in the file size which may or may have changed.
> if i use (%.2f) this will get rid if the spaces in the brackets but
> then i can't line up the fields from project to project.
I find your question to be a little incoherent, but I think you're asking
how you can put variable-width strings into a fixed-width report. You may
do this by combining printf and sprintf, something like this.
printf "%-20s %-20s %-20s %-20s",
"Proj1",
sprintf("%d (%.2f)", 100, 90),
89,
sprintf("%d (%.2f)", 1024, 80);
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: Sun, 28 Sep 1997 10:47:17 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Rob Nedelcu <nedelcu@algonet.se>
Subject: Re: HELP! on Attaching files to email.
Message-Id: <Pine.GSO.3.96.970928104508.12117E-100000@usertest.teleport.com>
On Sat, 27 Sep 1997, Rob Nedelcu wrote:
> I need some help on attaching files when emailing individuals who have
> filled in their email adress in a form. Collecting it and sending a
> message is no problem, but I need to send 2 files along with it as
> word documents. How do I do this one? I've tried almost anything!
>
> I'm using sendmail...
I'd consider using a module instead of sendmail. But if you want to use
sendmail, the Perl part of the answer is simple: Just send the right
commands and data to sendmail! If you're doing that and it doesn't work,
you've found a bug in sendmail. If you're not sure what commands to send,
check with your docs and FAQs about sendmail, or a sendmail newsgroup,
which should be able to give you a better and more complete answer than we
can give you here. Good luck!
--
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: 28 Sep 1997 13:00:02 -0400
From: Anooshiravan Merat <merata@pearl.sums.ac.ir>
To: comp.lang.perl.misc@myriad.alias.net
Subject: help!
Message-Id: <3.0.3.32.19970928195409.006992d0@194.225.78.2>
Salaam,
someone please tell me where can i find a guide about perl on the net. i
know some C and some BASIC programming and i want to start on perl. (no
books please, tell me about guides that are available on the net)
regards,
Anooshiravan Merat,
http://www.sums.ac.ir/~merata
------------------------------
Date: Sun, 28 Sep 1997 17:29:29 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Help!
Message-Id: <EH8B95.JDt@world.std.com>
"Christopher Pieper" <cmpiep@maila.wm.edu> writes:
> Now
>I know how to change the file but it is the process of going through all
>the files in a directory and then switching directories that has me
>baffled.
One convenient way of doing this is the File::Find module that comes
with perl.
use File::Find;
my $dir = shift || die "usage: $0 directory files...\n";
find ( \&wanted, $dir);
sub wanted {
return unless -T $_; # skip non-text files.
my $file = $File::Find::name;
if(-e "$file.html") {
warn "File $file.html already exists, skipping...\n";
return;
}
open IN, $file or warn "Can't open $file: $!\n";
open OUT, ">$file.html" or warn "Can't write to $file.html: $!\n";
# read on IN, change it however you want, write to OUT
close IN;
close OUT;
}
--
Andrew Langmead
------------------------------
Date: 28 Sep 1997 15:31:06 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Help: Regular Expression Substitution
Message-Id: <60lt7q$ib9@news-central.tiac.net>
In article <342D4668.A21D662B@webexpert.net>,
Kai Chang <kai@webexpert.net> wrote:
> I am trying to parse comments comments out of C code, and I ran
>across an
>oddity. I've made a work around, but I still don't understand why my
>first idea
>didn't work. Please help, and cc a copy to my e-mail at
>kai@webexpert.net.
>Thank you.
> I've already worked out "//" and if "/*" is on one line and "*/" is
>on another.
>What I'm trying to work out here is:
>1) /*comment*/ print "Hello World!\n";
>2) print "Hello World!\n"; /*comment*/
>3) /*comment1*/ print "Hello World!\n"; /*comment2*/
>4) /*comment1*/ print "Hello World!\n"; /*comment2*/ print "Hello
>Again!\n";
>
>and the code I intended to use was:
>
>$Curline =~ s/^([^"\n]*(".*")*[^"\n]*)\/\*[^(\*\/)\n]*\*\//$1/g;
You might try the solution suggested in the FAQ at
http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfaq6/How_do_I_use_a_regular_expresio.html
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Sun, 28 Sep 1997 13:08:14 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: I have an error with my script
Message-Id: <comdog-ya02408000R2809971308140001@news.panix.com>
In article <01bc2256$4eecb9c0$ec3729cf@main>, "Jason Buckley" <jbuckley@webvermont.com> wrote:
>I think that my perl script is fine, but I may not have it configured
>correctly. For some reason I keep getting a 500 error from my server?
have you checked the various FAQs? (see the sig...)
>#!/bin/perl
># Receive Info From Free Link
>read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
[snip broken code]
perhaps you should look into CGI.pm - it does all of this CGI
processing for you (correctly even) :)
>print "Content-type: text/html\n\n";
>print "<html><head><title>Thank You</title></head>\n";
>print "<body><h1>Thank You For Adding a Link</h1>\n";
>print "Here's what you added:<br><br>\n";
you might also look into using here documents for this sort of
quoting - it improves readability and editability :)
print <<"HTML";
Content-type: text/html
<html>
<head>
<title>Thank You</title>
</head>
<body>
<h1>Thank You For Adding a Link</h1>
<!--and so on-->
HTML
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 28 Sep 1997 11:34:15 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jason Buckley <jbuckley@webvermont.com>
Subject: Re: I have an error with my script
Message-Id: <Pine.GSO.3.96.970928113243.12117K-100000@usertest.teleport.com>
On 28 Sep 1997, Jason Buckley wrote:
> I keep getting a 500 error from my server?
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to
solving such problems. It's available on the perl.com web pages. Hope
this helps!
http://www.perl.com/perl/
http://www.perl.com/perl/faq/
http://www.perl.com/perl/faq/idiots-guide.html
--
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: Sun, 28 Sep 1997 16:13:46 GMT
From: peterpan@mailexcite.com (Peter)
Subject: Java CGI Post to Perl Script
Message-Id: <342e81f9.564528@news.hk.linkage.net>
Hello All,
I write a Java applet to POST some data to a server
script and that script will send back what I post to it. When I use a
compiled C script, all things work fine. but when I use a PERL script
to replace that C script. I encounter a "Server Error 500" IO
exception that produce from the server. Anybody know what's wrong?
I have tested my script under debug mode and find it ok. The
following is my script:
#!/usr/local/bin/perl
use CGI qw(:standard);
$query = new CGI;
$yourname = $query->param('name');
$youremail = $query->param('email');
print header();
print start_html();
print $yourname;
print $youremail;
print end_html();
------------------------------
Date: Sun, 28 Sep 1997 12:58:00 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Java CGI Post to Perl Script
Message-Id: <comdog-ya02408000R2809971258000001@news.panix.com>
In article <342e81f9.564528@news.hk.linkage.net>, peterpan@mailexcite.com (Peter) wrote:
>I write a Java applet to POST some data to a server
>script and that script will send back what I post to it. When I use a
>compiled C script, all things work fine. but when I use a PERL script
>to replace that C script. I encounter a "Server Error 500" IO
>exception that produce from the server. Anybody know what's wrong?
it's very difficult to tell from the information you gave, but
you can check the "Idiot's Guide to Solving Perl CGI problems" [1]
[1]
<URL:http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html>
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 28 Sep 1997 16:24:06 +0100
From: dbell@maths.tcd.ie (Derek Bell)
Subject: Re: Julian Date Routine
Message-Id: <60lsqm$shr@bell.maths.tcd.ie>
Brian Ewins <Brian.Ewins@dont.spam.me> writes:
>And a quick conversion:
>$julian = 2440588+int(time/86400);
> ^Julian date for jan 1st 1970
> ^seconds in a day
Shouldn't the 2440588 be 2440588.5? Unix times its dates from 00:00 on
that day and the julian calendar counts from 12:00, which means that any
midnight has to be Julian Day x.5, where x is the integer part.
Derek
--
Derek Bell dbell@maths.tcd.ie |The road to hell is paved with
WWW: http://www.maths.tcd.ie/~dbell/index.html| melting snowballs
PGP: http://www.maths.tcd.ie/~dbell/key.asc | -- Larry Wall
------------------------------
Date: 28 Sep 1997 10:45:53 -0700
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: launch Windows 3.1 app from within Perl?
Message-Id: <60m54h$7c5$1@lennon.postino.com>
Mark Willey (willey@purdue.edu) wrote:
: Can't find this in any FAQ:
: Is there a way to launch a Windows 3.1 app from within a Perl script?
: Something like minesweep.pl that would launch minesweeper, for example. Or
: is there any general utility program that would do that which I could
: invoke from said perl script?
#!/usr/bin/perl -w
system("winmine.exe") ;
or exec("winmine.exe") ;
--
Danny Aldham SCO Ace , MCSE , JAPH , DAD
I wak'd, she fled, and day brought back my night. jm
------------------------------
Date: 28 Sep 1997 14:43:04 GMT
From: masroor <masroor@bga.com>
Subject: Need help with syntax in perl
Message-Id: <60lqdo$pju$1@news3.realtime.net>
Hi ::
1) /Hello/
Question , In the above statment I am searching for the word hello.
What would be syntax, if I wanted to pass a command line
argument, that way it will search for the strinmg that is
passed by the argument.
I have tried the followings and they didn't work.
1) /\$1/
2) /\$ARGV\[0\]/
3) /$ARGV\[0\]/
ANy help would be appreciated.
Thanks
Masroor
email ===> masroor@bga.com
------------------------------
Date: Sun, 28 Sep 1997 13:03:31 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Need help with syntax in perl
Message-Id: <comdog-ya02408000R2809971303310001@news.panix.com>
In article <60lqdo$pju$1@news3.realtime.net>, masroor <masroor@bga.com> wrote:
>Hi ::
>
>1) /Hello/
>
>Question , In the above statment I am searching for the word hello.
> What would be syntax, if I wanted to pass a command line
> argument, that way it will search for the strinmg that is
> passed by the argument.
> I have tried the followings and they didn't work.
>
> 1) /\$1/
> 2) /\$ARGV\[0\]/
> 3) /$ARGV\[0\]/
what about the simple
/$ARGV[0]/
? no need to escape anything:
#!/usr/bin/perl
$string = 'japh';
print "Matches japh!\n" if $string =~ /$ARGV[0]/;
__END__
% perl test.pl japh
Matches japh!
% perl test.pl hello
%
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 28 Sep 1997 10:43:54 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: sandra <web-babe@mailcity.com>
Subject: Re: newbie - source for Perl 5 w/WWW libs for Win 95
Message-Id: <Pine.GSO.3.96.970928104237.12117D-100000@usertest.teleport.com>
On Sun, 28 Sep 1997, sandra wrote:
> Where can a rookine Perl person such as mysekf start looking for the
> current good scoop on how to get the Perl 5.x with the WWW libraries
> running on a Win95 machine?
There are complete instructions which come with the Perl distribution. If
you've still got questions after you've read the docs and FAQs, please ask
again here. Good luck!
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
--
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: Sun, 28 Sep 1997 13:00:48 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
To: lmain@ti.com
Subject: Re: Newbie URL Redirection Question
Message-Id: <Pine.SGI.3.95.970928125955.26094C-100000@vangogh.bergen.org>
>Greetings!! I am brand new to Perl (2 days) and I am working on a CGI
>for my company. I am trying to find a way to send the user to a
>particular site. Unfortunately, my Perl 5 book and all my searching on
>the web has left me clueless. I don't want to spout html out, just send
>them to another page (for now).
>Can anybody help me?? Please!
The easiest way (TMTOWTDI) would be:
print "Location: http://www.yoursite.com/dir/redirect.html\n\n";
That would send them to whatever site you indicate.
----------------
| Before you think UNIX is family-oriented, note that all children must die.
| - Cross-Platform Perl
----------------
Jeff Pinyan | http://users.bergen.org/~jefpin | jefpin@bergen.org
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
** I can be found on #perl on irc.ais.net as jpinyan **
- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>$ P+++$>++++ L E--->---- W++$
N++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y?
------------------------------
Date: 28 Sep 1997 13:57:55 GMT
From: "Creede Lambard" <fearless@io.com>
Subject: Re: Perl4 is *not* Y2K (was Re: Y2K)
Message-Id: <60lnp3$2si@bgtnsc02.worldnet.att.net>
Randal Schwartz <merlyn@stonehenge.com> wrote in article
<8c3emp8swu.fsf_-_@gadget.cscaper.com>...
>
> Perl4 is dead dead DEAD!
>
Nono! Perl4 is not dead! It's gone into hiding. If you want to find it you
have to get a copy of Perl5. It's in there. Really. Trust me. :D
------------------------------
Date: Sun, 28 Sep 1997 12:58:46 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
Subject: Re: Searching a directory
Message-Id: <Pine.SGI.3.95.970928125720.26094B-100000@vangogh.bergen.org>
>use this:
>opendir(DIR, "/your/dir/tobe/opened");
>@contents = <DIR>;
>close (DIR); # or is it closedir(DIR); ???
Tom told me I was wrong... and I am... sorry:
opendir(DIR, "/your/dir/tobe/opened") or die "Directory can't be opened: $!";
@contents = readdir(DIR);
closedir(DIR);
THIS should read your directory and output its contents to @contents.
----------------
| "I don't contemplate it, I just sit and think about it."
| - Sonia Balsky
----------------
Jeff Pinyan | http://users.bergen.org/~jefpin | jefpin@bergen.org
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
** I can be found on #perl on irc.ais.net as jpinyan **
- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>$ P+++$>++++ L E--->---- W++$
N++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y?
------------------------------
Date: 28 Sep 1997 16:01:21 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: sysread() question
Message-Id: <slrn62svqh.qet.Tom.Grydeland@mitra.phys.uit.no>
On 27 Sep 1997 15:29:45 GMT,
Trudno zhit' v derevne bez nagana. <alex@kawo2.rwth-aachen.de> wrote:
> I guess the Perl is just a bad language for sockets and
> server stuff and stop converting my C-code to Perl.
It's probably not Perl, it's the way you use it.
If you blindly translate C to Perl, you're likely to get bad Perl.
For a nice, Perl-ish way of writing clients and servers in Perl, take a
look at IO::Socket, included with your latest Perl or available from
CPAN.
> Alex
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Sun, 28 Sep 1997 11:08:07 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Trudno zhit' v derevne bez nagana." <alex@kawo2.rwth-aachen.de>
Subject: Re: sysread() question
Message-Id: <Pine.GSO.3.96.970928110616.12117I-100000@usertest.teleport.com>
On 27 Sep 1997, Trudno zhit' v derevne bez nagana. wrote:
> I guess the Perl is just a bad language for sockets and
> server stuff
Not true!
--
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: Sun, 28 Sep 1997 11:31:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Trudno zhit' v derevne bez nagana." <alex@kawo2.rwth-aachen.de>
Subject: Re: sysread() question
Message-Id: <Pine.GSO.3.96.970928110822.12117J-100000@usertest.teleport.com>
On 27 Sep 1997, Trudno zhit' v derevne bez nagana. wrote:
> >It wouldn't be hard to make this compliant
> >with 'use strict', and that should even speed it up a little.
>
> Can you please explain a little bit more,
> what do you mean?
Perl is a very permissive language; it lets you write your code however
you'd like. At times, that can mean that you're writing code which is
slower or less reliable, or simply harder to maintain, than it should be.
One way to make better code is to use the 'strict' pragma at the beginning
of your script, something like this.
use strict;
That tells the compiler to enforce three kinds of restrictions. First is
'strict vars', which means that when you use a variable, it needs to be
declared in some way. Usually, this means that you use my() variables, but
you can also use any global package variable which is fully qualified or
which has been declared already, such as with 'use vars'. This makes it
far less likely that you'll accidentally misspell a variable name, or use
a global variable from another part of your code.
The second form of strict is 'strict subs' which is slightly misnamed. It
turns off "Perl poetry mode", in which an unrecognized bareword is seen as
a string. For example, suppose you write this.
$foo = bar;
This is valid Perl code, but it means something ambiguous! If you have a
sub called &bar, this calls it, and $foo gets the return value. If not,
this assigns 'bar' to $foo. This becomes a problem if, (among other
possible problems) your maintenance programmer adds a sub called &bar to
your script, so 'strict subs' outlaws this when &bar isn't already defined
(or declared, such as with 'use subs'). Instead, you can do one of these
non-ambiguous forms.
$foo = 'bar'; # It's a string
$foo = &bar; # It's a sub
$foo = bar(); # That's a sub, too.
The final stricture is 'strict refs'. That means that you can't use soft
references in your code, which may happen by accident. Since a soft
reference can potentially alter any global variable, they can be
dangerous; many programming languages don't allow them for that reason.
(For more info on both kinds of references, see the perlref(1) manpage,
which doesn't like calling them "soft" references.)
I recommend that any script which is longer than about a dozen lines (or
which will grow to be long) should use 'use strict' to help Perl to help
you catch errors.
But suppose you discover that a stricture is too restrictive? You can
countermand the pragma in an inner block, like this.
sub somesub {
no strict 'refs'; # For the rest of this sub, unless
# we 'use strict' again, we're allowed
# to use soft references.
...
}
So, your maintenance programmer can easily see where you may have had to
break the rules. :-)
It's not always easy to retroactively turn on strictness, so it's
something to put in from the beginning whenever possible. But if you find
yourself maintaining a script which wasn't written with strictness in
mind, you could add strictness one subroutine at a time, for example.
For those looking to the future, 'use strict' will give only the three
current strictures by default. When new strictures are added, you'll need
to ask for them in one way or another, so your current code shouldn't
break.
For more details, check out the manpage for strict.pm, which you should be
able to read with the command 'perldoc strict'. Also, the manpages for
vars.pm and subs.pm could be helpful.
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: 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 1093
**************************************