[21783] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3987 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 17 11:06:48 2002

Date: Thu, 17 Oct 2002 08:05:14 -0700 (PDT)
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, 17 Oct 2002     Volume: 10 Number: 3987

Today's topics:
    Re: _Re: net::ftp errors news@roaima.freeserve.co.uk
    Re: Anything better than eval("\$$class\::x") ? <pinyaj@rpi.edu>
    Re: Anything better than eval("\$$class\::x") ? <bkennedy@hmsonline.com>
        Array from String <spam@stinks.com>
    Re: Array from String <jason@baugher.pike.il.us>
    Re: Array from String <spam@stinks.com>
    Re: Array from String <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Array from String <spam@stinks.com>
    Re: Array from String <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Array from String (tî'pô)
    Re: Array from String <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Array from String <spam@stinks.com>
    Re: Array from String (tî'pô)
    Re: Array from String (tî'pô)
    Re: Array from String <spam@stinks.com>
    Re: Array from String (Tad McClellan)
    Re: Array from String (Tad McClellan)
    Re: Array from String <spam@stinks.com>
    Re: can't terminate the script? <nobull@mail.com>
    Re: Code behaves differently depending on surrounding c (Tad McClellan)
        format and write to a browser <nospam@nospam.org>
    Re: How to write a wc utility in Perl? (Tad McClellan)
    Re: How to write a wc utility in Perl? (Helgi Briem)
    Re: Is perlmonks.com down today? Or is just me. <zentara@highstream.net>
    Re: Ok, so why does this one not work??? (Tad McClellan)
    Re: Pattern Matching help <vm.mayer@comcast.net>
    Re: Pattern Matching help <bernard.el-hagin@DODGE_THISlido-tech.net>
        Perl and Word (SynonymInfo) <SaschaMoe@web.de>
    Re: Perl and Word (SynonymInfo) (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 17 Oct 2002 14:26:59 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: _Re: net::ftp errors
Message-Id: <3rdmoa.ctf.ln@moldev.cmagroup.co.uk>

eric <ericehlers@hotmail.com> wrote:
> somewhere on the web i came across a snippet of code which referenced
> $ftp->message.  as far as i can tell this is an undocumented property
> in Net::Ftp.  in my experience it seems to provide an error message
> where one is otherwise unavailable.

It's indirectly documented in Net::FTP, thus:

    Methods for the adventurous
	"Net::FTP" inherits from "Net::Cmd" so methods defined in
	"Net::Cmd" may be used to send commands to the remote FTP server.

Then, in Net::Cmd we have these functions:

    message ()
	Returns the text message returned from the last command

    code ()
	Returns the 3-digit code from the last command. If a command is
	pending then the value 0 is returned

    ok ()
	Returns non-zero if the last code value was greater than zero and
	less than 400. This holds true for most command servers. Servers
	where this does not hold may override this method.

    status ()
	Returns the most significant digit of the current status code. If
	a command is pending then "CMD_PENDING" is returned.

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Thu, 17 Oct 2002 09:44:00 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Da Witch <heather710101@yahoo.com>
Subject: Re: Anything better than eval("\$$class\::x") ?
Message-Id: <Pine.A41.3.96.1021017093928.31864B-100000@vcmr-104.server.rpi.edu>

[posted & mailed]

On Thu, 17 Oct 2002, Da Witch wrote:

>>  # class->some_var(name, [value]);
>>  sub some_var {
>>    my $class = shift() . "::";
>>    my $name = shift;
>
>>    my $var = $::{$class}{$name};
>>    $$var = shift if @_;
>>    return $$var;
>>  }
>
>OK, I tried this idea, but I get an error.  This is how I re-coded
>static_x using the idea above (along with a toy version of the class
>structure):

I'm sorry.  I forgot the \ when I modified the code in my post.  I
shouldn't do that without retesting.

With the fixed code:

>    my $x = \$::{"$class::"}{'x'};

I submit that you do NOT get the effect you were looking for.  This is
because to Perl, "$class::" does not mean $class . "::", but rather, it
means "the '' variable in the package 'class'".  Just like $xyz::def is
the $def scalar in xyz, $blah:: is the ${''} variable in the package blah.

To fix this, do

  my $x = \$::{$class . "::"}{x};

or

  my $x = \$::{"${class}::"}{x};

or append the "::" to $class like I did.

-- 
Jeff "japhy" Pinyan      RPI Acacia Brother #734      2002 Acacia Senior Dean
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Thu, 17 Oct 2002 10:47:11 -0400
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Anything better than eval("\$$class\::x") ?
Message-Id: <pjqdndfQopQ9UDOgXTWcoQ@News.GigaNews.Com>


"Da Witch" <heather710101@yahoo.com> wrote in message
news:aoknhg$17h$1@reader1.panix.com...

> I want to have inheritable methods that can get/set globals in the
> subclass's package.

Since you are creating get/set methods, do you really need "official" scalar
globals?  You could maintain a lexically scoped hash in the base class that
pays attention to the class of the derived method:


package Testing::Base;

use strict;
use warnings;

my %vars; # will hold static vars for all derived classes

sub static_x {
  my $self = shift;
  my $class = ref($self) || $self;
  @_ ? $vars{$class}{'X'} = $_[0] : ($vars{$class}{'X'} || 'blank');
}


package Testing::Derived;

use strict;
use warnings;

use base 'Testing::Base';

sub new {
  bless { }, shift;
}

package Testing::Derived2;

use strict;
use warnings;

use base 'Testing::Base';

sub new {
  bless { }, shift;
}

package main;

use strict;
use warnings;

my $o1 = new Testing::Derived;
my $o2 = new Testing::Derived;

print $o1->static_x(), "\n";
$o2->static_x(rand());
print $o1->static_x(), "\n";
$o1->static_x(rand());
print $o2->static_x(), "\n";

my $o3 = new Testing::Derived2;
print $o3->static_x(), "\n";
print $o1->static_x(), "\n";
print $o2->static_x(), "\n";


By not using global scalars, you also get true encapsulation for your class
which should make OO purists happy.  As a side note, you can also put
methods in your base class to autogenerate and eval the static_ subroutines,
which could save a bunch of keystrokes if you have a lot of such variables.

--Ben Kennedy




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

Date: Thu, 17 Oct 2002 13:03:53 GMT
From: "PinkPuppy" <spam@stinks.com>
Subject: Array from String
Message-Id: <Zyyr9.833$XsJ4.45940861@news2.randori.com>

Okay, if I have the following data inside a text file (it's a group file to
be used with an .htaccess file):
admin: bob jan don peggy
developers: steve amber
users: kim whitney jo tena shari

Now, what I want to do is find a particular group(s) and cycle through all
their members.

Can someone show me an easy way to do this?




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

Date: Thu, 17 Oct 2002 13:10:53 GMT
From: Jason Baugher <jason@baugher.pike.il.us>
Subject: Re: Array from String
Message-Id: <Xns92AA533579287jasonbaugherpikeilus@209.242.76.10>

"PinkPuppy" <spam@stinks.com> wrote in comp.lang.perl.misc:

> Okay, if I have the following data inside a text file (it's a group
> file to be used with an .htaccess file):
> admin: bob jan don peggy
> developers: steve amber
> users: kim whitney jo tena shari
> 
> Now, what I want to do is find a particular group(s) and cycle through
> all their members.
> 
> Can someone show me an easy way to do this?
> 
> 
> 

Read lines from the file, comparing them with a regex against your desired 
group name, and when you find the right line, take the remainder of the 
line, split it out into a list of members, and cycle through that list, 
doing with them whatever you want to do.


-- 
Jason Baugher 
Virtual Adept Professional Consulting Services
1406 Adams Street, Quincy, IL 62301 - (217) 221-5406
jason@baugher.pike.il.us - http://baugher.pike.il.us/virtualadept


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

Date: Thu, 17 Oct 2002 13:17:56 GMT
From: "PinkPuppy" <spam@stinks.com>
Subject: Re: Array from String
Message-Id: <8Myr9.836$XsJ4.40435886@news2.randori.com>

> > Can someone show me an easy way to do this?
>
> Read lines from the file, comparing them with a regex against your desired
> group name, and when you find the right line, take the remainder of the
> line, split it out into a list of members, and cycle through that list,
> doing with them whatever you want to do.
>
> Jason Baugher
> Virtual Adept Professional Consulting Services
> 1406 Adams Street, Quincy, IL 62301 - (217) 221-5406
> jason@baugher.pike.il.us - http://baugher.pike.il.us/virtualadept
>

That was my plan, but I was hoping that someone could supply some code.




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

Date: Thu, 17 Oct 2002 13:21:09 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Array from String
Message-Id: <aomdg4$6v2$2@korweta.task.gda.pl>

In article <8Myr9.836$XsJ4.40435886@news2.randori.com>, PinkPuppy
wrote:
>> > Can someone show me an easy way to do this?
>>
>> Read lines from the file, comparing them with a regex against your desired
>> group name, and when you find the right line, take the remainder of the
>> line, split it out into a list of members, and cycle through that list,
>> doing with them whatever you want to do.
>
> 
> That was my plan, but I was hoping that someone could supply some code.


Would you like a massage while you wait for someone to do your work
for you?


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Thu, 17 Oct 2002 13:26:59 GMT
From: "PinkPuppy" <spam@stinks.com>
Subject: Re: Array from String
Message-Id: <DUyr9.837$XsJ4.44826779@news2.randori.com>

> > That was my plan, but I was hoping that someone could supply some code.
>
>
> Would you like a massage while you wait for someone to do your work
> for you?
>
>
> Cheers,
> Bernard

Not necessary.  Literary verbiage that barely qualifies for pseudocode
describing how the problem should be tackled is fine for those literate in
PERL.  I'm new to PERL.  Thus a little sample code is like a picture... it's
worth a thousand words.  I can solve this problem in less than 5 minutes
with any of  6 languages, but I'm struggling with PERL and could use some
patience.

Thanks.




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

Date: Thu, 17 Oct 2002 13:49:32 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Array from String
Message-Id: <aomf5c$jf8$1@korweta.task.gda.pl>

In article <DUyr9.837$XsJ4.44826779@news2.randori.com>, PinkPuppy
wrote:
>> > That was my plan, but I was hoping that someone could supply some code.
>>
>>
>> Would you like a massage while you wait for someone to do your work
>> for you?
>
> 
> Not necessary.  Literary verbiage that barely qualifies for pseudocode
> describing how the problem should be tackled is fine for those literate in
> PERL.  I'm new to PERL.  Thus a little sample code is like a picture... it's
> worth a thousand words.  I can solve this problem in less than 5 minutes
> with any of  6 languages, but I'm struggling with PERL and could use some
> patience.


Try writing anything and we'll help you fix errors if they crop up. If
you don't even try then you're not fooling anyone that you want to
learn Perl.


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Thu, 17 Oct 2002 15:56:38 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Array from String
Message-Id: <7bgtqugn6jk7qrfdln1qp568f5gt0fhtvh@4ax.com>

Bernard El-Hagin bravely attempted to attach 21 electrodes of
knowledge to the nipples of comp.lang.perl.misc by saying:

>Would you like a massage while you wait for someone to do your work
>for you?

Yes please!

What do you look like? ;o)


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

Date: Thu, 17 Oct 2002 13:58:02 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Array from String
Message-Id: <slrnaqtgbs.15m.bernard.el-hagin@gdndev25.lido-tech>

In article <7bgtqugn6jk7qrfdln1qp568f5gt0fhtvh@4ax.com>, Teh (tî'pô)
wrote:
> Bernard El-Hagin bravely attempted to attach 21 electrodes of
> knowledge to the nipples of comp.lang.perl.misc by saying:
> 
>>Would you like a massage while you wait for someone to do your work
>>for you?
> 
> Yes please!
> 
> What do you look like? ;o)


That depends on what *you* look like. ;)


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Thu, 17 Oct 2002 13:59:57 GMT
From: "PinkPuppy" <spam@stinks.com>
Subject: Re: Array from String
Message-Id: <wnzr9.840$XsJ4.42532981@news2.randori.com>


"Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
message news:aomf5c$jf8$1@korweta.task.gda.pl...
> Try writing anything and we'll help you fix errors if they crop up. If
> you don't even try then you're not fooling anyone that you want to
> learn Perl.
>
>
> Cheers,
> Bernard
> --

So be it...

Here's what I have...
$from    = $rqpairs{'from'};
 $to  = $rqpairs{'to'};
 $subject = $rqpairs{'subject'};
 $body    = $rqpairs{'body'};
 @sendTo = split(/,/,$to);

 # Build list of groups from file
 @fileGroupArray = ();
 if (open (groups,$groupfile)) {
  while (<groups>) {
   $_ =~ /(.+):/;
   push(@fileGroupArray,$1);
  }
 }

 foreach $group(@sendTo) {
  foreach $fileGroup(@fileGroupArray) {
   if ($fileGroup eq $group) { &email; }  #if there's a match then I want to
send the email and break out of this loop.  How do I break out of the loop?
  }
 }


I'm sure there is an easier way to do what it is I'm doing, but like I said,
I'm new, so this is what I've done so far.  I think it works, but I'm
looping unnecessarily since I don't know how to break out of a foreach loop
in PERL.




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

Date: Thu, 17 Oct 2002 16:05:03 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Array from String
Message-Id: <migtquc9e8vrb9g1btt1726mt14mfo1l1o@4ax.com>

Bernard El-Hagin bravely attempted to attach 20 electrodes of
knowledge to the nipples of comp.lang.perl.misc by saying:
>In article <7bgtqugn6jk7qrfdln1qp568f5gt0fhtvh@4ax.com>, Teh (tî'pô)
>wrote:
>> Bernard El-Hagin bravely attempted to attach 21 electrodes of
>> knowledge to the nipples of comp.lang.perl.misc by saying:
>> 
>>>Would you like a massage while you wait for someone to do your work
>>>for you?
>> 
>> Yes please!
>> 
>> What do you look like? ;o)
>
>That depends on what *you* look like. ;)

It does? Looks like it's time to update my genetic code. In the
version I'm running one's looks are pretty much hard coded...

-- 
My finger does fit into Teh hole in a CD though...


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

Date: Thu, 17 Oct 2002 16:09:18 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Array from String
Message-Id: <pvgtqusc46ofv834de6mprqo11ue9m5434@4ax.com>

PinkPuppy bravely attempted to attach 44 electrodes of knowledge to
the nipples of comp.lang.perl.misc by saying:

>I don't know how to break out of a foreach loop
>in PERL.

last; # break out of the innermost loop
last TAG; # break out of loop labeled TAG

Note this doesn't work on do while (until) loops.
perldoc -f last


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

Date: Thu, 17 Oct 2002 14:06:17 GMT
From: "PinkPuppy" <spam@stinks.com>
Subject: Re: Array from String
Message-Id: <ttzr9.841$XsJ4.44761159@news2.randori.com>

Unrelated...

If you don't mind, how do you pronouce your name?  My grandfather's name was
Bernard, but it was unusually pronounced /BER-nerd/.




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

Date: Thu, 17 Oct 2002 09:19:51 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Array from String
Message-Id: <slrnaqtho7.2em.tadmc@magna.augustmail.com>

PinkPuppy <spam@stinks.com> wrote:
>> > Can someone show me an easy way to do this?
>>
>> Read lines from the file, 


   @ARGV = 'some.file';
   while ( <> ) {


>> comparing them with a regex against your desired
>> group name, and when you find the right line, 


      if ( /^group: (.*)/ ) {

>> take the remainder of the
>> line, split it out into a list of members, 

         my @members = split /\s+/, $1;


>> and cycle through that list,
>> doing with them whatever you want to do.

         foreach ( @members ) {

            # process $_ here

         }
     }
   }


> I was hoping that someone could supply some code.


See above.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 17 Oct 2002 09:47:54 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Array from String
Message-Id: <slrnaqtjcq.2lt.tadmc@magna.augustmail.com>

PinkPuppy <spam@stinks.com> wrote:
> 
> "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
> message news:aomf5c$jf8$1@korweta.task.gda.pl...
>> Try writing anything and we'll help you fix errors if they crop up. If
>> you don't even try then you're not fooling anyone that you want to
>> learn Perl.


> Here's what I have...
> $from    = $rqpairs{'from'};
>  $to  = $rqpairs{'to'};
>  $subject = $rqpairs{'subject'};
>  $body    = $rqpairs{'body'};
>  @sendTo = split(/,/,$to);


You don't need to copy them to other variables, you can use
them direct from the %rqpairs hash.

If you want to copy them anyway, then you can use a "hash slice":

   my($from, $subject, $body) = @rqpairs{ qw /from subject body/ };
   my @sendTo = split(/,/, $rqpairs{to});


>  # Build list of groups from file
>  @fileGroupArray = ();
>  if (open (groups,$groupfile)) {
             ^^^^^^

Filehandles should be in UPPER CASE. Your code will stop working
when the next version of perl introduces a groups() function.

   
> How do I break out of the loop?


   perldoc -f last


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 17 Oct 2002 14:54:32 GMT
From: "PinkPuppy" <spam@stinks.com>
Subject: Re: Array from String
Message-Id: <HaAr9.842$XsJ4.28049592@news2.randori.com>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnaqtho7.2em.tadmc@magna.augustmail.com...
> PinkPuppy <spam@stinks.com> wrote:
> >> > Can someone show me an easy way to do this?
> >>
> >> Read lines from the file,
>
>
>    @ARGV = 'some.file';
>    while ( <> ) {
>
>
> >> comparing them with a regex against your desired
> >> group name, and when you find the right line,
>
>
>       if ( /^group: (.*)/ ) {
>
> >> take the remainder of the
> >> line, split it out into a list of members,
>
>          my @members = split /\s+/, $1;
>
>
> >> and cycle through that list,
> >> doing with them whatever you want to do.
>
>          foreach ( @members ) {
>
>             # process $_ here
>
>          }
>      }
>    }
>
>
That's perfect!  Only one question.  If I want all of the members of all the
groups that mach to be in one array doesn't the statement my @members =
split /\s+/, $1; overwrite the existing values in that array?

Also, once I have the @members fully populated, is there a PERL mechanism
for removing duplicate values?




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

Date: 17 Oct 2002 14:03:13 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: can't terminate the script?
Message-Id: <u9y98xmd4e.fsf@wcl-l.bham.ac.uk>

"jackkon" <jackkon@ms29.url.com.tw> writes:

> My pc have 64M RAM.
> I read a file about 15776483 byte in a script.
> When the script finish, I find that it still use the memory.

What makes you believe this?

> And the process don't terminate when it print "Execute Over" on the screen.

What makes you believe this?

> What's wrong with my script or OS or my hardware?

Probably nothing.  

What is probably wrong is your interpretation of what you are
observing. It has nothing whatever to do with Perl.

You've not told us what you are observing only how you interpreted it.

If your OS is Linux then see the Linux FAQ: "Why Is Free Memory as
Reported by free Shrinking?".

If your OS is not Linux then see the Linux FAQ anyhow as the concept
is much the same for most Unix-like OSs.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 17 Oct 2002 07:28:21 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Code behaves differently depending on surrounding code
Message-Id: <slrnaqtb75.284.tadmc@magna.augustmail.com>

Sean McAfee <mcafee@artemis.transmeta.com> wrote:

> I've found that for a particular
> large block of text, this counting routine takes a very long time.


The counting routine is the same in both cases, so that must
not be where the change in speed is coming from.

Might you be looking for the problem in the wrong place?


> This is the shortest version
> of the routine that takes a very long time:
> 
> sub count_lines {
>     while (/\n/g) {
>         ;
>     }
>     return 14602;
> }
> 
> This routine took almost 3.5 minutes to return the answer in the main
> program.  But when I excised this routine exactly as shown, and stored it in
> a file prepended only with this code:
> 
> open FILE, './MyHugeFile' or die;
> read FILE, $_, -s FILE;
> close FILE;
> 
> print count_lines();
> 
> ...it printed the answer in less than half a second.


The only difference is in how you build the contents of $_.

How is $_ populated in your real program?


> And the regex is very simple; it employs no
> backtracking 


So it has no quantifiers in it?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 17 Oct 2002 10:05:55 -0400
From: "Christian Caron" <nospam@nospam.org>
Subject: format and write to a browser
Message-Id: <aomg43$8sh9@nrn2.NRCan.gc.ca>

Hi all,

if I:

#################
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";

format STDOUT =
|==================|
| @<<<<<<<<<<<           |
$name
 .

$name = "myname";
write;

#################

and try to run that from a browser, it tells me the document contains no
data (empty). But from the command line, no problem.

Is it possible to use "format" and "write" to print to a web page, or we
always have to use "print"?

Thanks!




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

Date: Thu, 17 Oct 2002 07:01:00 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to write a wc utility in Perl?
Message-Id: <slrnaqt9js.284.tadmc@magna.augustmail.com>

Soon <scyeang@hotmail.com> wrote:
> I would like to write a program in Perl that work like wc in UNIX with
> option -l, -w, and -c


   system 'wc', @ARGV;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 17 Oct 2002 14:23:25 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: How to write a wc utility in Perl?
Message-Id: <3daec775.126557379@news.cis.dfn.de>

On Thu, 17 Oct 2002 07:01:00 -0500, tadmc@augustmail.com
(Tad McClellan) wrote:

>Soon <scyeang@hotmail.com> wrote:
>> I would like to write a program in Perl that work like wc in 
>> UNIX with option -l, -w, and -c
>
>
>   system 'wc', @ARGV;

He he.  You are an evil man, Mr. McClellan.

That won't work unless you have wc in path 
on your system. 
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: Thu, 17 Oct 2002 09:15:11 -0400
From: zentara <zentara@highstream.net>
Subject: Re: Is perlmonks.com down today? Or is just me.
Message-Id: <lrdtqu86tnaunsvk6bj29vpgih0tu6s2vr@4ax.com>

On 16 Oct 2002 14:22:44 -0700, russellcecala@netscape.net (Russell
Cecala) wrote:

>Anyone know what's up with perlmonks.com?

Isn't it perlmonks.org?





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

Date: Thu, 17 Oct 2002 08:52:23 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Ok, so why does this one not work???
Message-Id: <slrnaqtg4n.284.tadmc@magna.augustmail.com>

Christian C Schouten <cschoute@liacs.nl> wrote:

> It just doesn't seem to
> work to use either open or sysopen when having use CGI. In other words, as
> soon as use CGI is present, the file will not be altered.
                              ^^^^^^^^

Maybe you were looking at the wrong file...

(with the same name but in some other directory)


> The same code does work when I comment out all CGI crap.


What happens when you try running it from the command line?


> So, does anyone have any ideas???


Don't use relative paths in a CGI program unless you have
first chdir()ed to a known directory.


> # Allow HTML tags.
> autoEscape(undef);


   chdir '/some/known/directory' or die "could not cd  $!";


> my $DatabaseFile = "survey_ICT.csv";


>     # Open results file, lock it, read it.
>     sysopen(DATABASE, $DatabaseFile, O_RDWR|O_CREAT) or die "Can't open database: $!";


You are using a relative path there.


>     flock(DATABASE, LOCK_UN);


You have introduced a race there.

Remove the flock(..., LOCK_UN).


>     close DATABASE;


close() will release the lock for you.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 17 Oct 2002 09:10:02 -0400
From: Mike Mayer <vm.mayer@comcast.net>
Subject: Re: Pattern Matching help
Message-Id: <vm.mayer-2E23BA.09100217102002@news-east.giganews.com>

In article <3DAEA949.7C2905FC@fujitsu-siemens.com>,
 Josef Möllers <josef.moellers@fujitsu-siemens.com> wrote:
> 
> Although TMTOWTDI:
> 

Perhaps the Sudafed is too high a dose, but I cannot 
  figure this acronym out...

???


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

Date: Thu, 17 Oct 2002 13:15:22 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Pattern Matching help
Message-Id: <aomd5a$6v2$1@korweta.task.gda.pl>

In article <vm.mayer-2E23BA.09100217102002@news-east.giganews.com>,
Mike Mayer wrote:
> In article <3DAEA949.7C2905FC@fujitsu-siemens.com>,
>  Josef Möllers <josef.moellers@fujitsu-siemens.com> wrote:
>> 
>> Although TMTOWTDI:
>> 
> 
> Perhaps the Sudafed is too high a dose, but I cannot 
>   figure this acronym out...


"There's More Than One Way To Do It." Perl's motto.


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Thu, 17 Oct 2002 15:59:23 +0200
From: Sascha Moellering <SaschaMoe@web.de>
Subject: Perl and Word (SynonymInfo)
Message-Id: <3DAEC23B.6080401@web.de>

Hi,

I want to look up synonyms in Word using Perl and Win32::OLE. My code is:

use OLE;

$application = CreateObject OLE 'Word.Application' || die $!;

print $ARGV[0];
$document = $ARGV[0];
my $language=$application->{wdEnglishUS};

$application->Documents->Add();
$application->{'Visible'} = 0;

open(FILE, $document);

@lines = <FILE>;
foreach $line (@lines)
{
	print $line;
	$synlist = $application->SynonymInfo({Word => $line, LanguageID => 
$language})->SynonymList;
	
	foreach $syn (@synlist)
	{
		print $syn;
	}
}

$application->Quit();


But this doesnot work, there seems to be an empty parameter in line 18. 
Any ideas?



Thank you,

Sascha



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

Date: Thu, 17 Oct 2002 09:34:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl and Word (SynonymInfo)
Message-Id: <slrnaqtikg.2hh.tadmc@magna.augustmail.com>

Sascha Moellering <SaschaMoe@web.de> wrote:

> open(FILE, $document);


You should always, yes *always*, check the return value from open():

    open(FILE, $document) or die "could not open '$document'  $!";


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

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


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