[12054] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5654 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 13 15:07:15 1999

Date: Thu, 13 May 99 12:01:39 -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           Thu, 13 May 1999     Volume: 8 Number: 5654

Today's topics:
    Re: Newbie question on CGI developing <upsetter@ziplink.net>
    Re: param parsing <aqumsieh@matrox.com>
    Re: pattern matching ? <bowen@imall.com>
    Re: Perl cgi on a standalone PC? <bwlang@genome.wi.mit.edu>
    Re: perldoc question (Larry Rosler)
        Perlscript error sureshvv@hotmail.com
    Re: Perlscript error <t-armbruster@ti.com>
        Please Help:  Am I creating the hash wrong, or accessin (Laurence Leider)
        read file assign variables mikecard@my-dejanews.com
    Re: read file assign variables <brectanu@vt.edu>
    Re: read file assign variables (Larry Rosler)
    Re: read file assign variables <ebohlman@netcom.com>
        regexp ?: how to ignore escaped delimiter? (Spica)
    Re: regexp ?: how to ignore escaped delimiter? <bwlang@genome.wi.mit.edu>
    Re: regexp ?: how to ignore escaped delimiter? (Larry Rosler)
    Re: regexp ?: how to ignore escaped delimiter? (Spica)
    Re: Security issues wth Perl-Win32 <droby@copyright.com>
    Re: Shopping Cart (Charles R. Thompson)
    Re: SLOC <sto@storm.com>
    Re: Sorry if this is FAQ-ing obvious <cassell@mail.cor.epa.gov>
        SRC: dejaview -- Easily search DejaNews (1st Revision) (Matthew Bafford)
        teach perl? <ferhad@aneiva.com>
    Re: translating FAT to VFAT <swarren@www.wwwdotorg.org>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 13 May 1999 16:18:20 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Newbie question on CGI developing
Message-Id: <gXC_2.195$9x5.57406@news.shore.net>

Arjun Ray <aray@nmds.com> wrote:
: system' needed to make this work: everyone manages to come up with
: their own ad hoc 'tag system', the overall consequence of which is
: that source files are neither fish nor fowl: not HTML documents, not
: Perl scripts, just, well, some kinda sorta 'tag system' files.

: For lookup-based substitutions, I've usually found it simpler just to
: take advantage of the SGML entity reference mechanism.

I'm probably not the only Perl user on this group who would appreciate a
pointer to some information on learning SGML. I'm "guilty" of using
home-rolled "tag systems" because they get the job done and once I devised
a reasonably-flexible system, they weren't that hard to adapt to a given
job. But I'm always open to learning a better way.

--Art

-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


------------------------------

Date: Thu, 13 May 1999 12:22:32 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: param parsing
Message-Id: <x3yogjpndmf.fsf@tigre.matrox.com>


"james gough" <jgough@163.net> writes:

> HI, all,
> I always see people define subs like these:
> sub MySub($) {
> sub MySub($$$) {
> sub MySub($@)  {
> 
> how do these $ and @ affect the parameter parsing?

These declarations simply prototype the function to take in a
specified number and type of variables. For more info, consult the
'perlsub' doc.

HTH,
Ala



------------------------------

Date: Thu, 13 May 1999 10:22:08 -0600
From: Peter Bowen <bowen@imall.com>
Subject: Re: pattern matching ?
Message-Id: <373AFC30.1EDD8DFF@imall.com>

Normally I just sit back and let the reg exp gurus go wild, but this
really is more than a simple pattern match.   The pattern match was
fine, but catching the correct keyword, and then applying the switch was
what caught my eye...

# Perl init stuff here :)

my %list = ("si1_code" => 1,
	    "si2_code" => 1,
	    "si3_code" => 1);

open(FILE,"myfile.txt");
while (my $line=<FILE>) {
    my $junk;
    my ($keyword,$value) = split / = /, $line;
    if  ($list{$keyword}) { # why go further if we don't need to...
	($junk,$value) = split /b/,$line;
	chomp $value; 
	$value =~ s/\;//;
	# execute a subroutine for this keyword.
	&{$keyword}($value);	
    }
}

sub si1_code {
    my $keyword = "si1_code";
    my $value = shift;
    # Have your way with $value		
}

etc...

Good luck,
-Peter


tvn007@my-dejanews.com wrote:
> 
> Hi,
> 
> Would someone help me on this ?
> 
> Problem:
> 
> I have to read every single line from a file and search for
> a keyword such as si1_code , si2_code, si3_code.
> 
> below is a small sample of input file:
> 
> si1_code = 135'b110011;
> si2_code = 2413'b11010010;
> si3_code = 2513'b0010101101;
> 
> The only thing I would like to get from
> si1_code is 110011
> and si2_code is 11010010
> ....
> 
> My solution on this problem require many  steps as shown below:
> while (<INFILE>) {
> chomp;
> 
>      $_ =~ s/;//;  # get rid of the ;
>      $_ =~ s/'b/ /;
>      @line = split;
> 
>     if ($line[0] eq "s1_code") {
> 
>      "do something"
> 
>      }
>   elsif ($line[0] eq "s2_code") {
> 
>      "do something"
>     }
> }
> 
> I really appreciate if you can give me a better solution.
> 
> Thanks in advance,
> 
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---

-- 
Peter Bowen
Unix System Programmer
iMALL Inc.
bowen@imall.com
(801)226-5007


------------------------------

Date: Thu, 13 May 1999 14:00:30 -0400
From: "Bradley W. Langhorst" <bwlang@genome.wi.mit.edu>
Subject: Re: Perl cgi on a standalone PC?
Message-Id: <373B133E.6FAB063F@genome.wi.mit.edu>

i think you'd need to ship a webserver on that cdrom

brad



------------------------------

Date: Thu, 13 May 1999 10:11:54 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: perldoc question
Message-Id: <MPG.11a4a7b3d749c16989a5b@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <373A1509.3567554E@mail.cor.epa.gov> on Wed, 12 May 1999 
16:55:53 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
> Larry Rosler wrote:
 ...
> > Welcome to Unixland.  That refers to "Section 2: System Calls" in the
> > venerable Unix manual.
> > 
> > Section 1 is User Commands, such as cat(1).
> > 
> > Section 3 is Library Functions, such as printf(3).
> > 
> > The rest, you don't want to hear about.  Take my word for it!
> 
> What about section 6 ??  Don't forget the games!  :-)

My HP-UX manual has (in three volumes) Section 1; Sections 2 and 3; 
Sections 1M, 4, 5, and 7.  No Section 6.  What are they trying to tell 
us?

> David, who many consider to *be* deserving of a section 8...

And no Section 8 either.  Catch 22...

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Thu, 13 May 1999 16:50:59 GMT
From: sureshvv@hotmail.com
Subject: Perlscript error
Message-Id: <7hevtg$gec$1@nnrp1.deja.com>

I recently downloaded Perlscript from ActiveState
on my windows-nt server. When I load the plhello.htm
example, it appears fine on the screen. But when I hit the
PerlScript button, I get an error saying:

Cannot call method "Text1" on an undefined value at line 4...

In fact, I get the same kind of error when I hit any button
on any of the example pages(RPN Calculator, Mouse tracker).
But they all appear to load correctly
and look correct on the screen.

Any help appreciated.

Thanks.

suresh


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


------------------------------

Date: Thu, 13 May 1999 13:14:01 -0500
From: "Tim Armbruster" <t-armbruster@ti.com>
Subject: Re: Perlscript error
Message-Id: <THE_2.28$401.2621@dfw-service1.ext.raytheon.com>


sureshvv@hotmail.com wrote in message <7hevtg$gec$1@nnrp1.deja.com>...
>PerlScript button, I get an error saying:
>
>Cannot call method "Text1" on an undefined value at line 4...
>


That is PerlScript, not Perl.  I guess there really isn't a newsgroup for
PerlScript, though.  There are mailing lists and FAQs at www.activestate.com

What browser are you using?  PerlScript requires MSIE 3.0, I believe.




------------------------------

Date: Thu, 13 May 1999 18:04:56 GMT
From: lleider@mmm.com (Laurence Leider)
Subject: Please Help:  Am I creating the hash wrong, or accessing its elements wrong?
Message-Id: <373b115e.16152325@news.mmm.com>

Judging from the output I get, the same list of references is assigned
to every element of %newhash.  These references all point to the data
contained in the last three elements in %syncdata (they all have the
same branch code).

What I expected was a hash of a lists, each list being a list of 3
list references.

Everything upstream from this code has worked as I expected.  I can
print the contents of %syncdata and confirm the results.  I suspect
the problem is with my push statement, but I cannot figure it out.

Let me know if you want more information.  I am still working on this,
but thanks for any help you can offer in the meanwhile.

LL
===================================================

#build new hash from old, this time with branch code as key.
@count = sort keys %syncdata;
foreach $element (@count) {
   ($model, $branch, $type, $date, $name) = @{$syncdata{$element}};
   push @{$newhash{$branch}}, [($model, $type, $date, $name)];
}

# print newhash for debug
@count = sort keys %newhash;
foreach $element (@count) {
   print "$element","\n";
   ($one, $two, $three) = @{$newhash{$branch}};
   print "@$one, @$two, @$three","\n";
}



Opinions expressed herein are my own and may not represent those of my employer.



------------------------------

Date: Thu, 13 May 1999 16:38:59 GMT
From: mikecard@my-dejanews.com
Subject: read file assign variables
Message-Id: <7hev72$fk9$1@nnrp1.deja.com>

hi

i am trying to get the basics of perl down, i have written a script
which seems to be correct but won't work:


#!/usr/bin/perl -w

open (LINKS, "linkdata.txt") or die "can't open file\n";
while (<LINKS>) {
	chomp ($link = <LINKS>);
	chomp ($description = <LINKS>);
}
close LINKS;

print "$link";
print "$description";

#the end

linkdata.txt is a txt file with this:

www.place.com
a groovy place to visit
ppp.he.net
oh this one rox

what i want is for the first line to be assigned to $link and the second
line to be $description (i am aware that the next time through the loop
these variables  will be reassigned, this program is meant to be
educational not functional)

when i run the script i get this message

Use of uninitialized value at test2.cgi line 5, <LINKS> chunk 4.
Use of uninitialized value at test2.cgi line 6, <LINKS> chunk 4.
Use of uninitialized value at test2.cgi line 10.
Use of uninitialized value at test2.cgi line 11.


why?

mike cardeiro


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


------------------------------

Date: Thu, 13 May 1999 13:07:46 -0400
From: Brian Rectanus <brectanu@vt.edu>
Subject: Re: read file assign variables
Message-Id: <373B06E2.669F2A86@vt.edu>

You cannot use uninitialized variables whaen using the -w flag.

Put in (before the loop):
$link = '';
$description = '';

or better:
my $link = '';
my $description = '';

-Brian

mikecard@my-dejanews.com wrote:
> 
> hi
> 
> i am trying to get the basics of perl down, i have written a script
> which seems to be correct but won't work:
> 
> #!/usr/bin/perl -w
> 
> open (LINKS, "linkdata.txt") or die "can't open file\n";
> while (<LINKS>) {
>         chomp ($link = <LINKS>);
>         chomp ($description = <LINKS>);
> }
> close LINKS;
> 
> print "$link";
> print "$description";
> 
> #the end
> 
> linkdata.txt is a txt file with this:
> 
> www.place.com
> a groovy place to visit
> ppp.he.net
> oh this one rox
> 
> what i want is for the first line to be assigned to $link and the second
> line to be $description (i am aware that the next time through the loop
> these variables  will be reassigned, this program is meant to be
> educational not functional)
> 
> when i run the script i get this message
> 
> Use of uninitialized value at test2.cgi line 5, <LINKS> chunk 4.
> Use of uninitialized value at test2.cgi line 6, <LINKS> chunk 4.
> Use of uninitialized value at test2.cgi line 10.
> Use of uninitialized value at test2.cgi line 11.
> 
> why?
> 
> mike cardeiro
> 
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---

--
Brian Rectanus
brectanu@vt.edu


------------------------------

Date: Thu, 13 May 1999 11:34:57 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: read file assign variables
Message-Id: <MPG.11a4bb28bc4b4e40989a5d@nntp.hpl.hp.com>

In article <373B06E2.669F2A86@vt.edu> on Thu, 13 May 1999 13:07:46 -
0400, Brian Rectanus <brectanu@vt.edu> says...
> mikecard@my-dejanews.com wrote:
 ...
> > #!/usr/bin/perl -w
> > 
> > open (LINKS, "linkdata.txt") or die "can't open file\n";
> > while (<LINKS>) {
> >         chomp ($link = <LINKS>);
> >         chomp ($description = <LINKS>);
> > }
> > close LINKS;
> > 
> > print "$link";
> > print "$description";
 ...
> > www.place.com
> > a groovy place to visit
> > ppp.he.net
> > oh this one rox
> > 
> > what i want is for the first line to be assigned to $link and the second
> > line to be $description (i am aware that the next time through the loop
> > these variables  will be reassigned, this program is meant to be
> > educational not functional)
> > 
> > when i run the script i get this message
> > 
> > Use of uninitialized value at test2.cgi line 5, <LINKS> chunk 4.
> > Use of uninitialized value at test2.cgi line 6, <LINKS> chunk 4.
> > Use of uninitialized value at test2.cgi line 10.
> > Use of uninitialized value at test2.cgi line 11.
> > 
> > why?

> You cannot use uninitialized variables whaen using the -w flag.
> 
> Put in (before the loop):
> $link = '';
> $description = '';
> 
> or better:
> my $link = '';
> my $description = '';

Sorry, wrong.  Declaring variables is good (and required by 'use 
strict;'), but initializing them has absolutely nothing to do with this 
problem.

The problem is that every pass through the loop reads three lines (not 
two, as desired).  So the second pass reads the nonexistent fifth and 
six lines of the file into the variables.  Thus they become undefined at 
that point, whether or not they were initialized earlier.

The following code does what the submitter wants.  It is not the best 
way, but it has the fewest changes to his code.

#!/usr/bin/perl -w
use strict;

my ($link, $description); # Not initialized, see...

until (eof DATA) {
        chomp ($link = <DATA>);
        chomp ($description = <DATA>);
}

print $link;
print $description;
__END__
www.place.com
a groovy place to visit
ppp.he.net
oh this one rox

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Thu, 13 May 1999 18:54:46 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: read file assign variables
Message-Id: <ebohlmanFBopvA.JyJ@netcom.com>

mikecard@my-dejanews.com wrote:
: i am trying to get the basics of perl down, i have written a script
: which seems to be correct but won't work:

You've got a fairly common newbie mistake or two, but they can easily be 
fixed:

: #!/usr/bin/perl -w

*Very* good.  You *don't* have the common newbie mistake of leaving off 
the -w.

: open (LINKS, "linkdata.txt") or die "can't open file\n";

And you remembered to check your system calls for success!  Hint: if you 
stick a ':$!' right after 'file', you'll get an error message that tells 
you *why* you couldn't open the file.  Saves tons of debugging time.

 : while (<LINKS>) {

Each time around the loop, this reads a line of text into $_.

: 	chomp ($link = <LINKS>);

This reads a line of text into $link.

: 	chomp ($description = <LINKS>);

This reads a line of text into $description.

: }

So each time around the loop, you're reading three lines out of the 
file.  However, your description below says that your lines come in 
pairs.  You're getting the warning messages because the second time 
around your loop, you're trying to read past the end of the file, so 
<LINKS> is giving you an undefined result.

: close LINKS;

: print "$link";
: print "$description";

Assuming the problems in the loop were fixed, this would print the values 
from the *last* two lines of the file.  I suspect you want to print them 
for *each* entry in the file.  If that's the case, you need to move these 
two lines *inside the loop*.

See if you can figure out on your own how to fix the loop; a correct 
solution will have at most two instances of <LINKS>, and should insure 
that neither $link nor $description ever gets set to an undefined value.



------------------------------

Date: Thu, 13 May 1999 16:21:47 GMT
From: reply@newsgroup.please (Spica)
Subject: regexp ?: how to ignore escaped delimiter?
Message-Id: <373afa21.252387914@news2.realtime.net>

I hope that I don't make any major faux pas in this, my first post.
I'm just getting started here and I've run into a snag. I've got a
text file that is delimited with the vertical bar:  |. However, there
are a few fields that have an excaped vertical bar: \|. I would like
to ignore these. So, here is what my script looks like so far:

$ErrorCount = 0;
$TotalErrorCount = 0;
open (RESULTS, $newfile);
while (<RESULTS>) {  
	# split the record into fields
	($TestPlan, $Script, $TestCase, $TestData, $ErrorCount,
$ErrorText, $WarningCount, $WarningText, $DateTime, $Elapsed) = split
(/\|/,$_);
	
	# Calculate error total
	$TotalErrorCount += $ErrorCount;
}
print "Total error count: ",$TotalErrorCount;

and an example of a record where it doesn't work is:

master.pln|Unit_Testing\Scripts\LogicalView\LV_DataObject.t|ModifyObjectName|5,
"\|MyTable", 3|0||0||1999-05-11 18.23.49|0:00:09

I'll get the error:

Argument "MyTable", 3" isn't numeric in add at filetest.pl line 13,
<RESULTS> chunk 22. 

How can I skip occurences of \|? I tried:

	($TestPlan, $Script, $TestCase, $TestData, $ErrorCount,
$ErrorText, $WarningCount, $WarningText, $DateTime, $Elapsed) = split
(/[^\\]\|/,$_);

but that was worse than before.

Any help for a newbie is much appreciated. 

TIA, Spica


------------------------------

Date: Thu, 13 May 1999 13:58:55 -0400
From: "Bradley W. Langhorst" <bwlang@genome.wi.mit.edu>
Subject: Re: regexp ?: how to ignore escaped delimiter?
Message-Id: <373B12DF.1655D711@genome.wi.mit.edu>

i can't help you with a better regex to split (though i think it is possible) on
but i
think you can get around this problem by

$_~= s/\\|/%%/g;
        ($TestPlan, $Script, $TestCase, $TestData, $ErrorCount,
$ErrorText, $WarningCount, $WarningText, $DateTime, $Elapsed) = split
(/\|/,$_);
$_~= s/%%/\\|/g

essentially replace your escaped pipe with something else
do the split then re-replace your substitution character with your
escaped pipe.
its a kludge but should work

>



------------------------------

Date: Thu, 13 May 1999 11:13:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: regexp ?: how to ignore escaped delimiter?
Message-Id: <MPG.11a4b6106d7ed91d989a5c@nntp.hpl.hp.com>

In article <373afa21.252387914@news2.realtime.net> on Thu, 13 May 1999 
16:21:47 GMT, Spica <reply@newsgroup.please> says...
> ... I've got a
> text file that is delimited with the vertical bar:  |. However, there
> are a few fields that have an excaped vertical bar: \|. I would like
> to ignore these.
 ...
> How can I skip occurences of \|? I tried:

I assume that by 'ignore' and 'skip' you mean simply not to split on the 
vertical bar if it is escaped.

Use negative lookbehind (introduced in perl5.005):

#!/usr/local/bin/perl -w
use strict;

$_ = "a|b|c\|d|e\n";

print join ' ^ ' => split /(?<!\\)\|/;
__END__

Output:

a ^ b ^ c\|d ^ e

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Thu, 13 May 1999 18:52:23 GMT
From: reply@newsgroup.please (Spica)
Subject: Re: regexp ?: how to ignore escaped delimiter?
Message-Id: <373b1dd8.261530541@news2.realtime.net>

On 13 May 1999 17:44:19 GMT, ilya@math.ohio-state.edu (Ilya
Zakharevich) wrote:

>[A complimentary Cc of this posting was sent to Steve Wells 
><wells@cedarnet.org>],
>who wrote in article <373B0BF8.1A6E064C@cedarnet.org>:
>> I hope I don't scare you away from PERL altogether with this.

No, this just seems quite challening, but I'm determined to learn how
to script in perl to help make my life easier.

>> 
>> If you want a detailed explaination of why this works then
>> please review the book:
>> 
>> "Mastering Regular Expressions" by Jeffrey E. F. Friedl
>> 
>> specifically page 205 as this is a modification of his
>> work.
>> 
>> Here's what I came up with:
>>   while (<RESULTS>) {
>>         push (@entry, defined($1) ? $1 : $3)
>>              while (m/([^\|\\]*(\\.[^\|\\]*)*)\|?|\|/g);
>>   }
>
>Yet another example of not trusting this book for best advice.

As I'm totally fresh to this regular expressions topic, I had found
this book by searching on the web and decided to order it as in aid to
learning perl. Is it not a good book? Or are some of the examples just
outdated with new revisions of perl? Any comments welcome. (I'm still
going to wait for the book order to arrive as I have 30 days to return
it but wouldn't mind hearing comments from others....)

>
>    /(?<! \\ ) \| /x
>
>starting from 5.005 (It does not handle \\|, but this was not requested.)
>
>Ilya

Thanks to all who replied to my call for help. I'm only looking to not
split on \|, btw.

Spica



------------------------------

Date: Thu, 13 May 1999 15:41:49 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: Security issues wth Perl-Win32
Message-Id: <7herrt$cs5$1@nnrp1.deja.com>

In article <87701800@NEWS.SAIC.COM>,
  "Darren Bennett" <bennettd@asdi.saic.com> wrote:
> Jonathan,
>
>         You are a bored young man aren't you??

Has any of this indicated his age?

>
> You win.. I'm done with this 'thread' .. sorry to have wasted so much
> bandwidth trying to get some knowledge from you.
>

To obtain knowledge, you must ask real questions.  Your question sounded
like nothing but FUD.  If you post a description of a real security hole
alleged to originate in Perl, we'd certainly be happy to discuss it.

You asked about security problems with using Perl to perform
administrative tasks on NT.  He answered.  There are security holes in
NT.  They have nothing to do with Perl.

If you write administrative tools in Perl (or any language) for NT (or
any OS) you can make them insecure by bad coding.  See the perlsec
manpage for hints on programming securely in Perl.  The document has a
Unix slant, but most of the same principles apply anywhere.

If you make those administrative tools into CGI scripts, it's even
easier to screw up.  But it still isn't Perl that's the problem.

--
Don Roby


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


------------------------------

Date: Thu, 13 May 1999 16:31:04 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: Shopping Cart
Message-Id: <MPG.11a4c99a6545cd389896be@news>

[ Congratulations, waxpack@my-dejanews.com you could be a winner! Return 
to comp.lang.perl.misc to claim your prize. ]

In article <7heg9u$440$1@nnrp1.deja.com>, waxpack@my-dejanews.com says...
> I

<snip>

> m

Had you been the ambitious sort who wanted to learn Perl to fix said 
script, I might have helped. This isn't a community bulletin board or a 
classified section. Wrong group.

-- 
CT


------------------------------

Date: Thu, 13 May 1999 16:01:37 +0000
From: Scott Oglesby <sto@storm.com>
Subject: Re: SLOC
Message-Id: <373AF761.5B952C70@storm.com>

Alastair wrote:
> 
> Larry Rosler <lr@hpl.hp.com> wrote:
> >
> >'Source Lines of Code in C++ files' is not the same as the number of
> >lines in the files.  Some parsing is necessary to remove blank lines and
> >lines that are exclusively comments.  (I believe one counts preprocessor
> >directives and conditionally compiled code as source lines.)
> 
> Absolutely true. As I wrote the reply I thought 'should I mention comments,
> blanks lines etc.?' However, my thoughts were that getting to the stage of
> counting 'lines of code' would inevitably lead to looking at what one wanted to
> ignore. I would never consider 'source lines of code' as a simple 'wc -l'.
> 
> Best Wishes,
> 
> --
> 
> Alastair
> work  : alastair@psoft.co.uk
> home  : alastair@calliope.demon.co.uk

One compromise that has worked for us is to count semicolons outside of
comments.
It still skews for different coding styles, but not by much, and the
file parsing is
not complex.

It's probably more useful for comparing SLOC between revisions than
counting SLOC
in a new project.

Our implementation is in C, but you could whip one up in Perl, probably
by slurping
the entire file in and saying $semis = tr/;/;/;
This doesn't ignore comments, but even that might be good enough, unless
your programmers
decide to bump up their SLOC with comments like /*
;;;;;;;;;;;;;;;;;;;;;;; */

-- 
Scott Oglesby, System Architect
L-3 / Storm Control Systems
Statements here are my own, not the company's.


------------------------------

Date: Thu, 13 May 1999 11:35:54 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Sorry if this is FAQ-ing obvious
Message-Id: <373B1B8A.49AF70E5@mail.cor.epa.gov>

caf wrote:
> 
> Hi,
> 
> Sorry if this is in the FAQ, or obvious, or a usual topic of discussion
> but I write heaps of shell scripts with a little reporting ( but not a
> lot ), but a lot of accessing/running binary programs.
> 
> I'd like to learn perl via practice, but most of my pattern matching,
> replacing, reporting I do by 'sed' or 'awk'.

That's okay.  Start with "Learning Perl" by Schwartz and Christiansen.
You'll find that your expertise in sed & awk will transfer quite
nicely to pattern matching and replacing in Perl.. although Perl can
do a lot of match/subst things you cannot easily do in either sed or
awk.

You'll also find that Perl has a lot of built-ins which in some cases
allow you to *not* shell out to run some binary.  In particular,
a lot of the tasks you might be doing on unix via calls to other
unix tools are available.  You might be surprised.  Pleasantly so.

But this also means that you have to re-think a shell script, since
so much of what you were doing in that script might be utterly
unnecessary, or less than optimal in Perl.  That's why there's an
a2p (awk-to-Perl) converter and an s2p (sed-to-Perl) converter which
come with the Perl install.. and no sh2p or csh2p program.

> What I'd like to know is the overhead of using the perl 'system',
> rather than running a program from within a shell script, the script
> has to fork and exec the program, does perl do the same thing ( hence
> no overhead, as a shell script does the same thing ) or something
> different ....

Not too different, although Perl gives you some interesting ways
of coping with this sort of task.  The key point is that in Perl
you won't always *need* to do so.  If there isn't a built-in to
do the job, there may be a module (available free at CPAN) which
can do the job.  

HTH,
David
-- 
David Cassell, OAO                            cassell@mail.cor.epa.gov
Senior Computing Specialist                      phone: (541) 754-4468
mathematical statistician                          fax: (541) 754-4716


------------------------------

Date: Thu, 13 May 1999 18:06:45 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: SRC: dejaview -- Easily search DejaNews (1st Revision)
Message-Id: <slrn7jm3og.brq.dragons@dragons.duesouth.net>

On Sun, 09 May 1999 21:06:37 GMT, I held myself at gun point while typing
in the following:
: Soon to be placed at my site, but I'd like some input before I put it up.

Of course, not even a week after I posted this DejaNews became Deja and
changed it's format slightly.

I've updated the original version and placed it on my website.

: Share and Enjoy!

--Matthew

-- 
http://dragons.home.duesouth.net/dejaview.html


------------------------------

Date: Thu, 13 May 1999 11:41:44 -0700
From: "Miro" <ferhad@aneiva.com>
Subject: teach perl?
Message-Id: <7hf5rr$7ed$1@news-01.meganews.com>

Anyone would like to teach me Perl? I can give something in return (like
money,..). Please contact me: ferhad@aneiva.com




------------------------------

Date: Thu, 13 May 1999 18:28:40 GMT
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: translating FAT to VFAT
Message-Id: <sRE_2.750$6x6.886@news.rdc1.sfba.home.com>

Jan-Friedrich Mutter <jfm@bigfoot.de> wrote in message
news:7he6jr$qtl$1@union.informatik.uni-muenchen.de...
> >>is there a module or method or code available which is able to
> >>translate, say 'C:\Progra~1' to 'C:\Program Files' ?
> >
> >If there is, it'd probably be at http://www.perl.com/CPAN
> >
> >However, I'm not sure there would be... How come you're getting 16-bit
> >pathnames anyway?
>
> I have modified the registry so that I can start my xterm from the
> directory by right clicking the directory and choosing "xterm here"
> from the context
> menu. The registry keys are:
> HKEY_CLASSES_ROOT\Directory\shell\Xterm here
> HKEY_CLASSES_ROOT\Directory\shell\Xterm here\command
>         (Standard) = perl xterm.pl %1
>
> xterm.pl starts my xterm. The problem is that %1 only contains the
> old FAT pathname...

Oh yes... Just an idle though... try:

         (Standard) = perl xterm.pl "%1"
                                    ^  ^
Just maybe that'd persuade Explorer that your app could take things like
spaces etc. in the filename and hence it'd give you the real name.

Or maybe you could do something like shell out to "dir ${brokenPathName}"
and parse the output for the long file-name (ick!).

--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com                http://www.techhouse.com/
mailto:swarren@wwwdotorg.org                http://www.wwwdotorg.org/
              MIME, S/MIME and HTML mail are acceptable





------------------------------

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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 5654
**************************************

home help back first fref pref prev next nref lref last post