[6285] in Perl-Users-Digest
Perl-Users Digest, Issue: 907 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 6 17:28:25 1997
Date: Thu, 6 Feb 97 14:00:24 -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, 6 Feb 1997 Volume: 7 Number: 907
Today's topics:
-l behaving strangely and differently with debugger (Peter Scott)
Adduser (Anthony D'andrade)
Re: Adduser (brian d foy)
Re: Cgi script help, please! (brian d foy)
Re: Cgi script help, please! <rootbeer@teleport.com>
Re: Cgi script help, please! (Nathan V. Patwardhan)
Re: CGI.pm dynamic tables? <tchrist@mox.perl.com>
Re: Confusion about unpack (M.J.T. Guy)
Re: Decrementing a field in a flat data-base?????????? <nmljn@wombat.staff.ichange.com>
Re: Decrementing a field in a flat data-base?????????? (Nathan V. Patwardhan)
Re: Empty contents of a file without deleting it (Craig Berry)
Re: Frivilous request for new Perl function <merlyn@stonehenge.com>
Re: function arguments (Dave Thomas)
Re: function arguments <rootbeer@teleport.com>
Re: How to do this using perl? (Abigail)
Re: How to peek at next line of STDIN? (repost) <merlyn@stonehenge.com>
How to run programs asynchronously on NT <tejo_carlos@jpmorgan.com>
Re: insecure dependency in (<*>,<*>) (M.J.T. Guy)
Re: Looking for a Win32 pm module for paging <brobbins@pls.com>
perl tcl extension (Leon Chism)
Re: print 'undef' in an elegant way ? (E.)
Re: print 'undef' in an elegant way ? <zenin@best.com>
Re: print 'undef' in an elegant way ? (Charles DeRykus)
Redirection prob w. NS 3.0 <dpratte@worldnet.att.net>
Re: Redirection prob w. NS 3.0 (brian d foy)
REQ: freopen (Bernhard Wagner)
Script to Find-replace (Keven D. Ficken)
Sort on third element of an Multi-Dim Array <thorsoft@cdsnet.net>
Re: Sort on third element of an Multi-Dim Array (Nathan V. Patwardhan)
testing - please ignore <twolf@att.com>
Thanks for help.... <sgrover@elizacorp.com>
Re: Trimming Dollar Value <tchrist@mox.perl.com>
Re: Using exec-Why won't this work? ("John Dallman")
Who can write a perl-search script for our company? (Miggy)
Re: Word wrap script - it works! (Randy J. Ray)
Write help please (John W. Komp)
Re: Write help please (Nathan V. Patwardhan)
Re: Write help please (brian d foy)
Re: Write help please <jander@jander.com>
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Feb 1997 19:14:12 GMT
From: pjscott@euclid.jpl.nasa.gov (Peter Scott)
Subject: -l behaving strangely and differently with debugger
Message-Id: <5ddai4$7lt@netline-fddi.jpl.nasa.gov>
Running the following script:
#!/usr/local/bin/perl -wnl
if (/,/) {
print "foo";
} else {
print "bar";
}
produces:
euclid% echo "cat,dog" | /tmp/foo
bar,bar,euclid%
Running it under the debugger gives:
Bad free() ignored at /usr/ets/lib/perl5/perl5db.pl line 890.
DB::save called at /usr/ets/lib/perl5/perl5db.pl line 272
DB::DB called at /tmp/foo line 0
Cmain::(/tmp/foo:0): BEGIN { require 'perl5db.pl' };LINE: while (<>) {chomp;
DB<1> n
main::(/tmp/foo:3): if (/,/) {
DB<1> n
main::(/tmp/foo:4): print "foo";
DB<1> n
foo
euclid% !!
I give up. Can someone make sense of this for me please?
Perl identity:
This is perl, version 5.003 with EMBED
built under sunos at Oct 4 1996 10:44:46
+ suidperl security patch
--
This is news. This is your | Peter Scott, NASA/JPL/Caltech
brain on news. Any questions? | (Peter.J.Scott@jpl.nasa.gov)
Disclaimer: These comments are the personal opinions of the author, and
have not been adopted, authorized, ratified, or approved by JPL.
------------------------------
Date: Thu, 06 Feb 97 18:29:15 GMT
From: admin@visinet.ca (Anthony D'andrade)
Subject: Adduser
Message-Id: <5dd8l3$smj@usenet81.supernews.com>
How can I use System commands such as "adduser" in my perl scripts. I think
i have to use the package fnctl but I am not sure. Can you please give my an
example using adduser in a script. Ideally I want to add users to my system
through a CGI script.
------------------------------
Date: Wed, 05 Feb 1997 16:04:48 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Adduser
Message-Id: <comdog-0502971604480001@nntp.netcruiser>
In article <5dd8l3$smj@usenet81.supernews.com>, admin@visinet.ca (Anthony
D'andrade) wrote:
> How can I use System commands such as "adduser" in my perl scripts. I think
> i have to use the package fnctl but I am not sure. Can you please give my an
> example using adduser in a script. Ideally I want to add users to my system
> through a CGI script.
1. look into system().
system "adduser", "options";
2. reconsider what you want to do. it requires a suid root script that
will potentially allow anyone to easily break into your system by accessing
the script. don't be fooled into thinking password protected web pages
are anywhere near secure.
3. if you want an easier interface to adduser, see what tools your OS
already has for sysadmin-ing, or write yourself a nice Tcl/tk thing and
use X windows.
4. if you still want to do this despite the HUGE risks, at least use
taint checking (look in the index of the Camel[1] ), and check all of
your input before you send it to a shell.
some things should be not be easy to do so that they are not easily
done. :)
[1] $blue_camel = q/Programming Perl, Larry Wall, Tom Christensen,
& Randal L. Schwartz, ISBN 1-56592-149-6./
--
brian d foy <URL:http://computerdog.com>
unsolicited commercial email is not appreciated
------------------------------
Date: Wed, 05 Feb 1997 13:10:47 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Cgi script help, please!
Message-Id: <comdog-0502971310470001@nntp.netcruiser>
In article <32F9DE09.155A@grasberg.se>, magnus@grasberg.se wrote:
> I want to know how to make a kind of search and replace from within a
> pearl script................
*ahem* "Perl"
> The search should be in a external text file...????
the basic idea:
*open the file
*read in the data
*close the file
*use s/// appropriately
*open the file for writing (truncating to zero length)
*write the data to file
*close the file
#!/usr/bin/perl
#may need to change to suit your needs
open(FILE, "foo.txt") or handle_error "$!\n";
@lines = <FILE>;
$lines = join '', @lines;
close(FILE);
$lines =~ s#Cgi\s+script#Perl\s+search\s+and\s+replace#sgi;
open(FILE, ">foo.txt") or handle_error "$!\n";
print FILE $data;
close(FILE);
__END__
--
brian d foy <URL:http://computerdog.com>
unsolicited commercial email is not appreciated
------------------------------
Date: Thu, 6 Feb 1997 10:13:38 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Magnus Grdsberg <magnus@grasberg.se>
Subject: Re: Cgi script help, please!
Message-Id: <Pine.GSO.3.95.970206100913.14089J-100000@linda.teleport.com>
On Thu, 6 Feb 1997, Magnus Gr=E4sberg wrote:
> I want to know how to make a kind of search and replace from within a
> pearl script................
>=20
> The search should be in a external text file...????
It's usually good to use Perl's $^I variable to let you edit a text file
"in place" using @ARGV, <>, and print. These are all documented in the man
pages, especially perlfunc, perlvar, and perlop. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 6 Feb 1997 17:56:34 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Cgi script help, please!
Message-Id: <5dd60i$kfv@fridge-nf0.shore.net>
Magnus Grdsberg (magnus@grasberg.se) wrote:
: I want to know how to make a kind of search and replace from within a
: pearl script................
What's pearl?
: The search should be in a external text file...????
Your purposes would be better served in an appropriate newsgroup,
like comp.infosystems.www.authoring.cgi, where your question has
already been answered. You might also check the archives for the
above newsgroup at www.dejanews.com. In the words of Tom P:
"Good Luck!"
--
Nathan V. Patwardhan
nvp@shore.net
"Hello, good citizen. I'm Batman.
Would you like to be my assistant?
Would you like to ride with me?
Would you like to ride with Batman?"
------------------------------
Date: 6 Feb 1997 18:35:52 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: CGI.pm dynamic tables?
Message-Id: <5dd8a8$1k8$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, jacob@bitsrfr.cnd.hp.com (Jacob Miner) writes:
: Is there any way to create a dynamic table using the CGI.pm
:module, and it's syntax?
A: It's not that it's a mortal sin, it's just that its spelling sucks.
C: Whose spelling?
A: Its spelling.
C: It's spelling what?
A: No, just its spelling.
C: What's it spelling?
A: Spelling? It's not spelling.
C: YOU SAID IT WAS SPELLING SUCKS!
A: No, I never said it was spelling anything.
I merely remarked that its spelling sucks.
C: There! You mentioned "it's" again.
A: No I didn't, I comment upon its spelling. It doesn't even
have an again, so I certainly didn't mention its again.
Anyeay, you're the one who said it's spelling.
C: There, you did so mention "it's" again. And I wish you would tell
me what it's spelling.
A: Who's spelling anything?
C: I don't even know whose spelling we're using! Your spelling!
A: I'm not spelling. I'm Abbott. You're spelling. You're the one
who's spelling "sucks", and whose spelling sucks. As I said,
we're talking about something important: your spelling.
C: I thought *it* was spelling, not me. I thought I was Costello;
you mean now I'm Spelling?
A: You're spelling too, but poorly. The simple rule for keeping track
of possessives versus contractions is that here it's its own worst
enemy, there they're their own best friends, and everywhere since
days of yore, you're your own toughest proofreader.
C: I give up already. Can't we please just speak Perl?
This has been a joke of the emergency humor network, sponsored by
Apostrophes Anonymous. Had this been an actual program, you would have
seen a pound-bang line.
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
"It is easier to port a shell than a shell script."
--Larry Wall
------------------------------
Date: 6 Feb 1997 18:08:48 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Confusion about unpack
Message-Id: <5dd6ng$2k2@lyra.csx.cam.ac.uk>
In article <5c82aq$5a9@netaxs.com>, Joel Coltoff <joel@wmi0.wmi.com> wrote:
>I've got a file that when I run "od -X | head -1" gives
>
> 0000000 93000900 7793b132 520d0000 88000000
>
>I read the first 512 bytes read(FILE, $head, 512);
>
>and then I do $magicNumber = unpack( "I", $head);
>
>and $magicNumber is -1828714240 instead of 2466253056. This works
>when I do $magicNumber = unpack( "L", $head);
There were bugs with the handling of hex numbers with the 2**31 bit set
in the earlier versions of perl5. These are mended in the latest
developer version (perl5.003_25) and will therefore be fixed in perl5.004.
Mike Guy
------------------------------
Date: 06 Feb 1997 15:12:10 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: Decrementing a field in a flat data-base??????????
Message-Id: <w109151k82t.fsf@wombat.staff.ichange.com>
nvp@shore.net (Nathan V. Patwardhan) writes:
> You might try Sprite.pm, which handles flat-file database files in a
> sql-like fashion! Available at a CPAN near you!
Erm, not via the multiplexor. Perhaps it hasn't propagated throughout
the Network yet? I tried to get it with
http://www.perl.com/CPAN/modules/by-module/ and found nothing.
In the meantime, any idea where *else* one could download Sprite.pm?
Cheers,
Laird
--
Laird J. Nelson (617) 252-5147
Systems Engineer 25 First Street
Nets, Inc. Cambridge, MA 02141
nmljn@wombat.staff.ichange.com http://www.netsinc.com/
------------------------------
Date: 6 Feb 1997 20:57:04 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Decrementing a field in a flat data-base??????????
Message-Id: <5ddgj0$4a3@fridge-nf0.shore.net>
nelson (nmljn@wombat.staff.ichange.com) wrote:
: In the meantime, any idea where *else* one could download Sprite.pm?
Check yahoo, try archie:
Here you go!
ftp://ftp.cdrom.com/pub/perl/CPAN/authors/id/SHGUN/Sprite-3.1.tar.gz
Have a great day!
--
Nathan V. Patwardhan
nvp@shore.net
"Hello, good citizen. I'm Batman.
Would you like to be my assistant?
Would you like to ride with me?
Would you like to ride with Batman?"
------------------------------
Date: 6 Feb 1997 20:15:54 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Empty contents of a file without deleting it
Message-Id: <5dde5q$6om$1@marina.cinenet.net>
Chris Schoenfeld (chris@ixlabs.com) wrote:
: What's the most desirable method of emptying a file's contents without
: deleting it (e.g. system(cp /dev/null file)) in Perl?
If you don't mind creating the file if it wasn't there previously, then
open(DOOMED, ">say.goodbye") or die("Can't open doomed file: $!");
close(DOOMED);
The victim file will now exist and be zero bytes long.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 06 Feb 1997 14:25:35 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: chris@ixlabs.com
Subject: Re: Frivilous request for new Perl function
Message-Id: <8cybd1ocds.fsf@gadget.cscaper.com>
>>>>> "Chris" == Chris Schoenfeld <chris@ixlabs.com> writes:
Chris> Hi,
Chris> It would be great, and a little more Perlish, if there were a chop that
Chris> returned the truncated string, rather than what was chopped off. It
Chris> could be called chew, or perhaps masticate.
Chris> That way you could plop the chew call right in the print LIST. No Perl
Chris> programmer wants a sorry line like plain 'ol:
Chris> chop $scaler;
sub chew {
substr($_[0],0,-1);
}
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 571 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 6 Feb 1997 18:58:15 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: function arguments
Message-Id: <slrn5fka9t.t3m.dave@fast.thomases.com>
On Thu, 06 Feb 1997 17:43:04 +0000, Simon Williams <williams@mod5.ag.rl.ac.uk> wrote:
> ############### MAIN ##############
>
> $str="foo";
>
> print " $str\n";
> $return = &func($str);
> print " $str\n";
>
>
> ############### FUNC ##############
>
> sub func {
>
> local ($str);
> $str="bar";
>
> print " $str\n";
>
> $_[0]=$str;
>
> }
> ###################################
What version of Perl are you using. In 5.003_11, your example produces
foo
bar
bar
Which is what you expected.
> Isn't there some way of isolating *all* variables in *each*
> function from all variables in all other functions including
> main?
Again, in Perl 5, you should look at using 'my' instead of 'local' - it
gives you a close approximation of true lexical scoping:
my $str = 'foo';
print "$str\n";
{
my $str = 'bar';
print "$str\n";
}
print "$str\n";
produces 'foo - bar - foo'
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Thu, 6 Feb 1997 11:35:36 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Simon Williams <williams@mod5.ag.rl.ac.uk>
Subject: Re: function arguments
Message-Id: <Pine.GSO.3.95.970206112535.490C-100000@linda.teleport.com>
On Thu, 6 Feb 1997, Simon Williams wrote:
> I'm used to FORTRAN and similar languages, where variables passed to a
> subroutine are completely local to that subroutine.
> sub func {
>
> local ($str);
> $str="bar";
>
> print " $str\n";
>
> $_[0]=$str;
>
> }
First of all, since Perl isn't FORTRAN, it's customary and desirable to
indent loops to show structure. :-) Also, unless you have a specific
reason to use local(), you should probably use my() instead. (The details
are in perlsub(1).)
Most importantly, though, you're assigning to an element of @_ . There's
nothing wrong with that so long as you realize that each element of @_ is
aliased to the actual parameter. That is, your sub converts its (first)
argument to "bar". If you call this sub as &func($foo), $foo will be "bar"
afterwards.
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Thu, 6 Feb 1997 18:44:52 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: How to do this using perl?
Message-Id: <E572qs.Hyr@nonexistent.com>
On 6 Feb 1997 13:54:36 GMT, Tom Christiansen wrote in comp.lang.perl.misc:
++ [courtesy cc of this posting sent to cited author via email]
++
++ In comp.lang.perl.misc,
++ abigail@ny.fnx.com writes:
++ :++ @elements = split( m#/#, "c:/speech/work" );
++ :++ Yes, the real slashes work just fine in pathnames.
++ :++
++ :
++ :What's the problem with:
++ :
++ : @data = split /\\/, 'cl:\speech\work';
++ :Seems to work for me.
++
++ Try passing that path in as a regexp:
++
++ $path = 'cl:\speech\work';
++ if ($file =~ /^$path/) { ... }
++
++ I'm just really tired all the confusion and brokenness caused by the
++ idiotic backslashes as a separator when all the world (well, C and Unix
++ and all the derivatives of these) uses them as escape characters. I'm
++ tired of seeing "\foo\bar\nooobie" from people who don't understand why
++ it doesn't work.
++
++ So I espouse using *nothing* but slashes for the separater. Ever. It
++ works on the dumb systems, too, so there's no need to get all confused
++ by using the stoopid backslashes in a way that's bound to haunt you.
True, true, but the question was not about using \'s in the regex
itself. Of course, if you can avoid using \ as a path separator,
you should, but often Perl programs run on data which isn't under
the control of the programmer.
Abigail
------------------------------
Date: 06 Feb 1997 14:20:50 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: htchapma@vela.acs.oakland.edu (H. Todd Chapman)
Subject: Re: How to peek at next line of STDIN? (repost)
Message-Id: <8c20atpr65.fsf@gadget.cscaper.com>
>>>>> "H" == H Todd Chapman <htchapma@vela.acs.oakland.edu> writes:
H> I searched Dejanews, the FAQ, and Tom's EYEWTK???? and came up with one
H> post with the same question but no respones.
H> The question is:
H> How can I peek at the next line from <> without making it inacessible
H> from the subsequent function call via <> ?
H> In other words I want to use the angle operator to read in a line and
H> then put that line back so I can use the angle operator to read it in
H> again. How can this effect be achieved?
It can't be done transparently, but something like this should work:
package Diamond;
my @stack = ();
sub read {
@stack ? pop @stack : <>;
}
sub read_under {
$_ = &read;
defined $_;
}
sub unread {
push @stack, shift;
}
package main;
while (Diamond::read_under) {
...
# get an additional line:
$_ .= Diamond::read;
...
# oops, need to unread:
Diamond::unread $_; next;
}
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 571 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 06 Feb 1997 12:46:29 -0500
From: Carlos Tejo <tejo_carlos@jpmorgan.com>
Subject: How to run programs asynchronously on NT
Message-Id: <32FA18F5.515@jpmorgan.com>
Hi,
Thanks in advance for anyone who can enlighten me on how to
run programs or subroutines asynchronously in NT (i.e. not wait
for one process to finish). Let me tell you what I've tried so far:
For example, (in pseudo-code)
$myprogram1="C:\\MYPROGRAM1.EXE arg1 arg2";
$myprogram2="C:\\MYPROGRAM2.EXE arg1 arg2";
$myprogram3="C:\\MYPROGRAM3.EXE arg1 arg2";
#tried the following:
$output1=`$myprogram1`;
$output2=`$myprogram2`; etc....
#the above waits for each program to finish before going to the next.
#tried the following:
use Win32::Process;
Win32::Process::Create($pobj,"$myprogram1","",0,DETACHED_PROCESS,".")||die
$!;
#which works if it is an EXE program you're calling with no arguments.
So, what's the best way to do it if you have an EXE with arguments or
want to spawn off a subroutine?
Thanks again,
Carlos
------------------------------
Date: 6 Feb 1997 18:17:54 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: insecure dependency in (<*>,<*>)
Message-Id: <5dd78i$2rn@lyra.csx.cam.ac.uk>
In article <6wwwsyg5nc.fsf@debretts.comp.vuw.ac.nz>,
Phil Abercrombie <phil@comp.vuw.ac.nz> wrote:
>
>Can anybody explain what is going on here? Or is it a perl bug?
>
>The following command gives me an error
>$ perl -T -e '$ENV{PATH}="/bin"; @a=(<*>,<*>)'
>Insecure dependency in piped open while running with -T switch at -e line 1.
>
>This seems bogus, seeing as the following is ok:
>$ perl -T -e '$ENV{PATH}="/bin"; @a=(@b=<*>, @c=<*>)
>
>
>Tested under 5.00320 on netbsd, and 5.00300 on digital unix, &
>solaris.
I get the same effect with the latest version (perl5.003_25) on SunOS.
Seems to be a bug. Copied to perlbug.
Mike Guy
------------------------------
Date: Thu, 06 Feb 1997 13:07:48 -0500
From: Bert Robbins <brobbins@pls.com>
To: "Nathan V. Patwardhan" <nvp@shore.net>
Subject: Re: Looking for a Win32 pm module for paging
Message-Id: <32FA1DF4.70DF@pls.com>
Nathan V. Patwardhan wrote:
>
> Nick Bonfiglio (nbonfigl@3do.com) wrote:
> : I'm looking for a perl5 Win32 pm module that will send alpha pages.
>
> Sorry for the question, but what's an alpha page? (I'm not kidding - I just
> don't know).
I assume that the "alpah page" is really an alpha-numeric pager.
I have one and it is the greatest thing since Perl. I use mine to
monitor systems and I am immediately notified when a problem arises.
I have a SkyTel pager with the e-mail option. I have a PIN # that
I can use in the address of a normal e-mail message and I will
receive the first 240 characters of the message. Pages can also
be sent if I connect to a special number at SkyTel, via modem,
and issue the page that way.
--
Bert Robbins
------------------------------
Date: 6 Feb 1997 15:22:55 -0600
From: lchism@MCS.COM (Leon Chism)
Subject: perl tcl extension
Message-Id: <5ddi3f$ro1$1@Mars.mcs.net>
can someone tell me where to find the perl
tcl extension?
Is there an extension specifically for expect ?
thanks
------------------------------
Date: 6 Feb 1997 12:50:02 -0700
From: erisson@kallisti.sw-tech.com (E.)
Subject: Re: print 'undef' in an elegant way ?
Message-Id: <slrn5fkddp.3qb.erisson@kallisti.sw-tech.com>
Helmut Jarausch <jarausch@numa1.igpm.rwth-aachen.de> wrote:
>
> My is solution is ugly - isn't it?
>
> print "Id = @{[(defined($MyV->{Id}) ? $MyV->{Id} : \"undef\")]}\n";
Unless I'm totally misunderstanding the question...
#!/usr/bin/perl -w
$value="hi";
print ($value || "undef");
print "\n";
$novalue=undef();
print ($novalue || "undef");
print "\n";
-E
--
PGP Public Key Fingerprint: BE FC C5 FB 30 47 E5 5C DC DF C3 C0 AD A5 27 17
Homepage: http://www.primenet.com/~fnargle/erisson/ PGP Key available here
"Every day is like burning paper." --Slimebard
"You have *not* 'plonked' me!" --Mario1
------------------------------
Date: 6 Feb 1997 20:42:42 GMT
From: Zenin <zenin@best.com>
Subject: Re: print 'undef' in an elegant way ?
Message-Id: <5ddfo2$2vo$2@nntp2.ba.best.com>
E. <erisson@kallisti.sw-tech.com> wrote:
>snip<
: Unless I'm totally misunderstanding the question...
: #!/usr/bin/perl -w
: $value="hi";
: print ($value || "undef");
: print "\n";
This will fail if $value is '0' etc, or a null string ''. -They
will both print 'undef'. You have to test to see if it is
defined or not.
--
Zenin Programing Consultant
Zenin@Best.com Perl, JavaScript, Web Graphic Design
http://www.best.com/~zenin/ Just another Perl hacker
Spelling mistakes? Their couldn't be. -My modem is error correcting.
------------------------------
Date: Thu, 6 Feb 1997 19:33:41 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: print 'undef' in an elegant way ?
Message-Id: <E57505.3q6@bcstec.ca.boeing.com>
In article <5dcvl2$lab$1@news.rwth-aachen.de>,
Helmut Jarausch <jarausch@numa1.igpm.rwth-aachen.de> wrote:
> Hi,
>
> can anybody suggest an elegant method to print an undefined value
> when option 'w' is in effect.
>
> My is solution is ugly - isn't it?
>
> print "Id = @{[(defined($MyV->{Id}) ? $MyV->{Id} : \"undef\")]}\n";
>
Scrap the block eval perhaps...?
print "Id = ", $MyV->{Id} ? $MyV->{Id} : "undef", "\n";
HTH,
--
Charles DeRykus
ced@carios2.ca.boeing.com
------------------------------
Date: Thu, 06 Feb 1997 14:18:34 -0500
From: "Daniel A. Pratte" <dpratte@worldnet.att.net>
Subject: Redirection prob w. NS 3.0
Message-Id: <32FA2E8A.2500@worldnet.att.net>
This may be an inappropriate post to this newsgroup, but I can't get
satisfaction anywhere else.
Using NS 3.0 with an MS IIS server.
I have a PERL script as follows:
#!/usr/local/bin/perl
print "HTTP/1.0 200 OK\n";
print "Location: /restaurants/louisville.htm", "\n\n";
Redirection works great with IE 3.0 (page 'louisville.htm' is displayed)
but with Navigator 3.0, I get a "Document contains no data" message.
Any ideas?
--
Daniel A. Pratte, Louisville, KY USA
76616.2164@compuserve.com
dpratte@worldnet.att.net
------------------------------
Date: Wed, 05 Feb 1997 16:29:51 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Redirection prob w. NS 3.0
Message-Id: <comdog-0502971629510001@nntp.netcruiser>
In article <32FA2E8A.2500@worldnet.att.net>, dpratte@worldnet.att.net wrote:
> This may be an inappropriate post to this newsgroup, but I can't get
> satisfaction anywhere else.
what, my response in comp.infosystems.www.authoring.cgi and email
wasn't good enough for you? it had a bibliography and everything.
damn this is discouraging. i think that there is a bunch of us over
there doing a good job, then you go off and tell the perl group this :(
> Using NS 3.0 with an MS IIS server.
two strikes so far
> I have a PERL script as follows:
>
> #!/usr/local/bin/perl
> print "HTTP/1.0 200 OK\n";
strike 3, you're out.
> print "Location: /restaurants/louisville.htm", "\n\n";
> Redirection works great with IE 3.0 (page 'louisville.htm' is displayed)
> but with Navigator 3.0, I get a "Document contains no data" message.
>
> Any ideas?
yeah, read the HTTP spec (section 10.3)[1] and keep the CGI questions in
the right place. while you wait patiently for someone to answer your
question (we're not the 24 hour CGI Help Hotline you know, we have real
jobs that expect us to do other things as well), you can read the various
FAQs[2]
[1]
RFC 2068 - Hypertext Transfer Protocol -- HTTP/1.1
<URL:http://www.ics.uci.edu/pub/ietf/http/rfc2068.txt>
<URL:http://www.cis.ohio-state.edu/htbin/rfc/rfc2068.html>
[2]
<URL:http://www.perl.com/perl/faq/perl-cgi-faq.html>
<URL:http://www.perl.com/perl/faq/idiots-guide.html>
<URL:http://www3.pair.com/webthing/docs/cgi/faqs/cgifaq.shtml>
<URL:http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html>
--
brian d foy <URL:http://computerdog.com>
unsolicited commercial email is not appreciated
------------------------------
Date: 6 Feb 1997 19:03:12 GMT
From: bwagner@claude (Bernhard Wagner)
Subject: REQ: freopen
Message-Id: <5dd9tg$bru@bioko.ifi.unizh.ch>
Hello
How would you formulate freopen (UNIX/C) in Perl ?
With freopen I can grab stdout/stderr or other filehandles temporarily
and map them to other filehandles, so I can take the output of a program
and save it into a file.
I can do this in Perl like this (separate process):
open(INPUT,"ls|");
while(<INPUT>){
...
}
For external perl-programs (but within same process):
my $tmp="/tmp/blabla$$";
open(SAVEOUT,">$tmp");
my $oldfh= select STDOUT;
select SAVEOUT;
do "externalProgram.pl";
close(SAVEOUT);
select $oldfh;
open(INPUT,$tmp);
while(<INPUT>){
...
}
unlink $tmp;
What I don't like about the second solution is, that I have to use a
temporary file to save the results.
How can I accomplish this WITHOUT the temporary file?
(BTW... I wouldn't know how to do it in C with freopen, either...)
Thank you
Bernhard
--
Bernhard Wagner, MultiMedia Laboratory bwagner@ifi.unizh.ch
University of Zurich VOICE +41-1-257 45 69
Inst.f.Informatik, Winterthurerstr. 190 FAX +41-1-363 00 35
CH-8057 Zurich, Switzerland http://www.ifi.unizh.ch/staff/bwagner.html
------------------------------
Date: Thu, 06 Feb 1997 21:09:51 GMT
From: ficken@mobot.org (Keven D. Ficken)
Subject: Script to Find-replace
Message-Id: <5ddhhq$pp0$1@newsin-1.starnet.net>
I am looking for a script that will search through all of the files in
a directory tree and replace a specified character string with another
string. I have been unable to make heads or tails of the CPAN to find
one. I am hoping someone can direct me to such a script.
Thanks,
Keven
ficken@mobot.org
------------------------------
Date: Thu, 06 Feb 1997 10:16:58 -0800
From: Rick Thornley <thorsoft@cdsnet.net>
Subject: Sort on third element of an Multi-Dim Array
Message-Id: <32FA201A.1C24@cdsnet.net>
I have a multi-dimensional array of strings as follows:
@Page = (
[ "billpearl", "www.billpearl.com", "Bill
Pearl Enterprises, Inc." ],
[ "cbass", "www.cbass.com", "Clarence
Bass: Bodybuilding & Fitness Home Page" ],
[ "sportstrength", "www.sportstrength.com",
"Dr. Fred Hatfield's SportStrength Training Equipment Company" ],
[ "bleak", "www.magg.net/~bleak/", "Doris
Barrilleaux on Bodybuilding and Fitness" ],
[ "fredhome", "www.ipf.com/fredhome.htm",
"Training with Dr. Fred Hatfield - Dr. Squat" ],
[ "sportsci", "www.sportsci.org",
"Sportscience" ],
[ "ironpages", "www.nvm.com/ironpages/irontop.html", "The
Ironpages" ],
[ "ginamariehall", "www.dca.net/~ducks/ginamariehall.html",
"Gina Marie Hall's Bodybuilding Web Page" ],
[ "thpage", "www.concentric.net/~muscle/THPAGE.HTM", "The
Truly Huge Page" ],
[ "issa-usa", "www.issa-usa.com", "ISSA -
International Sports Sciences Association" ],
[ "ironmanmagazine", "www.ironmanmagazine.com",
"IRONMAN Magazine" ],
);
I need to print the third element in sorted order. Could someone provide
an example of how to sort this array on the third element and then print
the third element?
Thanks,
Rick
------------------------------
Date: 6 Feb 1997 19:18:21 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Sort on third element of an Multi-Dim Array
Message-Id: <5ddapt$qj2@fridge-nf0.shore.net>
Rick Thornley (thorsoft@cdsnet.net) wrote:
: I need to print the third element in sorted order. Could someone provide
: an example of how to sort this array on the third element and then print
: the third element?
Ahh, so glad you asked. Someone posted a solution to this problem about
a week ago, and perhaps even yesterday. :-) Please search www.dejanews.com
for comp.lang.perl.misc sort element and you'll be golden!
--
Nathan V. Patwardhan
nvp@shore.net
"Hello, good citizen. I'm Batman.
Would you like to be my assistant?
Would you like to ride with me?
Would you like to ride with Batman?"
------------------------------
Date: Mon, 03 Feb 1997 10:53:13 -0500
From: Thomas Wolf <twolf@att.com>
Subject: testing - please ignore
Message-Id: <32F609E9.74F3@att.com>
Sorry for posting to a technical group - I'm trying to figure out
why my posts beyond the firewall don't get posted!
Thnx for your patience,
tom
--
+--------------------------------+ If Life Is Suffering, I've fulfilled
| Thomas Wolf twolf@att.com | my purpose by installing MS Windows.
| AT&T Corp. (908) 957-3474 |
+--------------------------------+ ...my opinions are mine alone...
------------------------------
Date: 6 Feb 1997 19:07:23 GMT
From: "Samir Grover" <sgrover@elizacorp.com>
Subject: Thanks for help....
Message-Id: <01bc1461$93e23530$6b00000a@e15>
Dear helpers,
Thanks a lot for all of your responses to my simple queries. I just
finished writing
300 lines perl script to process a command file having a dataflow network
of signal processes. Though, it is slow at this moment, but it does the job
correctly.
Thanks for all responses.
Regards,
Samir
------------------------------
Date: 6 Feb 1997 19:00:25 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Trimming Dollar Value
Message-Id: <5dd9o9$25h$1@csnews.cs.colorado.edu>
I wrote:
:or even more creatively this:
: $it = '3.4405';
: $it =~ s/(\...).*//;
Whoops.
$it =~ s/(\...).*/$1/;
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
"People think it must be fun to be a super genius, but they don't
realize how hard it is to put up with all the idiots in the world."
--Calvin
------------------------------
Date: Thu, 6 Feb 1997 21:25:23 GMT
From: jgd@cix.compulink.co.uk ("John Dallman")
Subject: Re: Using exec-Why won't this work?
Message-Id: <E57A6C.22t@cix.compulink.co.uk>
"D.M. Johnson" <ez045864@peseta.ucdavis.edu> wrote:
> I am using exec to run a spell function.
Use system() not exec(). Both run another program, but exec also
terminates your perl script.
John Dallman, jgd@cix.co.uk. A micro-FAQ on things I keep getting asked:
#!perl is at ftp://.../CPAN/ports/msdos/tips-tricks/hbp_403.zip, BigPerl
for MS-DOS can be found in CPAN via http://www.perl.com, Perl for NT/Win
95 can be found at http://www.activeware.com, with an excellent FAQ file
at http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html and
no, I don't have the slightest idea what's wrong with your CGI script.
------------------------------
Date: Thu, 06 Feb 1997 18:31:22 GMT
From: WWW@pang.de (Miggy)
Subject: Who can write a perl-search script for our company?
Message-Id: <5dd8au$ftb@news1.Belgium.EU.net>
Hi,
I have no experience in perl programming whatsoever. I'm doin pretty
well with HTML so i'm looking for a partner who can write the perl
part. Situation :
We have a Txt based database file from our AS/400. This file contains
2-10 Mb data last - minute-travel- offers. We want a prgm that
searches that TXT file for the offers after the user has given an
number of searchcriteria.
I have a commercial offer but I think the price is *exagerated*.
So if somebody is interested E-mail me
Miguel.Major@ping.be
------------------------------
Date: 06 Feb 1997 12:18:08 -0700
From: rjray@tremere.ecte.uswc.uswest.com (Randy J. Ray)
Subject: Re: Word wrap script - it works!
Message-Id: <uowohdxg2vj.fsf@tremere.ecte.uswc.uswest.com>
geoff.cox@dial.pipex.com (Geoff Cox) writes:
> Can anyone tell me how to use the Wrap.pm instead of my re-invention
> of the proverbial wheel??!
The man page for Text::Wrap is pretty clear. But in a nutshell:
use Text::Wrap;
$Text::Wrap::columns = 79; # Allow for the CR
@lines = wrap($indent, $left, $text);
$indent is how much you want the first line indented, $left is the left
margin. You'll get back a list of lines that are *not* CR-terminated.
(before this module, I had about 4 variations of this wheel in my legacy code)
Randy
--
===============================================================================
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS Phone: (303)595-2869
Denver, CO rjray@uswest.com
"It's not denial. I'm just very selective about the reality I accept." --Calvin
===============================================================================
------------------------------
Date: 6 Feb 1997 19:20:15 GMT
From: jk0101@medtronic.COM (John W. Komp)
Subject: Write help please
Message-Id: <5ddatf$5sh@gazette.medtronic.com>
I'm confused at why the following does not execute as I would expect
(ie why didn't the first write statement do anything?):
#!/usr/local/bin/perl
$outfilename = ">tmp.rpt";
open(OUTFILE,$outfilename);
print OUTFILE "Before first\n";
$~ = START_STRING;
write OUTFILE;
print OUTFILE "After first\n";
&BuildMain;
close(OUTFILE);
#################################################################################################3
sub BuildMain
{
print OUTFILE "Before subroutine write \n";
$~ = START_STRING;
write OUTFILE;
$~ = STDOUT;
print OUTFILE "After subroutine write \n";
$stubs = "";
}
format START_STRING =
{*********** A String ***********}
.
-----------------------------------------------------------------------
Results in:
Before first
After first
Before subroutine write
{*********** A String ***********}
After subroutine write
-----------------------------------------------------------------------
Thanks,
-John
--
****************************************************
This morning I shot six holes in my freezer
I think I've got cabin fever
Somebody sound the alarm
- J. Buffett
****************************************************
------------------------------
Date: 6 Feb 1997 21:00:12 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Write help please
Message-Id: <5ddgos$4a3@fridge-nf0.shore.net>
John W. Komp (jk0101@medtronic.COM) wrote:
: I'm confused at why the following does not execute as I would expect
: (ie why didn't the first write statement do anything?):
: $outfilename = ">tmp.rpt";
: open(OUTFILE,$outfilename);
Error checking? No? Why not?
Try:
$outfilename = 'tmp.rpt';
open(OUTFILE, ">$outfilename") || die("Hey!: $!\n");
[etc etc snipped]
--
Nathan V. Patwardhan
nvp@shore.net
"Hello, good citizen. I'm Batman.
Would you like to be my assistant?
Would you like to ride with me?
Would you like to ride with Batman?"
------------------------------
Date: Wed, 05 Feb 1997 16:17:29 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Write help please
Message-Id: <comdog-0502971617290001@nntp.netcruiser>
In article <5ddatf$5sh@gazette.medtronic.com>, jk0101@medtronic.COM (John
W. Komp) wrote:
> I'm confused at why the following does not execute as I would expect
> (ie why didn't the first write statement do anything?):
you need to select the output filehandle for write.
> #!/usr/local/bin/perl
>
> $outfilename = ">tmp.rpt";
> open(OUTFILE,$outfilename);
>
> print OUTFILE "Before first\n";
$old_handle = select(OUTFILE);
> $~ = START_STRING;
> write OUTFILE;
> print OUTFILE "After first\n";
select($old_handle);
__END__
if you really want to do that sort of thing, you may want to review
chapter 11 of the Llama book (Formats).
--
brian d foy <URL:http://computerdog.com>
unsolicited commercial email is not appreciated
------------------------------
Date: 06 Feb 1997 16:33:52 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Write help please
Message-Id: <u3np39hb.fsf@jander.com>
jk0101@medtronic.COM (John W. Komp) writes:
>
> I'm confused at why the following does not execute as I would expect
> (ie why didn't the first write statement do anything?):
>
> #!/usr/local/bin/perl
>
> $outfilename = ">tmp.rpt";
> open(OUTFILE,$outfilename);
>
> print OUTFILE "Before first\n";
> $~ = START_STRING;
> write OUTFILE;
> print OUTFILE "After first\n";
>
> &BuildMain;
>
> close(OUTFILE);
>
> #################################################################################################3
>
> sub BuildMain
> {
> print OUTFILE "Before subroutine write \n";
> $~ = START_STRING;
> write OUTFILE;
> $~ = STDOUT;
> print OUTFILE "After subroutine write \n";
>
> $stubs = "";
> }
>
> format START_STRING =
> {*********** A String ***********}
> .
>
>
> -----------------------------------------------------------------------
>
> Results in:
>
> Before first
> After first
> Before subroutine write
> {*********** A String ***********}
> After subroutine write
>
> -----------------------------------------------------------------------
A few observations:
1. I'll bet you didn't run it with -w specified :)
2. $~ affects the currently selected output filehandle, which happens
to be STDOUT, _not_ OUTFILE. Of course, the currently selected
filehandle will only be used if you use 'write' w/o explicitly
specifying a filehandle.
3. There _is_ no format statement defined for OUTFILE.
So, if you change your code as follows:
==============================================================
#!/usr/bin/perl -w
$outfilename = ">tmp.rpt";
open(OUTFILE,$outfilename);
select OUTFILE;
print OUTFILE "Before first\n";
$~ = START_STRING;
write;
print OUTFILE "After first\n";
&BuildMain;
close(OUTFILE);
sub BuildMain {
print OUTFILE "Before subroutine write \n";
$~ = START_STRING;
write;
$~ = STDOUT;
print OUTFILE "After subroutine write \n";
}
format START_STRING =
{*********** A String ***********}
.
==============================================================
You'll get the following output:
==============================================================
Before first
{*********** A String ***********}
After first
Before subroutine write
{*********** A String ***********}
After subroutine write
==============================================================
--
Jim Anderson jander@jander.com
PGP Public Key Fingerprint: 0A 1C BB 0A 65 E4 0F CD
4C 40 B1 0A 9A 32 68 44
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 V7 Issue 907
*************************************