[7785] in Perl-Users-Digest
Perl-Users Digest, Issue: 1410 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 4 22:17:05 1997
Date: Thu, 4 Dec 97 19: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, 4 Dec 1997 Volume: 8 Number: 1410
Today's topics:
Re: "man perlsec" tainting question <rootbeer@teleport.com>
Re: "uninitialized value" -- but it's initialized! <rootbeer@teleport.com>
[?]-Array (Max)
Re: [?]-Array (brian d foy)
Re: ^M removal (brian d foy)
Adding a directory to perl's include PATH at compile ti (Marc Merlin)
Re: Browser redirect in CGI? (Bob Stewart)
Re: File Editing <rootbeer@teleport.com>
Forced to use brain-dead perl 4 -- how do I accomplish (Eric)
Re: How about a new type of "OR" (lazy evaluation)? <ed@texas.net>
Re: How about a new type of "OR" (lazy evaluation)? <rootbeer@teleport.com>
Re: How do I print all but the first variable in an arr <tchrist@mox.perl.com>
Re: Joys of tainting <rootbeer@teleport.com>
Looking for DOS port of curseperl (Chris Reuter)
Re: Matching lowercase letter in regexp <rootbeer@teleport.com>
Re: Modifying file attributes (brian d foy)
Re: need the skinny on my() vs local() <ed@texas.net>
Re: Perl Contractors Wanted <rhodri@wildebst.demon.co.uk>
Perl on Win32 using Watcom v. 11 (Ben Coleman)
Re: Perl4 is not Y2K (was Re: Forced to use brain-dead (brian d foy)
Re: Q: multiline <rootbeer@teleport.com>
Re: Running the same program many times? <rootbeer@teleport.com>
Re: Setting default printer under Windows NT <rootbeer@teleport.com>
Re: Wrapping Text in Forms? (brian d foy)
Re: Writing to files (Tad McClellan)
Re: Writing to files (Tad McClellan)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 4 Dec 1997 15:31:35 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Rohan Oberoi <rohan.oberoiTAKETHISOUT@cornell.edu>
Subject: Re: "man perlsec" tainting question
Message-Id: <Pine.GSO.3.96.971204152926.4421Z-100000@usertest.teleport.com>
On 4 Dec 1997, Rohan Oberoi wrote:
> From "man perlsec":
>
> Any variable
> that is set within an expression that has previously
> referenced a tainted value also becomes tainted (even if it
> is logically impossible for the tainted value to influence
> the variable).
>
> I'd like a better understanding of what "within an expression" means
> here than I can get from the examples perlsec provides.
For that, you'll have to read the source. :-)
> I expected that "$ARGV[0] =~ m|(Hello)| and $foo = $1;" would
> taint $foo because of the presence of $ARGV[0]. Can anyone
> explain why it doesn't ?
Because $1 is never tainted. So, if that statement sets $foo, $foo can't
be tainted. 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: Thu, 4 Dec 1997 14:26:33 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Edward Henigin <ed@texas.net>
Subject: Re: "uninitialized value" -- but it's initialized!
Message-Id: <Pine.GSO.3.96.971204142330.4421P-100000@usertest.teleport.com>
On 4 Dec 1997, Edward Henigin wrote:
> Why does this script
>
> #!/usr/bin/perl -w
> use strict;
>
> sub A { "LLL" }
> sub B { "LCLL" }
> eval { sub C { A . B } };
> print "$@\n" if $@;
> print "c is: ",C,".\n";
>
> produce this output?
>
> $ ./script.pl
> Use of uninitialized value at ./dink.pl line 6.
> c is: LLLLCLL.
The eval doesn't have any code! (Maybe that shouldn't produce that error,
but I don't think it's what you intended.)
When perl compiles this line...
eval { sub C { A . B } };
...it compiles the sub first. That is, the sub is compiled at compile
time, not saved until runtime. So, at runtime, all that's left is this:
eval { };
...which makes the error message. The obvious solution is to simply
declare the sub, if that's what you want. 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: 4 Dec 1997 15:31:13 -0500
From: pyz@panix.com (Max)
Subject: [?]-Array
Message-Id: <6673uh$nk7@panix2.panix.com>
What are the maximum elements possible in an array?
Can I go over the number 256?
Thanks!
Max Pyziur
pyz@panix.com
------------------------------
Date: Thu, 04 Dec 1997 16:07:19 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: [?]-Array
Message-Id: <comdog-ya02408000R0412971607190001@news.panix.com>
In article <6673uh$nk7@panix2.panix.com>, pyz@panix.com (Max) wrote:
>What are the maximum elements possible in an array?
how much memory do you have? :)
>Can I go over the number 256?
sorta depends on what the array elements are. are they very large
files?
let's try a simple example:
#!/usr/bin/perl
@array = (0..32768);
print "$#array\n";
__END__
32768
i guess you can go over 256. are you having problems with a particular
peice of code?
--
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: Thu, 04 Dec 1997 18:05:56 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: ^M removal
Message-Id: <comdog-ya02408000R0412971805560001@news.panix.com>
In article <34872361.5A78@buxx.com>, Buxx <buxx@buxx.com> wrote:
>I need to strip out ^M characters from files I've copied from
>MSDOS files
>
>s/<?>//g;
s/\cM//g;
s/\r//g;
and so on. if this copy happens through FTP, try using text mode
which should do the conversion for you.
good luck :)
--
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: 4 Dec 1997 22:31:57 GMT
From: marc_merlin@magic.metawire.com (Marc Merlin)
Subject: Adding a directory to perl's include PATH at compile time.
Message-Id: <667b0t$31n@elmer.netapp.com>
I would like to have several "site-perls", namely:
/usr/local/lib/perlxxxx/site-perl
/usr/local/lib/perlxxxx/project-name
The purpose of this is to have modules from the net in site-perl, and
modules for the project in project-name.
Here are the three solutions I've looked at:
- added an incpush in perl.c
-> Refused by IT, because they don't like modification to source code (for
upgrade reasons)
- modified config.sh to look like this:
sitelib='/usr/local/lib/perl5.004_04/project:/usr/local/lib/perl5.004_04/site_perl'
sitelibexp='/usr/local/lib/perl5.004_04/project:/usr/local/lib/perl5.004_04/site_perl'
perl -V was happy with this, but I was told that it breaks install of
packages like sybperl, because they create a
/usr/local/lib/perl5.004_04/project:/usr/local/lib/perl5.004_04/site_perl
directory to put their files
- made a wrapper around perl
#!/bin/sh
# This little trick is to make sure that PERL5LIB is first in the search
# PATH (without it, -Idir takes precedence)
P5L=$PERL5LIB
unset PERL5LIB
exec perl5 -I$P5L:/usr/local/lib/perl5.004_04/project $*
This one works and makes everyone happy, but I don't like it, because even
if re-written in C, it's still inefficient.
Any other idea?
Thanks,
Marc
------------------------------
Date: Thu, 04 Dec 1997 20:54:53 GMT
From: editor@gardenweb.com (Bob Stewart)
Subject: Re: Browser redirect in CGI?
Message-Id: <3487185a.15768141@news.digex.net>
On Wed, 03 Dec 1997 15:45:01 -0800, Brian Godden
<bgodden@imap1.apple.com> wrote:
>Hello all,
>
>I have a simple question. I'm trying to do a browser redirect after a
>successful form submittion. I found a reference that recommended this:
>
>print "Location: http://blah.com/page.html\n\n";
>
>But this only prints this statement to my browser. Any suggestions why
>this doesn't work? Or suggestion on how to do this better? Would some
>form of open work better?
>
>Thanks!
Brian,
Is it possible you included the "content/text" statement before this
one? The Location statement is instead of the content statement.
------------------------------
Date: Thu, 4 Dec 1997 15:01:20 -0800
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: File Editing
Message-Id: <Pine.GSO.3.96.971204145950.4421T-100000@usertest.teleport.com>
On Thu, 4 Dec 1997, Lops wrote:
> From: Lops <lops@I_should_put_my_domain_in_etc_NNTP_INEWS_DOMAIN>
Have your sysadmin fix that.
> I want to change the data in particular location in the file later .
> How can I change the data stored in the file ?
Open the file for update. Print the new data to the file. If you're not
sure how to do this, get a good beginners' book on Perl, such as the Llama
book. 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: 3 Dec 1997 07:08:47 GMT
From: pojo@gte.net.nospam (Eric)
Subject: Forced to use brain-dead perl 4 -- how do I accomplish task that is simple in perl 5 ?
Message-Id: <6630hv$bsm$1@gte2.gte.net>
Howdy,
Learned Perl using Perl 5. Like it a lot. Unfortunately, the server
that I'm using uses Perl 4 on an AIX box. This works fine in perl 5:
$a = $config{fields}[$r];
Which is a hash containing a list reference. Unfortunately perl 4
craps out and gives:
syntax error in file searchdb.pl at line 134, next 2 tokens "}["
Tried changing to:
$a = $config{fields}->[$r];
and
$b = $config{fields} ; # This line is okay
$a = $b->[$r]; # Craps out
These both give the error:
syntax error in file searchdb.pl at line 134, next 2 tokens "->"
ARGHHH! I cannot even find any documentation for perl4 ... =c Does
anyone know how to do references in Perl 4??
-Eric
------------------------------
Date: 4 Dec 1997 23:06:31 GMT
From: Edward Henigin <ed@texas.net>
Subject: Re: How about a new type of "OR" (lazy evaluation)?
Message-Id: <667d1n$26i$1@news3.texas.net>
This sounds like the "0 but true" value that some functions
can return (like sysseek()).
Maybe a pragma to make 0 == true ? So you can turn it on
and off inside of your code?
use zerotrue;
$result = (calc(@params) || default(@params));
no zerotrue;
Ed
--
Bart Lateur <bart.mediamind@tornado.be> wrote:
: I find myself using the syntax like the next,a lot, as it is a nice
: shortcut (it could be "||" instead of "or"):
: $result = &calc(@params) or &default(@params);
[...]
: So I would suggest the introduction of a new type of lazy evaluation
: operator, in which case the right side is only executed if the left side
: evaluates to undef.
[...]
------------------------------
Date: Thu, 4 Dec 1997 15:09:37 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Bart Lateur <bart.mediamind@tornado.be>
Subject: Re: How about a new type of "OR" (lazy evaluation)?
Message-Id: <Pine.GSO.3.96.971204150515.4421U-100000@usertest.teleport.com>
On Thu, 4 Dec 1997, Bart Lateur wrote:
> I find myself using the syntax like the next,a lot, as it is a nice
> shortcut (it could be "||" instead of "or"):
>
> $result = &calc(@params) or &default(@params);
You probably know this, but others reading this may not: The 'or' is of
such low precedence that that does the same as this:
( $result = &calc(@params) )
or
( &default(@params) );
> However, I only want the first part to fail (and continue with the
> second part) if it's undefined, so I always end up asking myself: can
> the left part return a 0 or a ""? Under normal conditions, if this is
> the case, I want to accept this as result
That is, you want a species of "or" which is sensitive to whether a value
is defined, rather than whether it's true. Is that right? That proposal is
being worked on by the Perl development team. Stay tuned; it may be in a
future version of 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: 4 Dec 1997 22:47:57 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How do I print all but the first variable in an array?
Message-Id: <667but$997$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, jzp@usa.net writes:
:I am fairly new to perl and this is the situation I am in. I need to
:be able to print all but the first variable in a regular array. Do I
:make sense? Basically I have an array of:
:@stuff
:and I want to print $stuff[1] and $stuff[2] and $stuff[3] etc BUT NOT
:$stuff[0].
Simply use:
print "@stuff[ 1 .. $#stuff ]\n";
or some less-quoted variation thereon.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
The only disadvantage I see is that it would force everyone to get Perl.
Horrors. :-)
--Larry Wall in <8854@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Thu, 4 Dec 1997 14:49:15 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Philip <fil_nospam@login.net>
Subject: Re: Joys of tainting
Message-Id: <Pine.GSO.3.96.971204143430.4421Q-100000@usertest.teleport.com>
On Thu, 4 Dec 1997, Philip wrote:
> next unless($t=~/([a-zA-Z0-9&=\+]+)/); # line 0
> $r=quotemeta($1); # line 1
> $r="$r\\W" if(length($t)<=2); # line 2
>
> $t is tainted, lines 0 and 1 untaint it in $r.
No; $t may still be tainted at that point, but an untainted copy of part
of it is used to generate $r. So, $r is not tainted, but $t is unchanged.
> Line 2 causes $r to become tainted.
Yes, if $t is still tainted. If you use tainted data to modify $r, $r will
become tainted. (And are you certain that that pattern does what you want?
I'd recommend anchoring it, at least.) 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: Thu, 4 Dec 1997 20:09:34 GMT
From: cgreuter@calum.csclub.uwaterloo.ca (Chris Reuter)
Subject: Looking for DOS port of curseperl
Message-Id: <EKoLBy.Mqx@undergrad.math.uwaterloo.ca>
Hi all,
I'm writing a fairly simple home-library sort of application to run
under DOS on a 386 SX with 1Mb of RAM (or possibly a 286), and rather
than write the thing in C, I'd rather use perl (with perlmenu).
Does anyone know where I can find a DOS binary of perl 4.x with some
DOS curses port compiled in that will run on such a small system?
(DBM support would also be a bonus, but isn't necessary).
--Chris
[This message was previously posted on comp.lang.perl, which I have
been told is a dead group.]
------------------------------
Date: Thu, 4 Dec 1997 14:59:34 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Honza Pazdziora <adelton@fi.muni.cz>
Subject: Re: Matching lowercase letter in regexp
Message-Id: <Pine.GSO.3.96.971204145351.4421S-100000@usertest.teleport.com>
On Thu, 4 Dec 1997, Honza Pazdziora wrote:
> how do I match lowercase letter (locale-smart, of course)?
while (<>) {
while (/(\G.*?[^\W0-9_])/g) {
print "$1\n" if $1 eq lc $1;
}
}
Does that do what you want?
--
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, 04 Dec 1997 18:15:02 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Modifying file attributes
Message-Id: <comdog-ya02408000R0412971815020001@news.panix.com>
In article <348f15d9.98722485@news.demon.co.uk>, andy@osea.demon.co.uk wrote:
>I've written a "touch" utility for html files which simply reads their file
>attributes and updates their "Last-Modified" fields accordingly...
>
>Trouble is, when the new files are saved the original file date/time is lost,
>so is a single-shot tool...
>The contents need to be inivisibly modified so future "touches" won't
>overwrite the "Last-Modified" details.
hmmm... do you mean that you have some data in this file that says
"Last Modified: xxxxx" and you want to change that data without changing
the file attributes?
some options:
* change the Last Modified information in the file at the same time
that it is modified.
* use your touch utility with a time in the past (i.e. the time
that it was penultimately modified)
* use your touch utility immediately after modifying the file, or
run it more often than the ganularity of the time which you report
in the Last Modified time.
>How can I restore the original file attributes in Perl (NT version)?
>I can't find anything anywhere about this.
did you look at utime()? it even uses the word "touch".
dog[43] perldoc -f utime
=item utime LIST
Changes the access and modification times on each file of a list of
files. The first two elements of the list must be the NUMERICAL access
and modification times, in that order. Returns the number of files
successfully changed. The inode modification time of each file is set
to the current time. Example of a "touch" command:
#!/usr/bin/perl
$now = time;
utime $now, $now, @ARGV;
--
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: 4 Dec 1997 23:10:09 GMT
From: Edward Henigin <ed@texas.net>
Subject: Re: need the skinny on my() vs local()
Message-Id: <667d8h$26i$2@news3.texas.net>
Tom, I just wanted to give you a hand. The Q and A below
is the clearest explanation of my() vs local() that I've ever
seen.
Thanks for being such a stalwart perl supporter.
Ed
--
Tom Christiansen <tchrist@mox.perl.com> wrote:
[...]
: Q: What's the difference between dynamic and lexical (static) scoping?
: Between local() and my()?
: A: local($x) saves away the old value of the global variable $x,
: and assigns a new value for the duration of the subroutine,
: which is visible in other functions called from that subroutine.
: This is done at run-time, so is called dynamic scoping. local()
: always affects global variables, also called package variables
: or dynamic variables.
: my($x) creates a new variable that is only visible in the current
: subroutine. This is done at compile-time, so is called lexical or
: static scoping. my() always affects private variables, also called
: lexical variables or (improperly) static(ly scoped) variables.
[...]
------------------------------
Date: Thu, 04 Dec 1997 22:04:47 +0000 (GMT)
From: Rhodri James <rhodri@wildebst.demon.co.uk>
Subject: Re: Perl Contractors Wanted
Message-Id: <47f3656da8rhodri@wildebst.demon.co.uk>
In article <34869EEC.4072@hotlava.com>,
Gary Howland <ghowland@hotlava.com> wrote:
> Martien Verbruggen wrote:
> >
> > In article <348470CE.13D5FA40@martech.pageactive.com>,
> > Peter Marshall <peterm@martech.pageactive.com> writes:
> >
> > > - we are Perl savy, you will not have to deal Perl wannabes
> >
> > savy?
> > wannabes?
> > deal Perl?
[snip]
> Give him a break. (You have to bear in mind he's probably just an MBA,
> not a perl techie).
Yes, but he could have written it in English. Or American, I'm not that
choosy :-)
--
Rhodri James *-* Wildebeeste herder to the masses
If you don't know who I work for, you can't misattribute my words to them
... Set phasors to debug!
------------------------------
Date: Thu, 04 Dec 1997 22:11:18 GMT
From: tnguru@termnetinc.com (Ben Coleman)
Subject: Perl on Win32 using Watcom v. 11
Message-Id: <34872a1e.4333941@news.mindspring.com>
Has anyhone successfully built Perl 5.004 for Win32 using the Watcom v. 11
compiler? Any gotchas I should look out for?
Ben
--
Ben Coleman ben@termnetinc.com |
Senior Systems Analyst |
TermNet Merchant Services, Inc. |
Atlanta, GA |
------------------------------
Date: Thu, 04 Dec 1997 18:18:21 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl4 is not Y2K (was Re: Forced to use brain-dead perl 4 -- how do I accomplish task that is simple in perl 5 ?)
Message-Id: <comdog-ya02408000R0412971818210001@news.panix.com>
In article <-0412971655170001@aggie.coaps.fsu.edu>, fl_aggie@thepentagon.com (I R A Aggie) wrote:
>+ >I R A Aggie <fl_aggie@thepentagon.com> wrote:
>+ Eventually, people will say: "Perl 4!?!?! Who the hell did design such
>+ crap!?!"
>
>"Larry Wall and Randal Schwartz and their involvement in the development
> of Perl 4 -- innocent dupes or criminal masterminds? Next on Geraldo!"
should any reprinting of "Programming Perl, First Edition" have a scapegoat
as the mascot? :)
--
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: Thu, 4 Dec 1997 15:27:08 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Fabrizio Pivari <pivari@geocities.com>
Subject: Re: Q: multiline
Message-Id: <Pine.GSO.3.96.971204152639.4421Y-100000@usertest.teleport.com>
On Thu, 4 Dec 1997, Fabrizio Pivari wrote:
> I have some problems to find a good method to match in multiline.
> For example I want to find the title of an HTML file.
> I use this method
> if(/<TITLE>/i .. /<\/TITLE>/i)
> {
> $Title.=$_;
> $Title=~/<TITLE>(.*)<\/TITLE>/i;
> $title=$1;
> }
>
> I think this isn't a good method.
That's right; it isn't. You should use a module to parse the HTML. 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: Thu, 4 Dec 1997 14:52:11 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Andrew Brigham <abrigham@mail.northroute.net>
Subject: Re: Running the same program many times?
Message-Id: <Pine.GSO.3.96.971204144951.4421R-100000@usertest.teleport.com>
On Thu, 4 Dec 1997, Andrew Brigham wrote:
> foreach $line(@lines){
>
> $info = `systemcommand $line`;
> of course this basically would run the "systemcommand" (whatever that
> maybe) once for every argument I have in @lines... But now I'm searching
> for a faster way to do this. Something that would run multiple copies of
> "systemcommand" at the same time with different arguments... instead of
> one after the other after another and so on and on...
Yes; you can fork-and-exec a number of child processes at once, setting
them off to do those commands in parallel, if that will do what you want.
Be sure to check for errors from fork. 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: Thu, 4 Dec 1997 15:21:02 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: charlot@cam.org
Subject: Re: Setting default printer under Windows NT
Message-Id: <Pine.GSO.3.96.971204151040.4421V-100000@usertest.teleport.com>
On 4 Dec 1997 charlot@cam.org wrote:
> I would like to know if it is possible to set the default printer of a
> Windows NT (3.51) server from Perl.
If this can be done, it'll be done the same way that it's done from C or
from any other language. That is, your program either edits some files or
issues some commands, or something like that. I'd check the docs for the
server.
> Any help will be appreciated,
> Richard, knowing this is more-or-less a "pure" Perl question and hoping he
> won't get flamed for it...
Will you appreciate helpful flames? :-) But if you think your question is
flameworthy, why are you posting it? I don't know what you mean by a
"pure" Perl question. But this one doesn't have anything specific about
Perl, so I'd say it's not a Perl question at all.
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: Thu, 04 Dec 1997 18:07:00 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Wrapping Text in Forms?
Message-Id: <comdog-ya02408000R0412971807000001@news.panix.com>
In article <3487275A.D30076FF@horizonint.com>, Dale Chavez <dchavez@horizonint.com> wrote:
>1. I open a temp file for writing.
>2. I have a form that has a text input box.
>3. The user presses the submit button and the data gets written and the
>file closes.
>
>No problem.
>
>However, when user manually enters a CR in the text form, I get a bogus
>temp file with the name of the new line as the temp file! What could be
>causing this? How do I fix?
i don't know. how about posting some code so we can see what you are
doing?
--
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: Tue, 2 Dec 1997 23:13:42 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Writing to files
Message-Id: <6qp266.g24.ln@localhost>
paul@pkamf.demon.co.uk wrote:
: Hi Guru's
Hello to the guru's what?
;-)
I hope you don't mean to exclude answers from non-gurus.
Here's one...
: I want to open a file, search for two 'markers' then insert text - a
^^^^^^^^^^^^^
What most of us would call 'delimiters', I guess.
: variable - between the two. Do I open the file so:
^^^^^^^
On the same line?
On lines by themselves?
Maybe on different lines, but not by themselves?
Might there be two pairs of markers on the same line?
What do you want to do with the existing text between the delimiters?
Replace it?
Tack the variable's contents onto the end of what is already there?
I would do it differently in each case. Don't really want to do
all those cases when you'll only want one of them.
How about some sample data and some desired output?
Then I'm sure someone would be able to help...
: open(FILE,+<filename); ?
^^^^
^^^^
: or will this zap everything in the file?
Uh. The description of that function you called there says:
"'+<' is almost always preferred for read/write updates"
So that looks OK to me (except, as everybody already knows, you
would, in your real code, check the return value to see if the
open() actually opened anything...)
(you need some quotes too)
open(FILE, '+<filename') || die "could not open 'filename' $!";
It goes on to say:
"the '+>' mode would clobber the file first"
So I'd try and avoid that one ;-)
Use the Power.
The Power is in those docs (perlfunc, in this case).
The Power is free.
The Power is already on your hard disk somewhere (you do have perl
installed, I trust?)
Use this power only for Good ;-)
[
You must be a more trusting soul than I am. I couldn't call a function
without knowing what the creator(s) of the function have to say about
using their function...
(Well, maybe I could, but as soon as there was trouble, _then_ I
would certainly go have a looksee ;-)
]
: Will
: $_ =~ /"marker"/ work... then {print $var;}
: or someting similar work or am I missing something?
You're missing enough description of what you want.
Please repost with some sample input and output data.
: (Apart from locating the end of the marker ie the other string to mark
: the boundary fot text insertion.)
: Thanks for any help,
In case you don't clarify your specification, here is a stream of
consciousness list of potentially helpful things:
seek() (perlfunc)
(perlop, perlre)
s/MARKER(.*?)MARKER/MARKER${var}MARKER/g; # replace as many as it can find
# on one line
-i switch (perlrun)
$/ (perlvar)
"How do I change one line in a file/ (perlfaq5)
delete a line in a file/
insert a line in the middle of a file/
append to the beginning of a file?"
"How can I pull out lines between two patterns (perlfaq6)
that are themselves on different lines?"
"I'm having trouble matching over more than (perlfaq6)
one line. What's wrong?"
You already have all of this information on your computer.
Please use it.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 2 Dec 1997 23:16:07 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Writing to files
Message-Id: <nup266.g24.ln@localhost>
Peter J. Schoenster (pschon@baste.magibox.net) wrote:
: paul@pkamf.demon.co.uk wrote:
: >Hi Guru's
: >
: >I want to open a file, search for two 'markers' then insert text - a
: >variable - between the two. Do I open the file so:
: >
: >open(FILE,+<filename); ?
: >
: >or will this zap everything in the file?
: >
: >Will
: >
: >$_ =~ /"marker"/ work... then {print $var;}
: I have done a lot of this. You use html comments <!--hello bob--> as
Unless, of course, the data is not HTML.
So, for most cases, using HTML comments as delimiters probably
won't work so good.
I didn't see any mention of the format of the data in the original post...
Perl != CGI
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 1410
**************************************