[10013] in Perl-Users-Digest
Perl-Users Digest, Issue: 3606 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 1 14:06:12 1998
Date: Tue, 1 Sep 98 11:00:24 -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 Tue, 1 Sep 1998 Volume: 8 Number: 3606
Today's topics:
$1, $2, $3 are localized but... <mimmo@nospam-diemme.it>
Re: $1, $2, $3 are localized but... (Andre L.)
Re: $1, $2, $3 are localized but... (Greg Bacon)
Re: Better Regular Expressions <upsetter@ziplink.net>
Re: Currency Formatting in Perl (s//) <jdavey@epidigm.geg.mot.com>
Re: DeCrypt ? <eashton@bbnplanet.com>
Error writing to an output file... <pete.donina@ketchum.com>
Re: FMTEYEWTK on Switch Statements in Perl (was: No swi <jdporter@min.net>
Re: Formatting money <nguyend7@msu.edu>
Re: GD.pm <eashton@bbnplanet.com>
Re: Help on running perl scripts on MS-DOS (Win NT4 act <evhendrs@micron.net>
Re: Help on running perl scripts on MS-DOS (Win NT4 act (Eric Dew)
Re: Help on running perl scripts on MS-DOS (Win NT4 act (Eric Dew)
Re: Help to extract variables <mferg@hal.ddntl.didata.co.za>
Re: Help to extract variables (Maurice Aubrey)
Re: how does one delete a file with Perl? <tonylabb@infonline.net>
Re: No switch statement in Perl?? <jdw@alder.dev.tivoli.com>
Re: Perl compiler (Albert W. Dorrington)
Re: Perl Database library? (John D Groenveld)
reading from file <Jeffrey_Rosen-P28312@email.mot.com>
Re: reading from file (Maurice Aubrey)
Re: ReadParse/newline character ?? (Mike Wescott)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 01 Sep 1998 17:52:09 +0200
From: Domenico Viggiani <mimmo@nospam-diemme.it>
Subject: $1, $2, $3 are localized but...
Message-Id: <35EC1829.2BED3577@nospam-diemme.it>
Hi, all!
I read on the Camel Book:
'$1, $2, $3... are automatically localized and their scope extends to
the end of enclosing block...'
This is OK but if, for istance, I use such variables in a subroutine, I
find them initialized to the value they eventually had in the calling
block.
How can I initialize them to 'undef' or null string in the subroutine,
before using them?
Thanks in advance.
Replies better in mailbox (deleting 'nospam-' from address)
--
------------------------------------------------------------
Domenico Viggiani - Systems Administrator
Pitagora S.p.A.
------------------------------------------------------------
------------------------------
Date: Tue, 01 Sep 1998 12:40:32 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: $1, $2, $3 are localized but...
Message-Id: <alecler-0109981240320001@dialup-690.hip.cam.org>
In article <35EC1829.2BED3577@nospam-diemme.it>, Domenico Viggiani
<mimmo@nospam-diemme.it> wrote:
> Hi, all!
>
> I read on the Camel Book:
> '$1, $2, $3... are automatically localized and their scope extends to
> the end of enclosing block...'
>
> This is OK but if, for istance, I use such variables in a subroutine, I
> find them initialized to the value they eventually had in the calling
> block.
> How can I initialize them to 'undef' or null string in the subroutine,
> before using them?
$1, $2, $3, etc. are special variables, and they are read-only -> you
cannot assign to them, nor should you use them for other purposes than to
retrieve substrings matched inside capturing parentheses in regexes. For
your own $ vars, use names that begin with [A-Za-z_].
HTH,
Andre
------------------------------
Date: 1 Sep 1998 16:45:41 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: $1, $2, $3 are localized but...
Message-Id: <6sh8bl$4kp$1@info.uah.edu>
In article <35EC1829.2BED3577@nospam-diemme.it>,
Domenico Viggiani <mimmo@nospam-diemme.it> writes:
: This is OK but if, for istance, I use such variables in a subroutine, I
: find them initialized to the value they eventually had in the calling
: block.
: How can I initialize them to 'undef' or null string in the subroutine,
: before using them?
Are you worried that you'll get false positives in $1 and friends?
If that's the case, just check the return value of the match operator
before you use the values of $<n>. Otherwise, maybe it would help if
you explain your problem a little more.
Greg
--
Woody: Hey, Mr. Peterson, Jack Frost nipping at your nose?
Norm: Yep, now let's get Joe Beer nipping at my liver, huh?
------------------------------
Date: Tue, 01 Sep 1998 16:09:34 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Better Regular Expressions
Message-Id: <2%UG1.41$kE2.276882@news.shore.net>
Mee <mee@mine.com> wrote:
: If I am not mistaken, "You are a troll" around here
: seems to be a standard expression for admitting being
: defeated.
That's right. Tom P and the rest of us have been completely unsuccessful
in deriving any meaningful substance from the sum of your posts. Consider
us all defeated and please move on to a smarter newsgroup that can
appreciate your astonishingly transcendental intelligence.
--Art
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Tue, 01 Sep 1998 09:46:42 -0700
From: Jeff Davey <jdavey@epidigm.geg.mot.com>
Subject: Re: Currency Formatting in Perl (s//)
Message-Id: <35EC24F2.90DDD0D3@epidigm.geg.mot.com>
S. Kuip wrote:
> 1 while $amount =~ s/(.*\d)(\d\d\d)/$1,$2/;
>
> 1204846335 => 1,204,846,335
>
Not quite - this only puts the thousands comma delineator in. Anyone
else?
--
**********************************************************
Name: Jeffrey J. Davey
Title: Software Engineer
Company: QRP
Internet: jdavey@epidigm.geg.mot.com
Voice: (602) 441-6708
**********************************************************
------------------------------
Date: Tue, 01 Sep 1998 17:39:32 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: DeCrypt ?
Message-Id: <35EC2F00.62E1B699@bbnplanet.com>
> technically, crack does B<not> decrypt passwords, it simply runs crack
> on lots of strings that might be passwords...
wow, gosh, thanks for helping me out there. i was wondering why running
it as crack on a few major systems got the attention of the feds.
thanks!
e.
------------------------------
Date: Tue, 01 Sep 1998 12:24:00 -0400
From: Pete Donina <pete.donina@ketchum.com>
Subject: Error writing to an output file...
Message-Id: <35EC1FA0.85E2586C@ketchum.com>
I am having a problem writing to an output file from a CGI perl script.
I get the following error in the errorlog.
> [01/Sep/1998:12:11:34] failure: for host 199.183.150.2 trying to POST
/shell-cgi/test1.pl, cgi-parse-output reports: the CGI program
C:\Perl5\bin\perl.exe did not produce a valid header (program terminated
without a valid CGI header (check for core dump or other abnormal
termination)
I am running Netscape Eterprise Server v3.0 on NT
Perl for Win32 - v5.003_07
NT 4.0
The script works fine when I run it from the NT Server.
Here is the code.
$|=1;
$file2 = 'blank2.htm';
open(OUT, ">>$file2"); # Open the file
print OUT "This is a test";
close(OUT);
Thanks.
pete.donina@ketchum.com
------------------------------
Date: Mon, 31 Aug 1998 12:02:17 -0400
From: John Porter <jdporter@min.net>
Subject: Re: FMTEYEWTK on Switch Statements in Perl (was: No switch statement in Perl??)
Message-Id: <35EAC909.204FA429@min.net>
Tom Christiansen wrote:
>
> CASE 9:
>
> ($msg, $defstyle) = do {
> $i == 1 ? ("First", "Color" ) :
> $i == 2 ? ("Then", "Rarity") :
> ("Then", "Name" )
> };
( $msg, $defstyle ) = map {
/^c/i ? ( "First", "Color" ) :
/^r/i ? ( "Then", "Rarity" ) :
( "Then", "Name" )
} $opt;
> CASE 18:
>
> {
> "Fred" => \&greet,
> "Barney" => \&shuffle,
> "Wilma" => \&chat,
> }->{$who}->();
>
> Except that now you haven't managed to catch the null case.
Here's another approach which might be useful in some cases:
{
package U::Action;
*Fred = \&greet;
*Barney = \&shuffle;
*Wilma = \&chat;
sub AUTOLOAD { die "whoops: no such $AUTOLOAD" }
}
( 'U::Action::' . $who )->();
> So, anybody read this far? :-)
Even us old hands need to see this stuff again from time to time,
that's for sure. Thanks, Tom!
--
John Porter
------------------------------
Date: 1 Sep 1998 16:04:48 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: Formatting money
Message-Id: <6sh5v0$8jg$2@msunews.cl.msu.edu>
Andre L. <alecler@cam.org> wrote:
: It is possible that that thread had not reached the poster when he sent
: his own question. 20 minutes is not a long time in terms of news
: propagation...
I just wanted to make sure she would read that thread.
--
Dan Nguyen | There is only one happiness in
nguyend7@msu.edu | life, to love and be loved.
http://www.cse.msu.edu/~nguyend7 | -George Sand
------------------------------
Date: Tue, 01 Sep 1998 16:00:53 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: GD.pm
Message-Id: <35EC17E1.A7559733@bbnplanet.com>
> > one would hope that if one has perl on ones system that one also has gcc
> > or somesuch to go with it. why ask a rhetorical question.
>
> Huh??? As compilers have to be acquired and installed, and as no
> compiler is required to install perl binaries, there is zero correlation
> between these two capabilities, except by some programmer's conscious
> choice. Hardly a rhetorical question!
well, for instance, on suns you may use packages for anything you care
to so as to avoid local compilers. however, considering that you can
download and install gcc in package format for suns and for other
platforms one would think that this is a trivial action. going further
with the proof, if the system administrator went as far to download the
precompiled perl, they probably also downloaded gcc. not always the case
on ultra paranoid systems to avoid hacker wanna-bes compiling stuff.
anyway, my point was if you have perl you more than likely have a
working copy of gcc. rhetoric.
e.
------------------------------
Date: Tue, 01 Sep 1998 08:13:08 -0600
From: Ed Henderson <evhendrs@micron.net>
Subject: Re: Help on running perl scripts on MS-DOS (Win NT4 actually)
Message-Id: <35EC00F4.B66AC61E@micron.net>
Eric Dew wrote:
> Hello folks,
>
> I've written a perl script for UNIX and need to port it to MS-DOS/Win NT4.0.
> I've got perl up and running on the NT machine, but I don't know how exactly
> to get my script to work (as well as some file system questions).
>
> On UNIX, the script is run as such:
> % perlscript -d <date> -r <name>
>
> Will I be able to do that straight away on NT, or do I have to say:
> C:\perl5>perl perlscript -d <date> -r <name>
> (do I have to rename the script to have a proper suffix, like perlscript.pl?)
>
> I understand that I have to run the perl script as a batch file and so I
> included the following lines to the top of the file:
>
> @echo off
> goto endofperl
> @rem';
>
> and to the end of the file:
>
> __END__
> :endofperl
Ugly!! Forget all this junk. You are no WinNT 4.0, so you can set an ftype and
assoc.
assoc .pl perl
ftype perl=c:/perl/bin/perl.exe %0 %0 %*
This will associtate .pl files (you need to rename your script to have .pl
extenstion) with
the 'type' perl. And it will declare the action for 'perl' files to run the perl
interpreter and pass
is the specified options.
I have found for some strange reason (I'm not sure I'm not making a mistake here)
that the %0
argument needs to be specified twice to get the @ARGV array inside perl to be what
I expect,
but hey, play with it to make sure on your system.
as far as the rest is concerned, in perl, the "chdir" command understanads drive
letters,
even though the dos cd command doesn't. So you can legitimately put:
chdir "f:/foo/bar/bletch";
and perl will do the right thing. Also, use forward slashes, as backslashes are
escape characters,
and have been since about 1960 or so.. Why DOS ever used \ is beyond me!!
------------------------------
Date: Tue, 1 Sep 1998 17:08:08 GMT
From: edew@netcom.com (Eric Dew)
Subject: Re: Help on running perl scripts on MS-DOS (Win NT4 actually)
Message-Id: <edewEyM7LK.MGH@netcom.com>
In article <Pine.GSO.3.96.980901154240.10907A-100000@uscmail.usc.es> David Suarez de Lis <fafefito@uscmail.usc.es> writes:
>Hi there...
>
>On Tue, 1 Sep 1998, Eric Dew wrote:
>
>: Hello folks,
>:
>: I've written a perl script for UNIX and need to port it to MS-DOS/Win NT4.0.
>: I've got perl up and running on the NT machine, but I don't know how exactly
>: to get my script to work (as well as some file system questions).
>:
>: On UNIX, the script is run as such:
>: % perlscript -d <date> -r <name>
>:
>: Will I be able to do that straight away on NT, or do I have to say:
>: C:\perl5>perl perlscript -d <date> -r <name>
>: (do I have to rename the script to have a proper suffix, like perlscript.pl?)
>
>well, on NT4 Workstation, using Perl 5.004_02, you don't have to:
>
>> perl perlscript blah blah should work perfectly.
>
Well, tried that. Didn't work.
>: I understand that I have to run the perl script as a batch file and so I
>: included the following lines to the top of the file:
>
>I don't understand why, running it from the command line works as a dream
>(although cmd.exe, being much better than command.com, is pretty poor as
>compared to Unix shells like bash...)
>
I don't understand either. Maybe what I was told is an UL. I don't know
jack about DOS scripting, so I take anyone's suggestion as gospel.
>: Next, I plan to run the perl script on drive D:\, but want it to do
>: things to files on drive F:\ (say).
>:
>: So, how to do I tell it to change drives to F:\ ? I'm putting in the
>: line,
>: `F:\`;
>: wherever I need to change to drive F.
>
>Tried that and got an error... maybe the best thing is
>$PATH=qq(f:\\path\\to\\the\\files);
>
Yeah, I might have to resort to that.
>and then attaching $PATH to all operations there...
>
>system "copy $PATH\\foo.txt $PATH\\texts\\foo.txt";
>
Is "system" required for running DOS commands, or will it just make it
"safer" in that it spawns a new process?
>
>: or do I have to use "\\" in place of "\", as in:
>
>If you use '' (not ``) qhich is equivalent to q(), then it doesn't matter, the
>string get's passed without parsing (although it may give errors on later
>commands), while "" allow expansion inside the string, so $PATH is expanded
>("" equal qq(), see perldoc perlop)
>
Yeah, that is why I'm using double-quotes. I need to use double quotes so
that $homedir and $file makes sense.
>I only get errors if I use ``, but who knows? I never needed to use them
>yet...
>
>: Of course, I could find out whether one back-slash or two back-slashes will
>: work, once I can get the script to run, which goes back to the first set
>: of questions.
>
>I will suggest you suffer with cmd capabilities using perl -we "script goes
>here " and try some silly examples to get the feeling of the environment...
>
Will try the above.
>then go to Cygnus CygWin32 and install bash for Win32 :)
>
May try the above.
EDEW
------------------------------
Date: Tue, 1 Sep 1998 16:57:36 GMT
From: edew@netcom.com (Eric Dew)
Subject: Re: Help on running perl scripts on MS-DOS (Win NT4 actually)
Message-Id: <edewEyM741.Lux@netcom.com>
In article <6sgc2q$m3d$1@ligarius.ultra.net> sowmaster@juicepigs.com (Bob Trieger) writes:
>[ posted to usenet and courtesy e-mail sent to edew@netcom.com]
>edew@netcom.com (Eric Dew) wrote:
>-> In article <6sfr2f$cso$1@ligarius.ultra.net> sowmaster@juicepigs.com (Bob
>-> Trieger) writes:
>-> >[ posted to usenet and courtesy e-mail sent to edew@netcom.com ]
>-> >edew@netcom.com (Eric Dew) wrote:
>
>-> >Well, what happened when you tried it?
>->
>-> If I did C:\per5>perl perlscript ... it said:
>->
>-> Bare word found where operator expected at perlscript.pl line 1, near "echo
>-> off"
>-> (Missing operator before off?)
>-> syntax error at perlscript.pl line 2, next token ???
>-> Array found where operator expected at perlscript.pl line 3, near "@rem"
>-> (Missing semicolon on previous line?)
>
>Are you trying to execute a perl script or a DOS bat?
>
I was told that to run a perl script on DOS, I have to run it as a batch file.
If not, please suggest the proper way to run it.
>Post the first couple of lines from your script. you obviously have an
>error on line 2.
>
I did post the first couple of lines in my original message.
>
>-> >-> So, how to do I tell it to change drives to F:\ ? I'm putting in the
>-> >-> line,
>-> >-> `F:\`;
>-> >-> wherever I need to change to drive F.
>-> >
>-> >Why are you doing that. Have you tried: chdir "f:/";
>->
>-> Because to change to another drive on DOS, one types:
>-> C:\>D:
>-> to get to
>-> D:\>
>
>Once again, are you writing a perl script or a DOS bat?
>
Once again, I am writing a perl script, but as I mentioned above, I was told
that it has to run as a DOS batch, whatever that means in this situation.
Also, I am assuming that since chdir is equivalent to cd, chdir("D:\"); would
be equivalent to cd D:\ and that won't work. Of course, as I mentioned in
my original post, if I could at least get it to run -- bug-free or no, I
can determine what the correct syntax will be. I mean, how many different
ways can one get a language to change directories? (Rhetorical question.)
>I know how to change disks in DOS and as an added bonus, I also know how
>to do it in perl.
You're not helping by telling me what you can do. You can help by telling me
how to do it, in perl on DOS.
>
>-> Thus, using chdir (which I would assume will equal to cd on DOS) will not
>-> work, because
>-> C:\>cd D:
>-> does not change the drive to D:\>.
>
>What do you mean `will not work'? Have you tried it or are you going to
>argue about what you think it will do?
>
As I mentioned in the very original post, I don't know if it will work or
not. I'm just surmising that it won't work because if things do what they're
supposed to do, it appears to me that it won't work. If I can get the program
to just start, I'd be happy and then I can debug it.
By the way, I'm not arguing. Will you just provide answers or are you just
going to continue with the snide remarks? I'm looking for straight answers,
not snide remarks, thank you.
>-> >You must escape the backwhacks if you insist on using them but it is
>-> >much easier to just use a single slash.
>-> >
>-> >IE:
>-> > chdir "f:/";
>-> > chdir "/$dir1/$dir2/$dir3";
>-> >
>-> Again, on DOS,
>-> cd dir1/dir2
>-> does not make sense. DOS prompt returns:
>-> The syntax of the command is incorrect
>-> (Meaning the forward slash is wrong.)
>
>For the last time, are you writing a perl script or a DOS bat?
I'm posting to a perl newsgroup. The content of my script includes the
likes of:
open(DLINE,"+ $file") || die ;
. . .
chdir("$homedir/dir1");
. . .
sub make_file {
. . .
}
Looks like perl.
>
>-> So, your suggestion, chdir "f:/"; will result in NOT changing to the F:
>-> drive (at least that's what I'm guessing...as I said before and below, if
>-> I can get it running, even with bugs, I can guess how to fix the paths)
>-> and chdir "/$dir1/$dir2/"; will not result in cd-ing to the proper directory.
>
>Guessing? What is stopping you from trying it?
>
Once more: if I can just get the thing to run, I'll debug it myself and
skip your pansy-ass comments. Can I get a straight answer?
EDEW
------------------------------
Date: Tue, 01 Sep 1998 18:15:30 -0200
From: Mark Fergusson <mferg@hal.ddntl.didata.co.za>
To: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Help to extract variables
Message-Id: <35EC55E1.B42EA73E@hal.ddntl.didata.co.za>
Hi. Thanks for the input. I tried this. Doesn't seem to work ? Anybody else have a
suggestion ?
Thanks.
Tony Curtis wrote:
> Re: Help to extract variables, Mark
> <mferg@hal.ddntl.didata.co.za> said:
>
> Mark> Hi. I'm runing a perl program with a number of
> Mark> arguments. I need to set variables based on these
> Mark> arguments. It looks something like this:
>
> Mark> program value1=Value1 value2=hello this is a test
> Mark> value3=next test value4=Value4
>
> Mark> What I need out of this is: $value1="Value1";
> Mark> $value2="hello this is a test"; $value3="next test";
> Mark> $value4="Value4";
>
> Mark> How Can I do this. I've tried using a for loop and
> Mark> split, but I only get for example $value2="hello";
>
> It would help to show the code involved.
>
> You could try something along the lines of (untested):
>
> my %args;
> foreach my $a (@ARGV) {
> if ($a =~ /=/) {
> my ($key, $val) = split /=/, $a;
> $args{$key} = $val;
> }
> }
>
> and then you can refer to all the x=y parameters through the
> %args hash. Of course you'll have to extend this to handle
> the unquoted parameters which have to be appended onto the
> current key's value.
>
> I wouldn't drag the left-hand-side directly into a variable
> (presumably via eval?) because you have no control over the
> parameters, which could lead to people messing with perl's
> special variables and other nastinesses.
>
> hth
> tony
> --
> Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
> Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
> "You see? You see? Your stupid minds! | private email:
> Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
--
_____________________________________________
Mark Fergusson: mferg@hal.ddntl.didata.co.za
Dimension Data:
PO Box 236, Pavillion, 3611, South Africa
(+27)-31-204-8424 (Work)
(+27)-31-204-8590 (Fax)
082-771-8519 (Cell)
------------------------------
Date: Tue, 01 Sep 1998 16:40:02 GMT
From: maurice@hevanet.com (Maurice Aubrey)
Subject: Re: Help to extract variables
Message-Id: <slrn6uo8r2.7t9.maurice@we-24-130-48-83.we.mediaone.net>
On Tue, 01 Sep 1998 18:15:30 -0200, Mark Fergusson <mferg@hal.ddntl.didata.co.za
wrote:
>Hi. Thanks for the input. I tried this. Doesn't seem to work ? Anybody else
>have a suggestion ?
In what way is it not working?
#!/usr/bin/perl -Tw
use strict;
my %args;
foreach(@ARGV) {
my($key, $value) = split /=/;
$args{$key} = $value;
}
foreach(keys %args) {
print "$_=$args{$_}\n";
}
Here's a test run:
%./try value1=Value1 value2="hello this is a test" value3="next test"
value4=Value4
value3=next test
value4=Value4
value1=Value1
value2=hello this is a test
Hmm... looks like it works to me. If you want to implement this as
you initially proposed, you should read about symbolic references.
But the hash approach is probably better.
--
Maurice Aubrey <maurice@hevanet.com>
Moderation in temper is always a virtue, but moderation in principle
is always a vice.
- Thomas Paine
------------------------------
Date: Tue, 01 Sep 1998 13:15:45 -0400
From: Tony Labbiento <tonylabb@infonline.net>
Subject: Re: how does one delete a file with Perl?
Message-Id: <35EC2BC1.48A27963@infonline.net>
Have you tried "unlink file_name".
Jonathan A. Laub wrote:
>
> is there a "delete" file command in Perl?
>
> Thanks
>
> Jon
--
****************************************
* Tony Labbiento *
* Infinity Online, Inc. *
****************************************
------------------------------
Date: 01 Sep 1998 10:35:58 -0500
From: Jim Woodgate <jdw@alder.dev.tivoli.com>
Subject: Re: No switch statement in Perl??
Message-Id: <obk93n976p.fsf@alder.dev.tivoli.com>
spiegler@cs.uri.edu writes:
> I cannot find a switch statement in Perl. Is there one? If not, do you know
> why it was not put into the language?
>
> Also, does Perl provide any mechanism other than if-elsif-else to deal with
> this?
try perldoc -q switch
--
Jim Woodgate
Tivoli Systems
E-Mail: jdw@dev.tivoli.com
------------------------------
Date: 1 Sep 1998 10:23:35 -0500
From: awdorrin@mail.delcoelect.com (Albert W. Dorrington)
Subject: Re: Perl compiler
Message-Id: <6sh3hn$ikr@ws051eng.ictest.delcoelect.com>
In article <6s4rjn$3ll$2@client3.news.psi.net>, abigail@fnx.com (Abigail) writes:
:> Albert W. Dorrington (awdorrin@mail.delcoelect.com) wrote on MDCCCXXII
:> September MCMXCIII in <URL: news:6s47h6$4s4@ws051eng.ictest.delcoelect.com>:
<snip>
:> ++
:> ++ Oh give me a break! There are many valid reasons for wanting
:> ++ to keep source code hidden from users.
:>
:> No, there are not.
:>
:> ++ Most of the reasons I can think of off the top of my head
:> ++ deal with security issues or support.
:>
:> Security? Nope. Support??????? Only in a negative sense.
:>
:> ++ The real answer to the question: 'How can I hide/protect my
:> ++ source code?' is - use another language, such as C, which
:> ++ is compiled.
:>
:> And which can be decompiled.
:>
Abigail,
You obviously are an opinionated person, but
if you haven't learned so already the world is not
black and white.
Just because you feel there are not valid reasons
for something, does not make it so. Obviously your opinions
are not what makes the world go round.
I can tell by your opinions, that you've never had
any experience in the field of software support. I can tell you've
never had to deal with the results of users who proliferate
their own methods/tools for doing things their own way.
And to answer the question 'whats wrong with people doing
things their own way' I could ask you the same thing, but
I'll tell you my reason: lack of efficiency.
Of course code can be decompiled - a machine can
also be hacked into and investigated in that manner. But
when you aren't worried about safeguarding the meaning of
life, but are looking to limit the access that a casual
user may try to exploit, then simple obfuscation may be
the most cost effective manner available.
If we expound on your beliefs, then I assume that
you would do away with passworded accounts completely. After
all, restricting access to a users files violates your 'freedom
of knowledge' principle. And anyways, anyone with enough smarts
can hack into that system and look at the files anyway.
I guess that you also probably leave the windows of
your car rolled down, the doors unlocked, and the keys in
the ignition. After all, it wouldn't be right for only you
to use your car, it should be a public resource that anyone
should be able to use. Anyway, anyone with enough smarts can
break into your car, hotwire it and drive it anyway...
Get my point yet?
- Al
--
Al Dorrington
FIRMS & Web Admin, Oracle DBA Phone: 765-451-9655
IC-DELCO CIM, Delphi Delco Electronics Systems Fax: 765-451-8230
------------------------------
Date: 1 Sep 1998 12:00:03 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: Perl Database library?
Message-Id: <6sh5m3$v3$1@tholian.cse.psu.edu>
There are a few "free" SQL databases:
ftp://ftp.idiom.com/pub/free-databases
Postgres and m*SQL have Perl interfaces.
Also, if you're a fan of Xbase dbf format, take a look at
DBI/DBD::XBase
http://www.arcana.co.uk/technologia/perl/DBI/
John
groenveld@acm.org
------------------------------
Date: Tue, 01 Sep 1998 08:57:21 -0700
From: Jeffrey Rosen <Jeffrey_Rosen-P28312@email.mot.com>
Subject: reading from file
Message-Id: <35EC1961.63C66284@email.mot.com>
I have code that is not behaving as I would expect. $name gets
manipulated as if it was a pointer to $line, not a string copy of the
informaiton. How do I make a copy of the string?
$DATA_FILE = "/tmp/1998_08_11_013400.ldif";
open(DATA,"$DATA_FILE") || die "Input file not found";
while ($line=<DATA>) {
$name=$line;
if ($line =~ /nscalxitemid:/) {
print $name;
($attribute,$node,$id)=split(/:/,$line);
if (!defined($idlist{$id})) {
$idlist{$id} = 1;
}
else {
print "dup: $id";
}
} #end match id
} #end while main loop
When I do not use a file handle it works. i.e.
$temp="test";
$newvar=$temp;
$temp="new";
in this case $newvar is still "test";
Thanks in advance, Jeff
P28312@email.mot.com
------------------------------
Date: Tue, 01 Sep 1998 17:00:08 GMT
From: maurice@hevanet.com (Maurice Aubrey)
Subject: Re: reading from file
Message-Id: <slrn6uoa0p.7t9.maurice@we-24-130-48-83.we.mediaone.net>
On Tue, 01 Sep 1998 08:57:21 -0700, Jeffrey Rosen
<Jeffrey_Rosen-P28312@email.mot.com> wrote:
>I have code that is not behaving as I would expect. $name gets
>manipulated as if it was a pointer to $line, not a string copy of the
>informaiton. How do I make a copy of the string?
>
>
>$DATA_FILE = "/tmp/1998_08_11_013400.ldif";
>open(DATA,"$DATA_FILE") || die "Input file not found";
>while ($line=<DATA>) {
>$name=$line;
> if ($line =~ /nscalxitemid:/) {
> print $name;
> ($attribute,$node,$id)=split(/:/,$line);
> if (!defined($idlist{$id})) {
> $idlist{$id} = 1;
> }
> else {
> print "dup: $id";
> }
> } #end match id
>} #end while main loop
You'll need to isolate where the problem is. The code that you
supplied seems to work fine over here. Here's the test script,
slightly modified:
#!/usr/bin/perl
open(DATA, 'test.txt') or die "Input file not found: $!";
while (defined($line=<DATA>)) {
$name=$line;
if ($line =~ /nscalxitemid:/) {
print $name;
($attribute,$node,$id)=split(/:/,$line);
if (!defined($idlist{$id})) {
$idlist{$id} = 1;
} else {
print "dup: $id";
}
} #end match id
} #end while main loop
undef $line;
print "\nLINE: $line\n";
print "NAME: $name\n";
Here's some fake data:
nscalxitemid:1:2939
sdfsdfsdf:293:49392
nscalxitemid:29:90329
nscalxitemid:38:90329
And here is the output:
nscalxitemid:1:2939
nscalxitemid:29:90329
nscalxitemid:38:90329
dup: 90329
LINE:
NAME: nscalxitemid:38:90329
Clearly, $name is not a reference to $line.
Isn't this acting the way you expected?
--
Maurice Aubrey <maurice@hevanet.com>
Individual rights are the means of subordinating society to moral law.
- Ayn Rand
------------------------------
Date: 01 Sep 1998 12:53:48 -0400
From: wescott@cygnus.ColumbiaSC.NCR.COM (Mike Wescott)
Subject: Re: ReadParse/newline character ??
Message-Id: <x4k93n3hb7.fsf@cygnus.ColumbiaSC.NCR.COM>
In article <35EAE18D.26D1FC53@loop.com> Ben Wallach <benwallach@loop.com> writes:
> I am reading in a string (key/value pair) from a web page into my perl
> script. I need to print this string to a file. The string has a newline
> character in it ("\n") that needs to be reflected when it is printed to
> the file.
> PROBLEM: The newline character is being interpreted literally.
> EXAMPLE: "This is my\ntest string"
> After ReadParse reads string and string is printed to file:
> This is my\ntest string
> WHAT I WANT :
> This is my
> test string
> Somehow I need the readParse function to understand that "\n" means
> newline and not '\' and then 'n' ????
Consider using eval().
--
-Mike Wescott
mike.wescott@ColumbiaSC.NCR.COM
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3606
**************************************