[18925] in Perl-Users-Digest
Perl-Users Digest, Issue: 1120 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 12 18:07:16 2001
Date: Tue, 12 Jun 2001 15:05:20 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <992383519-v10-i1120@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 12 Jun 2001 Volume: 10 Number: 1120
Today's topics:
Re: -f operator and tainted data <elijah@workspot.net>
a question to programmers. <thinkit8@lycos.com>
Re: a question to programmers. <gnarinn@hotmail.com>
Re: a question to programmers. (Craig Berry)
Re: Ack! Newbie still suffering from C-brain! (Steven)
ARGV <emailkevin@charter.net>
Re: ARGV <carlos@plant.student.utwente.nl>
Re: ARGV <bart.lateur@skynet.be>
Re: Can an lvalue sub also be an rvalue? nobull@mail.com
Re: Can an lvalue sub also be an rvalue? (Jay Tilton)
Re: can you do while (<HANDLE>) inside opening a file t <comdog@panix.com>
directing STDOUT back to the display (Shon)
Re: directing STDOUT back to the display <ren@tivoli.com>
fork and pass message while waiting (Kevin Joseph)
Re: fork and pass message while waiting (Jay Tilton)
help with regexp? (oza)
Re: help with regexp? <gnarinn@hotmail.com>
Re: help with regexp? <ren@tivoli.com>
Re: Help with split?vvp (Steven)
Re: Help with split?vvp (Rolf Krahl)
Re: Help with split?vvp <godzilla@stomp.stomp.tokyo>
Re: Help with split?vvp <godzilla@stomp.stomp.tokyo>
Re: How to make a Perlscript Shareware? (Steven)
Key facts from exported System Info.-report (msinfo32.e (Roger Larsen)
Re: Last Chance for Damian's Advanced OO Perl class (Randal L. Schwartz)
log file parsing <emailkevin@charter.net>
Marble lossage in "or" vs. "||" (pt)
Re: Marble lossage in "or" vs. "||" <bart.lateur@skynet.be>
modules (no, not perl modules) <todd@designsouth.net>
Re: My senior project is "done" (Sweth Chandramouli)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Jun 2001 19:50:52 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: -f operator and tainted data
Message-Id: <eli$0106121514@qz.little-neck.ny.us>
In comp.lang.perl.misc, David Allen <mda@idatar.com> wrote:
> Quick question about how the -f operator really works.
> (And related file operators)
>
> If I'm writing a CGI program and of course have user data
> that I can't trust, is it safe to use the -f operator?
It is taint-checking safe, but it could have side effects
that you might not want. Others have observed that stat()ing
AFS mounts can be a slowdown, as perhaps could other odd
files.
> But is the same true of -f? As in, is this an equally bad idea?
No file will be created as a result of -f. But if you give
different user feedback based on -f '/var/www/index.html'
returning true, versus -f '/htdocs/mainsite/index.html'
returning false, then you give an external way for people to
find your files.
Then they pull out various exploits that offer the ability to
'read any file on the system if the name is known' and try them
out on your box.
> I'm guessing that -f is implemented in terms of stat() but I'm not
> sure. I can't think of any reason why this would be insecure, but
> I know that that doesn't mean that it's secure. :)
Well, as I mentioned, it is taint-checking safe, so that means it
is not a big risk.
Elijah
------
likes seeing security discussion here
------------------------------
Date: 12 Jun 2001 11:23:10 -0700
From: thinkit <thinkit8@lycos.com>
Subject: a question to programmers.
Message-Id: <9g5mme04h8@drn.newsguy.com>
if a language only offered hexadecimal and binary input literals, would you be
more or less likely to utilize it? in a similar line, how much hexadecimal do
you use in the languages you use now? do you count to 16, or to 0x10?
------------------------------
Date: Tue, 12 Jun 2001 19:06:08 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: a question to programmers.
Message-Id: <992372768.634872943162918.gnarinn@hotmail.com>
In article <9g5mme04h8@drn.newsguy.com>, thinkit <thinkit8@lycos.com> wrote:
>if a language only offered hexadecimal and binary input literals, would you be
>more or less likely to utilize it? in a similar line, how much hexadecimal do
>you use in the languages you use now? do you count to 16, or to 0x10?
>
strange question to ask in a perl newsgroup
gnari
------------------------------
Date: Tue, 12 Jun 2001 21:29:33 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: a question to programmers.
Message-Id: <tid2dtk5i80ja6@corp.supernews.com>
thinkit (thinkit8@lycos.com) wrote:
: if a language only offered hexadecimal and binary input literals, would
: you be more or less likely to utilize it? in a similar line, how much
: hexadecimal do you use in the languages you use now? do you count to
: 16, or to 0x10?
I wouldn't use it. After all, even (most) assemblers offer string
literals and the like. Having
print 0x48656c6c6f2c20776f726c64210a;
as your first program seems a bit...retro. :)
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Magick is the art and science of causing change in conformity
| with Will." - Aleister Crowley
------------------------------
Date: 12 Jun 2001 14:20:03 -0700
From: steve.busiello@gs.com (Steven)
Subject: Re: Ack! Newbie still suffering from C-brain!
Message-Id: <fa45b871.0106121320.3bd687b9@posting.google.com>
Definately the BEST book for accomplished perl programmers:
you start thinking perl wise when you start writing
$line = "Steven is a Java programmer\n";
substr($line,12,4) = "Perl";
print "$line";
-Steven
dha@panix.com (David H. Adler) wrote in message news:<slrn9i9s37.ep2.dha@panix2.panix.com>...
> In article <7V0V6.1401$h45.8042@news.uk.colt.net>, John Imrie wrote:
> >
> > pt <mnemotronic@mind\no-spam/spring.com> wrote in message
> > news:3B244F86.1BCB14B0@mindspring.com...
> >> After taking a few steps back, it appears that much of my Perl code
> >> resembles Pascal/C/C++/Java/etc. I just read about foothing (i.e.
> >> *foo{THING}), the "each" operator and pseudohashes. The more I read,
> >> the more interesting doohickies turn up. How long does it take to BEGIN
> >> {<PERLISH> =~ /thinking/}
> >>
> > You know you are thinking in perl when you use foreach instead of for
>
> ...and moreso when you start using for, but as a synonym for foreach,
> rather than as a C-style for loop. :-)
>
> On a more practical note, you might want to read Effective Perl
> Programming by Joseph Hall (w/Randal Schwartz, but who cares about *him*
> ;-). Very good book for learning to write idiomatic Perl.
>
> dha
------------------------------
Date: Tue, 12 Jun 2001 16:30:24 -0400
From: "kevin" <emailkevin@charter.net>
Subject: ARGV
Message-Id: <ticuti5odrre6a@corp.supernews.com>
Can someone please explain the purpose of ARGV? ...for instance, what is
happening in the following line?
$arg = shift(@ARGV);
thanks
------------------------------
Date: Tue, 12 Jun 2001 22:39:41 +0200
From: "carlos" <carlos@plant.student.utwente.nl>
Subject: Re: ARGV
Message-Id: <9g5ume$7jh$1@dinkel.civ.utwente.nl>
its the array of arguments that you pass on the command line
"kevin" <emailkevin@charter.net> wrote in message
news:ticuti5odrre6a@corp.supernews.com...
> Can someone please explain the purpose of ARGV? ...for instance, what is
> happening in the following line?
>
>
> $arg = shift(@ARGV);
>
>
> thanks
>
>
------------------------------
Date: Tue, 12 Jun 2001 20:50:24 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: ARGV
Message-Id: <quvcit4f2v2aaugr62o0auv89d6uq69bki@4ax.com>
kevin wrote:
>Can someone please explain the purpose of ARGV? ...for instance, what is
>happening in the following line?
>
>$arg = shift(@ARGV);
It conteins the words on the command line. Commonly, that means, the
files you want your script to process.
script:
print join ' | ', @ARGV; print "\n";
run as:
perl -w test.pl foo.txt bar.txt baz.txt
result:
foo.txt | bar.txt | baz.txt
Note that the command line witches for perl and the script name are
missing. Also note that the "files" don't even need to exist.
So shift(@ARGV) gets (and removes) the first "file" from that list.
Array.
--
Bart.
------------------------------
Date: 12 Jun 2001 18:52:25 +0100
From: nobull@mail.com
Subject: Re: Can an lvalue sub also be an rvalue?
Message-Id: <u9bsnt1t7q.fsf@wcl-l.bham.ac.uk>
mnemotronic@yahoo.com (pt) writes:
> "John Lin" <johnlin@chttl.com.tw> wrote in message news:<9g3qbg$s1r@netnews.hinet.net>...
> > "pt" wrote
> > > Can a sub declared with the "lvalue" attribute also be used as a
> > > regular (rvalue) sub?
> > > $thing_status = status($thing) ; # get thing's status
> > > status($thing) = 0 ; # reset thing's status
> >
> > Your code tells your the answer. Does it compile? Does it work?
>
> No and No, but that's only because I haven't figured out the
> correct syntax, usage, or incantation yet. One or two short examples
> would be appreciated.
Perhaps _you_ should post an example of code that doesn't work.
The code you posted works just fine if status() is an lvalue
subroutine e.g:
sub status : lvalue { $_[0]{status} };
my $thing = { status => 2 };
my $thing_status = status($thing) ; # get thing's status
print "\$thing_status = $thing_status\n";
status($thing) = 0 ; # reset thing's status
print "\$thing->{status} = $thing->{status}\n";
__END__
Output:
$thing_status = 2
$thing->{status} = 0
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 12 Jun 2001 19:41:21 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Can an lvalue sub also be an rvalue?
Message-Id: <3b266626.11538612@news.erols.com>
On 11 Jun 2001 16:09:52 -0700, mnemotronic@yahoo.com (pt) wrote:
>Can a sub declared with the "lvalue" attribute also be used as a
>regular (rvalue) sub?
Yes. A sub always returns an rvalue.
[snip quote from docs]
> This implies that an lvalue sub does not require being used in an
>lvalue context, or am I reading something into an admittedly
>expermental feature?
You're correct. Its return can be treated as you would any variable. It
can be modified, but doesn't have to be. It can be used as an ordinary
rvalue at the same time its being used as an lvalue.
> I'm not sure how the sub would detect it's context ...
Whether a sub is called in an lvalue context is perl's problem. Other than
setting a sub's 'lvalue' attribute and making sure the return is something
that can be modified, you need no special coding.
Rather than sit and be baffled, go ahead and play around with it. Be
encouraged to try things that may break it.
#!perl -w
use strict;
my $thing = {}; #Create a hash reference to throw around.
status($thing) = 0; #status == 0
status($thing) = 1; #status == 1
status($thing)++; #status == 2, but this invocation returns 1
++status($thing); #status == 3
status($thing) = [qw/foo bar/]; #status is now an array reference
status($thing)->[0] = 'baz'; #change one element of the array
status($thing) = status($thing)->[0]; #status eq 'baz'
status($thing) .= ' Test'; #status eq 'baz Test'
status($thing) =~ s/Test/Final/; #status eq 'baz Final'
print status($thing), "\n"; #Only used as rvalue here
sub status : lvalue {
$_[0]->{status};
}
------------------------------
Date: Tue, 12 Jun 2001 14:26:28 -0700
From: brian d foy <comdog@panix.com>
Subject: Re: can you do while (<HANDLE>) inside opening a file twice?
Message-Id: <comdog-D43AF4.14262812062001@news.panix.com>
In article <9g3pte$v6m$1@nntp1.ba.best.com>, inwap@best.com (Joe Smith)
wrote:
> In article <QNYU6.81822$%i7.61334578@news1.rdc1.sfba.home.com>,
> Gala <Gala@nonono.com> wrote:
> > Not to mention,
> >most server providers usally dont give more then 100 megs, or sometimes
> >less, depending on the provider and service, but theres no way in the
> >7th circle of hell you are going to get anything even remotely close to
> >2 gigs.
>
> Perl is not a language that only runs on web servers. The amount of
> disk space allocated to a $30/month account is irrelevent to proper
> coding techniques.
well, when i had to store large files ( 8 Gb ) on a service
provider i just bought them the disks to do it. :)
"no way in hell" is for people who can't work the system. hacking
isn't limited to computers, after all.
--
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: 12 Jun 2001 11:31:52 -0700
From: sgfoley@hotmail.com (Shon)
Subject: directing STDOUT back to the display
Message-Id: <b0a70a3a.0106121031.4d97896b@posting.google.com>
Basic Flow of my scripts...
1. script_1 redirect STDOUT to FILE
2. script_1 invokes script_2 via command line.
3. script_2 redirect STDOUT to FILE if(foo);
problem:
if foo = false, the STDOUT is still redirected to FILE.
(no the if is not inverted if foo=true i get the same thing :p )
questions:
1)is script_2 using the same STDOUT filehandle as script_1, i thought
they would be in a different symbol table?
2)how do i redirect STDOUT back to the display terminal?
thx,
Shon
------------------------------
Date: 12 Jun 2001 14:28:54 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: directing STDOUT back to the display
Message-Id: <m3puc9lcp5.fsf@dhcp9-173.support.tivoli.com>
On 12 Jun 2001, sgfoley@hotmail.com wrote:
> Basic Flow of my scripts...
> 1. script_1 redirect STDOUT to FILE
> 2. script_1 invokes script_2 via command line.
> 3. script_2 redirect STDOUT to FILE if(foo);
>
> problem:
> if foo = false, the STDOUT is still redirected to FILE.
> (no the if is not inverted if foo=true i get the same thing :p )
>
> questions:
> 1)is script_2 using the same STDOUT filehandle as script_1, i
> thought they would be in a different symbol table? 2)how do i
> redirect STDOUT back to the display terminal?
Filehandles are inherited by child processes. This is an OS thing
that isn't really affected by Perl.
There is really no way to resurrect the original STDOUT target, though
you may be able to figure out what terminal the process is running on
and direct output directly to the terminal. Normally, this is a very
bad idea, though there are always exceptions.
The correct solution to this problem is generally to have script_1 not
redirect STDOUT in the first place, or do so only temporarily.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 12 Jun 2001 12:36:15 -0700
From: kejoseph@hotmail.com (Kevin Joseph)
Subject: fork and pass message while waiting
Message-Id: <54c48ac0.0106121136.765fdc19@posting.google.com>
I have a process which takes around 10 min to complete. This process is
being executed from a web server. However, Netsape and IE timeout after
300 sec.
I am trying to write a perl script which would fork this process and
pass a message back to server every 250 sec. This way IE/Netscape and
would not timeout and when the process has completed, it will output
the information to the web page.
How do I implement this ? I have tried various combination but still could
not figure it out.
Any help would be greatly appreciated.
Thanks,
Kevin.
------------------------------
Date: Tue, 12 Jun 2001 20:51:07 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: fork and pass message while waiting
Message-Id: <3b26770b.15864063@news.erols.com>
On 12 Jun 2001 12:36:15 -0700, kejoseph@hotmail.com (Kevin Joseph) wrote:
>I have a process which takes around 10 min to complete. This process is
>being executed from a web server. However, Netsape and IE timeout after
>300 sec.
>I am trying to write a perl script which would fork this process and
>pass a message back to server every 250 sec. This way IE/Netscape and
>would not timeout and when the process has completed, it will output
>the information to the web page.
Wow. That's awful. Would the user be expected to keep the browser open and
to stay on the same page the whole time? This is poor user interface.
Consider a different approach. Provide a URL where the result can be viewed
at leisure once complete, but have it display a message along the lines of
"Still working. Check back in X minutes." until it has finished. Allow the
user to choose to be notified by email when it is complete, or to receive
the result itself by email.
This will also reduce the number of inevitable "Doesn't work in Netscape"
problems. :)
------------------------------
Date: 12 Jun 2001 12:01:41 -0700
From: oooozaaaa@yahoo.com (oza)
Subject: help with regexp?
Message-Id: <106a220d.0106121101.7382a976@posting.google.com>
This question suits to webserver newsgroups too, but I know there are
lots of regexp guys here. so here is my question:
I will use Apaches rewrite module to translate the url in first line
to the one in second line below:
www.mysite.com/top/scriptname/modename/idnum
www.mysite.com/scriptname.php?mode=modename&id=idnum
Every url like the first one will be translated to second one in my
website. Since almost all of the pages will be like this, performance
of the regexp I use is important.
I consider these:
/top/([^/]*)/([^/]*)/(.*) /$1.php?mode=$2&id=$3 [L,R]
or
/top/(.*)/(.*)/(.*) /$1.php?mode=$2&id=$3 [L,R]
which one of these will perform better? Or will them work at all? Or
do you recommend another one?
Since I am on a virtual server, I want to make sure they will work
before asking host admin to put these to httpd.conf.
any help appreciated.
------------------------------
Date: Tue, 12 Jun 2001 19:01:04 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: help with regexp?
Message-Id: <992372464.109134168829769.gnarinn@hotmail.com>
In article <106a220d.0106121101.7382a976@posting.google.com>,
oza <oooozaaaa@yahoo.com> wrote:
>I will use Apaches rewrite module to translate the url in first line
>to the one in second line below:
>
>www.mysite.com/top/scriptname/modename/idnum
>www.mysite.com/scriptname.php?mode=modename&id=idnum
>
>Every url like the first one will be translated to second one in my
>website. Since almost all of the pages will be like this, performance
>of the regexp I use is important.
>
>I consider these:
>/top/([^/]*)/([^/]*)/(.*) /$1.php?mode=$2&id=$3 [L,R]
>
>or
>/top/(.*)/(.*)/(.*) /$1.php?mode=$2&id=$3 [L,R]
this one will not work, unless Rewrite regexes differ from perl ones
may be this one will:
/top/(.*?)/(.*?)/(.*?) /$1.php?mode=$2&id=$3 [L,R]
>Since I am on a virtual server, I want to make sure they will work
>before asking host admin to put these to httpd.conf.
why not put them in the .htaccess file ?
gnari
------------------------------
Date: 12 Jun 2001 14:46:17 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: help with regexp?
Message-Id: <m3lmmxlbw6.fsf@dhcp9-173.support.tivoli.com>
On 12 Jun 2001, oooozaaaa@yahoo.com wrote:
[snip]
> www.mysite.com/top/scriptname/modename/idnum
> www.mysite.com/scriptname.php?mode=modename&id=idnum
>
> Every url like the first one will be translated to second one in my
> website. Since almost all of the pages will be like this,
> performance of the regexp I use is important.
>
> I consider these:
> /top/([^/]*)/([^/]*)/(.*) /$1.php?mode=$2&id=$3 [L,R]
>
> or
> /top/(.*)/(.*)/(.*) /$1.php?mode=$2&id=$3 [L,R]
>
> which one of these will perform better? Or will them work at all? Or
> do you recommend another one?
As written, neither will work because of the overuse of "/". Also, I
don't know the significance of the "[L,R]" at the end.
s{/top/([^/\s]*)/([^/\s]*)/([^/\s]*)}
{/$1.php?mode=$2&id=$3}g
Restricting the matches to "[^/\s]" allows you to more readily handle
multiple substitutes at a time if the URLs are embedded within other
text. If you use ".*?" instead, then any URLs that are too short will
lead to a bunch of extra text being included. Of course, if there is
no other text, then this will not be a problem.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 12 Jun 2001 13:43:26 -0700
From: steve.busiello@gs.com (Steven)
Subject: Re: Help with split?vvp
Message-Id: <fa45b871.0106121243.72c1628e@posting.google.com>
I would do it like this:
$line = "a|b|c|d|e|f|g";
substr($line,0,1) = "0";
print "$line \n";
A little reverse substr jammy ...
Otherwise
Try this: ( definately not the best way, but following your thinking )
$line = "a|b|c|d|e|f|g";
($a,@items)=split /\|/,$line;
print "0|".join("|",@items)."\n";
-Steven
"Prasad, Victor [FITZ:K500:EXCH]" <vprasad@americasm01.nt.com> wrote in message news:<3B26297F.9BB8F76A@americasm01.nt.com>...
> Hello,
>
> I have a small script that takes a PIPE ( | ) delimited file that is
> suppose to strip the first field away, replace it with a 0 then keep the
> rest of the | delimited fields.
>
> ie.
>
> file (many lines)
>
> a|b|c|d|e|f|g
>
> output to new file should be
>
> 0|b|c|d|e|f|g
>
> what happens...the file contains this
>
> 0|2
>
> I have to use a PIPE (|) - because that is the standard for all our
> files.
>
> Script:
>
> open (rf,"$filename");
>
> open (faxtemp,">$filename.txt");
> while($line=<rf>) {
> ($a,$items)=split /|/,$line;
> print faxtemp "0|$items \n";
>
> }
> close (rf);
>
> help?
>
> Thanks,
>
> V
------------------------------
Date: 12 Jun 2001 21:01:10 GMT
From: rolf.krahl@gmx.net (Rolf Krahl)
Subject: Re: Help with split?vvp
Message-Id: <9g5vum$t17$2@rotkraut.de>
In article <3B26552D.3603F6BA@stomp.stomp.tokyo>,
"Godzilla!" <godzilla@stomp.stomp.tokyo> writes:
>
> I have copied out and tested a variety of methods
> posted. You will do well to always test code before
> posting and, you will do well to always test posted
> code before use.
>
> You will discover only my code works correctly simply
> as a result of testing my code before posting.
>
> Typically, files are terminated with a newline, yes?
Yes, but your test file was not only terminated with a newline, but
got an extra empty line after the last newline, e.g. you did not test
| a|b|c|d|e|f|g
| h|i|j|k|l|m|n
| o|p|q|r|s|t|u
but
| a|b|c|d|e|f|g
| h|i|j|k|l|m|n
| o|p|q|r|s|t|u
|
Now, one might discuss the semantik of empty lines in the file format
described by Victor's OP and how a script with the described task
should react on empty lines.
--
Rolf Krahl <rolf.krahl@gmx.net>
------------------------------
Date: Tue, 12 Jun 2001 14:39:35 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Help with split?vvp
Message-Id: <3B268C17.33686CE@stomp.stomp.tokyo>
Rolf Krahl wrote:
> Godzilla! wrote:
> > I have copied out and tested a variety of methods
> > posted. You will do well to always test code before
> > posting and, you will do well to always test posted
> > code before use.
> > You will discover only my code works correctly simply
> > as a result of testing my code before posting.
> > Typically, files are terminated with a newline, yes?
> Yes, but your test file was not only terminated with a newline, but
> got an extra empty line after the last newline, e.g. you did not test
> | a|b|c|d|e|f|g
> | h|i|j|k|l|m|n
> | o|p|q|r|s|t|u
Your comments are incorrect. This is my data format with
"visible" newlines \n added:
a|b|c|d|e|f|g\n
h|i|j|k|l|m|n\n
o|p|q|r|s|t|u\n
There are no other lines following my final \n
character. Read about and research $/ and its
relationship to a while loop along with how
input lines are record separated.
I would suggest you test your code again,
with a typical input file format.
Godzilla!
------------------------------
Date: Tue, 12 Jun 2001 15:00:29 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Help with split?vvp
Message-Id: <3B2690FD.926ABE1E@stomp.stomp.tokyo>
Rolf Krahl wrote:
> Godzilla! writes:
(snipped)
> Yes, but your test file was not only terminated with a newline, but
> got an extra empty line after the last newline, e.g. you did not test
> | a|b|c|d|e|f|g
> | h|i|j|k|l|m|n
> | o|p|q|r|s|t|u
> but
> | a|b|c|d|e|f|g
> | h|i|j|k|l|m|n
> | o|p|q|r|s|t|u
> |
In keeping with my reputation for being fair but firm,
I ran tests on my programmer editor to discover how it
saves or not saves a newline character at the end of
a file. I am including "\n" to make newlines visible.
Each newline is actually created with my Enter key.
My first test is this format:
a|b|c|d|e|f|g\n
h|i|j|k|l|m|n\n
o|p|q|r|s|t|u
I save this file, reopen it and do a search and
replace of all newlines with an X:
a|b|c|d|e|f|gXh|i|j|k|l|m|nXo|p|q|r|s|t|uX
My next test is this format:
a|b|c|d|e|f|g\n
h|i|j|k|l|m|n\n
o|p|q|r|s|t|u\n
After a search and replace, this results:
a|b|c|d|e|f|gXh|i|j|k|l|m|nXo|p|q|r|s|t|uX
Perhaps what you are noting is a difference
in behavior of program editors. I will test
this by having Perl write a file, using both
formats above, and discover what happens.
This will provide a test independent of
my program editor and hopefully disclose
what is truly happening.
I will post my results regardless of outcome.
Godzilla!
------------------------------
Date: 12 Jun 2001 14:36:28 -0700
From: steve.busiello@gs.com (Steven)
Subject: Re: How to make a Perlscript Shareware?
Message-Id: <fa45b871.0106121336.23a10231@posting.google.com>
Or use perl2exe
http://www.indigostar.com/perl2exe.htm
-Steven
"flash" <bop@mypad.com> wrote in message news:<WAnV6.3572$mK6.350707@news20.bellglobal.com>...
> I just wrote a script that encrypts the data.
> And then decrypts to a temporary location, and runs the program, and deletes
> it. (decrypted version)
>
> Then you would probally perlcc that script, so no one can change it.
>
> --
> #--*--*--*--*--*--*--*--*--*--*--#
> # The hypermart faq. #
> # http://www.hmdc.f2s.com #
> #--*--*--*--*--*--*--*--*--*--*--#
>
> "Tom Klinger" <admin@the-piper.net> wrote in message
> news:3b25e7e3$1@news.i-one.at...
> > Hi!
> >
> > Maybe my idea differs from the base intention of perl that code is free.
> > From my point of view why not earn money with your code when it is used by
> a
> > company which makes finally money using your script while you have to
> > develope all that code?
> >
> > Now, I want to go to develope 2 different versions of my software, one
> > so-called lite version with less features and options than the second
> > version, a so-called pro version with all enhancements.
> >
> > My problem now is how to secure the code so that for example a pro version
> > will expire for example after 30 days or only runs if is already licensed?
> > I know that there are too many gurus out there who can modify the code,
> > sure.
> > But why not give it a try?
> >
> > So my question now is if someone can give me a tip how to handle this or
> > maybe he can tell me the way how they're securing their code or methods to
> > purchase a software. Any information would be great.
> >
> > Thanks in advance and for your time reading my written crap. ;)
> >
> > Tom
> >
> >
------------------------------
Date: 12 Jun 2001 13:55:59 -0700
From: roger.larsen@no.abb.com (Roger Larsen)
Subject: Key facts from exported System Info.-report (msinfo32.exe)
Message-Id: <f9a93251.0106121255.67bc81b3@posting.google.com>
Dear Perl Users,
I want to extract the key facts from several exported system-info.-
reports (msinfo32.exe in Win95/8/NT4/2000). These reports are often
over 2000 lines. I just need the key facts regarding the hardware
in our computers (CPU/RAM/HDD/CD-ROM/...).
Do You know any Perl-scrips that can help me here?
Regards,
Roger Larsen
ABB A/S
------------------------------
Date: 12 Jun 2001 11:26:27 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Last Chance for Damian's Advanced OO Perl class
Message-Id: <m1zobd5zcc.fsf@halfdome.holdit.com>
>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:
Uri> the advanced object oriented perl class in boston is almost full. it is
Uri> being taught by damian conway on tue-wed, july 10-11. for more info read
Uri> this page:
Uri> http://www.sysarch.com/perl/OOP_class.html
Uri> there are 2 seats left open. if you want to attend this class you must
Uri> register soon or you won't be able to take it on the east coast until
Uri> next year.
The West Coast version of this class is Aug 1-2, and has just
opened up for registration... see
<http://cpd.ogi.edu/courseSpecific.asp?pam=713>
And Damian's also teaching his "text wrangling" course on Aug 3...
<http://cpd.ogi.edu/courseSpecific.asp?pam=714>
Seats are limited, available on first-come, first-serve basis only.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Tue, 12 Jun 2001 17:53:45 -0400
From: "kevin" <emailkevin@charter.net>
Subject: log file parsing
Message-Id: <tid3rk116i2i5b@corp.supernews.com>
can someone show me how to read each new line of a log file and then take
some action, and then read the next? Thanks
------------------------------
Date: 12 Jun 2001 14:08:38 -0700
From: mnemotronic@yahoo.com (pt)
Subject: Marble lossage in "or" vs. "||"
Message-Id: <da662010.0106121308.68c31a5a@posting.google.com>
Given that both "or" and "||" are logical operators, all four subs
should return TRUE, but only three do. Why doesn't "or_3" ?? Is the
first '0' eloping with the 'return'?
sub or_1()
{
# This works.
0 or 0 or (1 && 1 && 1) ;
}
sub or_2()
{
# This works.
0 || 0 || (1 && 1 && 1) ;
}
sub or_3()
{
# this doesn't work!
return 0 or 0 or (1 && 1 && 1) ;
}
sub or_4()
{
# This works.
return 0 || 0 || (1 && 1 && 1) ;
}
For extra credit, guess which method I choose...
------------------------------
Date: Tue, 12 Jun 2001 21:18:38 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Marble lossage in "or" vs. "||"
Message-Id: <4h1dit4g4dc7ijb8qk3cj50u7aqnndchvh@4ax.com>
pt wrote:
>sub or_3()
>{
> # this doesn't work!
> return 0 or 0 or (1 && 1 && 1) ;
>}
because it gets interpreted as
(return 0) or 0 or (1 && 1 && 1);
So it never gets to the remainder of the statement.
Remember, the precedence of "or" is extremely low. Lower than most
expressions commonly looked at as statements, anyway.
Another example:
sub and_1 {
return "abc" and "xyz";
}
print and_1;
-->
abc
sub and_2 {
return ("abc" and "xyz");
}
print and_2;
-->
xyz
>sub or_4()
>{
> # This works.
> return 0 || 0 || (1 && 1 && 1) ;
>}
It gets interpreted as
return (0 || 0 || (1 && 1 && 1));
> For extra credit, guess which method I choose...
Er... 3?
--
Bart.
------------------------------
Date: Tue, 12 Jun 2001 19:49:32 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: modules (no, not perl modules)
Message-Id: <gnuV6.140828$I5.37873128@news1.rdc1.tn.home.com>
Where can I learn to build a perl app that's advanced enough to be able to
load other outside modules (written for it, not Perl modules), and use that
code? How do you make a script know when to give control to an outside
module and what to expect back?
------------------------------
Date: Tue, 12 Jun 2001 20:21:19 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: Re: My senior project is "done"
Message-Id: <3RuV6.75502$G5.16118598@news1.rdc1.md.home.com>
In article <3B211E37.121A0545@earthlink.net>,
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>Or how about
>use Quantum::Superpositions BINARY => [ CORE::index ];;
>
> if( index( $urlcontent, any(@page_array) ) > -1 ) {
> # code to execute goes here
> }
I thought this was a joke, but on a lark I went looking
for that module, and found it. Damian has blown my mind yet again.
(Out of curiosity, can someone explain what the eigenstate of a
perl superposition would be? Damian mentions it in his
Data::Superposition paper, but the talk it references isn't online
yet. The any and all operators are much easier to grok in this
context.)
-- Sweth.
--
Sweth Chandramouli ; <sweth+perl@gwu.edu>
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.
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 V10 Issue 1120
***************************************