[25170] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7419 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 18 14:05:32 2004

Date: Thu, 18 Nov 2004 11:05:07 -0800 (PST)
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, 18 Nov 2004     Volume: 10 Number: 7419

Today's topics:
        Announce: CGI::Session::ExpireSessions V 1.04 <ron@savage.net.au>
        ANNOUNCE: Digest::SHA 5.28 (w/ shasum) <mshelor@cpan.dot.org>
        Announce: Getopt::Simple V 1.48 <ron@savage.net.au>
    Re: Any Perl that works offline from WinXP desktop? <segraves_f13@mindspring.com>
    Re: Array of Hashes ? <usenet@morrow.me.uk>
        Complex datastructure documentation? <dkoleary@olearycomputers.com>
    Re: die and write to log file <usenet@morrow.me.uk>
    Re: die and write to log file <usenet@morrow.me.uk>
        FAQ 3.18: Is it safe to return a reference to local or  <comdog@panix.com>
    Re: hi,something about thread in perl <usenet@morrow.me.uk>
        Not Initializing Variables Correctly? <jc_va@hotmail.com>
    Re: Not Initializing Variables Correctly? <mritty@gmail.com>
    Re: perl get crash when using ClearCase::CtCmd::exec (Maverick Ieong)
        Search file - Help needed please (Thierry B.)
    Re: Search file - Help needed please <mritty@gmail.com>
        SSI Question <nospam@nospam.com>
    Re: SysV constants, where are they defined? (js)
    Re: SysV constants, where are they defined? <usenet@morrow.me.uk>
        using regexes as command line parameters <waggis_at_hotmail.com>
    Re: using regexes as command line parameters <mritty@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 16 Nov 2004 09:27:42 GMT
From: Ron Savage <ron@savage.net.au>
Subject: Announce: CGI::Session::ExpireSessions V 1.04
Message-Id: <I7E1nA.1LM@zorch.sf-bay.org>

The pure Perl module CGI::Session::ExpireSessions V 1.04
is available immediately from CPAN,
and from http://savage.net.au/Perl-modules.html.

On-line docs, and a *.ppd for ActivePerl are also
available from the latter site.

An extract from the docs:
1.04  Tue Nov 02 15:20:00 2004
	- Note: All files referred to here match the CGI::Session file name format /cgisess_[0-9a-f]{32}/
	- Fix the assumption in sub expire_file_sessions() that the program was being run in the temp directory,
		by adding the temp directory's name as a prefix to all file names.
		Original patch: Matthias Blsing
	- Fix sub expire_file_sessions() to delete files of size <= 5 bytes which are old enough. Files of size 0
		are sometimes created by CGI::Session under unknown circumstances.
		As always, use new(delta => 123) to change the definition of 'old enough'
	- Fix verbose message for file session where it should have referred to $$D{'_SESSION_ID'}
		and not $$D{'id'}. The latter was a careless copy-and-paste from the database code
	- Ignore recent files whose size is <= 5 bytes
	- Change text of verbose messages from 'Time lapsed' to 'Time elapsed'
	- Add a security warning to the POD. Actually this comment is redundant, because you always read the POD,
		right?

--
Cheers
Ron Savage, ron@savage.net.au on 16/11/2004
http://savage.net.au/index.html




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

Date: Thu, 18 Nov 2004 18:42:35 GMT
From: Mark Shelor <mshelor@cpan.dot.org>
Subject: ANNOUNCE: Digest::SHA 5.28 (w/ shasum)
Message-Id: <I7E1t4.1wJL@zorch.sf-bay.org>

The Digest::SHA distribution now supports computation of digests from
the command line.  The bundled `shasum' script mimics the behavior of
`md5sum', and can serve as a drop-in replacement for the latter when
the stronger security of SHA (vs. MD5) is desired.

`shasum' implements all option switches of `md5sum', and includes an
additional one (-a or --algorithm) to indicate which SHA transform to
use.  The package supports all algorithms specified in FIPS 180-2
(viz. SHA-1/224/256/384/512).

Mark




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

Date: Tue, 16 Nov 2004 09:29:22 GMT
From: Ron Savage <ron@savage.net.au>
Subject: Announce: Getopt::Simple V 1.48
Message-Id: <I7E1p5.1rn@zorch.sf-bay.org>

The pure Perl module Getopt::Simple V 1.48
is available immediately from CPAN,
and from http://savage.net.au/Perl-modules.html.

On-line docs, and a *.ppd for ActivePerl are also
available from the latter site.

An extract from the docs:

1.48  Sun Nov 07 14:30:00 2004
	- Add sub pad() to simplify printing of fixed width fields.
		Original patch: Ricardo Signes.
		Since this is the only change, there is no need to upgrade

--
Cheers
Ron Savage, ron@savage.net.au on 16/11/2004
http://savage.net.au/index.html




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

Date: Thu, 18 Nov 2004 17:35:07 GMT
From: "Bill Segraves" <segraves_f13@mindspring.com>
Subject: Re: Any Perl that works offline from WinXP desktop?
Message-Id: <f35nd.4165$pK6.129@newsread2.news.atl.earthlink.net>

"M.L." <mel2000@hotmail.com> wrote in message
news:a409d169.0411171713.1de51d5d@posting.google.com...
<snip>
> Hello again. First I'd like to thank everyone who replied. One of the
> reasons for my late response is that I only have occasional Internet
> access for now. The problem will be fixed in a few months, but for now
> I am constrained to work offline most of the time. So I'm trying to do
> as much as I can while offline.
>

IndigoPerl, available free from www.indigostar.com, will suffice for your
situation.

> What am I trying to do? Simple. I want to use AnyData to slurp my
> inventory data from Excel (or jpeg IPTC info) and use it to replace
> variables within an HTML catalog template. I want to automate the
> process of building a separate web page for each inventory item; I
> know from experience that Perl is well-suited for that task. I also
> hoped that the project could be built and executed offline. I've
> already tried some off-the-shelf Windows programs but they aren't as
> flexible as I'd like. Since the project is largely visual, I prefer
> not to depend on a command line implementation. It is important that I
> see the results on a web page, so yes, I'm trying to run a cgi script
> offline.
>

IndigoPerl, available free from www.indigostar.com. After installation,
start the Apaches server and point your browser to http://localhost.

Cheers.
--
Bill Segraves




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

Date: Thu, 18 Nov 2004 17:22:35 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Array of Hashes ?
Message-Id: <rb2v62-bc4.ln1@osiris.mauzo.dyndns.org>


Quoth "Peter Wyzl" <wyzelli@yahoo.com>:
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message 
> news:Xns95A47DA443544asu1cornelledu@132.236.56.8...
> > sudhirx@gmail.com (Tom) wrote in
> > news:f50c52fa.0411170859.ed4643f@posting.google.com:
> >
> >> Well, I am a beginner as far as perl is concerned.
> >> Can some one point me that 'm doing is correct.
> >> I have pasted below my hash and array using Data::Dumper()
> >>
> >> I am pushing Hash1, Hash2 in to an Array
> >
> > comp.lang.perl.mindreadres is down the hall to your right.
> >
> >> I don't see => when 'm priting the Array using Data::Dumper()
> >
> > Have you read
> >
> > perldoc perldsc
> 
> Actually, that reminds me.  It's probably time that doc got updated.  My 
> copy (Perl 5.8.3) was written in 1996 and makes assertions about inability 
> to write complex data representations to disk which have been well fixed by 
> Storable.
> 
> Who would handle that?

Send a patch to p5p (perl5-porters@perl.org, or
nntp://nntp.perl.org/perl.perl5.porters).

Ben

-- 
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
     -Assyrian stone tablet, c.2800 BC                         ben@morrow.me.uk


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

Date: Thu, 18 Nov 2004 18:52:08 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Complex datastructure documentation?
Message-Id: <slrncpprq1.cbh.dkoleary@x1-6-00-b0-d0-c1-44-09.comcast.net>

Hey all;

I just finished a script for a client and will be working on the
documentation shortly.  The script uses a fairly complex data
structure that looks like:

#####################################################################
# Redesigned data structure.
#####################################################################
# %$hash:
# ${$hash}{Datalist} = \%datalist:
#    ${${$hash}{Datalist}}{$dl} = \%
#    ${${${$hash}{Datalist}}{$dl}}{host}  = $host
#    ${${${$hash}{Datalist}}{$dl}}{sid}  = $sid
#    ${${${$hash}{Datalist}}{$dl}}{suffix}  = $suffix
#    ${${${$hash}{Datalist}}{$dl}}{stream}  = $stream
#--------------------------------------------------------------------
# ${$hash}{Host}     = \%host_list;
#    ${${$hash}{Host}}{$host} = [ \@dls, \%sids ]
#    ${${${$hash}{Host}}{$host}}[0] = \@dls
#    ${${${$hash}{Host}}{$host}}[1] = \%sids
#    ${${${${$hash}{Host}}{$host}}[1]}{$sid}  = [ @dls, %lvs ]
#####################################################################

Does anyone have any tips on how I could document that 
clearly - for people that aren't used to complex data
structures in perl?

Any formatting/other hints/tips greatly appreciated.

Doug


-- 
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume:  http://home.comcast.net/~dkoleary/resume.html



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

Date: Thu, 18 Nov 2004 17:27:55 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: die and write to log file
Message-Id: <rl2v62-bc4.ln1@osiris.mauzo.dyndns.org>


Quoth karel@e-tunity.com:
> (2) Appending from the OS: use die() just as you would, but run your script
> as:
>         perl myscript.pl 2>logfile
> Unix-ish only. I don't think DOS allows for stderr-redirection while stdout
> remains un-redirected.

Not strictly Perl-related, but recent versions of NT (at least since
win2k) with cmd.exe do allow this, with the usual Bourne shell syntax.

Ben

-- 
You poor take courage, you rich take care:
The Earth was made a common treasury for everyone to share
All things in common, all people one.
'We come in peace'---the order came to cut them down.       [ben@morrow.me.uk]


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

Date: Thu, 18 Nov 2004 17:32:59 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: die and write to log file
Message-Id: <bv2v62-bc4.ln1@osiris.mauzo.dyndns.org>


Quoth and11@rol.ru:
> justme wrote on 18 Ноябрь 2004 10:08:
> 
> > usually when opening a file, we should check whether it can be opened
> > open(FILE,"textfile.txt") or die "Cannot open for reading:$!\n";
> > 
> > how can i also pipe a error message to a log file ? Something like "tee" ?
> 
> You may also try to catch __DIE__ signal and replace its handler with your custom one.
> 
> {

> local $SIG{__DIE__} = sub { open FH, ">>log.txt"; print FH "@_\n";
> close FH; print STDERR "@_\n"; } 
                                  ^^ ;

> open FH, "somefile" or die "err: $!"
                                      ^^ ; not strictly required, but I
                                      would anyway
> }

Please don't top-post.
Please indent decently.
Please wrap your lines at 76 characters.

$SIG{__DIE__} has been broken since it was first introduced, in that it
is called whenever die is called inside an eval, including for parse
errors. This means you need to be careful of this:

{
    local $SIG{__DIE__} = sub {
        die $_[0] if $^S or not defined $^S;
        # whetever else you want
    };
}

This is, of course, mentioned in perlvar, under $SIG{__DIE__} and $^S.

Ben

-- 
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based 
on the strictest morality.  [Samuel Butler, paraphrased]       ben@morrow.me.uk


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

Date: Thu, 18 Nov 2004 17:03:04 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 3.18: Is it safe to return a reference to local or lexical data?
Message-Id: <cnikk8$imo$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

3.18: Is it safe to return a reference to local or lexical data?

    Yes. Perl's garbage collection system takes care of this so everything
    works out right.

        sub makeone {
            my @a = ( 1 .. 10 );
            return \@a;
        }

        for ( 1 .. 10 ) {
            push @many, makeone();
        }

        print $many[4][5], "\n";

        print "@many\n";



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Thu, 18 Nov 2004 17:26:04 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: hi,something about thread in perl
Message-Id: <ci2v62-bc4.ln1@osiris.mauzo.dyndns.org>


Quoth sam <sam.wun@authtec.net>:
> Ben Morrow wrote:
> 
> > Quoth XiaotingHua <x.t.hua@163.com>:
> > 
> 
> > However, as you say, a perl thread is not a thread by any reasonable
> > definition: it's a userland fork. Without copy-on-write, or any of the
> > other optimizations the kernel can provide. The ithreads concept
> > originated in a project to emulate fork on systems which don't support
> > it, and IMHO on a system which supports fork you'd be *much* better off
> > with that. You *may* find that if you can create all your threads at
> > startup that over the course of a long-running program saving the
> > context switches needed for multiprocess is a significant benefit over
> > fork, but I doubt it; especially if you aren't forking hundereds of
> > process but just ~1 per processor.
> > 
> I m more concern the required memory when dealing with million of 
> processes that created by fork().

ithreads copy all perl data structures, without sharing pages. (This is
something that is being worked on, though...) I would expect (though I
haven't checked) a given number of ithreads to use (much) more memory as
well as being slower than a given number of forked processes, again
assuming a vaguely modern Unix OS.

Ben

-- 
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk


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

Date: Thu, 18 Nov 2004 12:00:55 -0500
From: "Buck Turgidson" <jc_va@hotmail.com>
Subject: Not Initializing Variables Correctly?
Message-Id: <831v62-i05.ln1@turf.turgidson.com>

I am a very weak Perl programmer, but I have managed to put the following
together, based on some examples I've found on the web.

However, I receive a long series of the following error message, but the
problem is it is not consistent as to where it begins and ends (i.e. which
cell in the Excel spreadsheet).  This leads me to believe I am overstepping
some memory, or not using variables correctly.  I do not think there is
anything wrong with the spreadsheet.

I would be grateful if someone could tell me the error of my ways.  I don't
even expect politeness.

 "Use of uninitialized value in printf at h:\dev\perl\readbudget.pl line 29"


#!/usr/bin/perl -w

#use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';

$Win32::OLE::Warn = 3; # die on errors...

my $Excel = Win32::OLE->GetActiveObject('Excel.Application') ||
Win32::OLE->new('Excel.Application', 'Quit');
my $Book = $Excel->Workbooks->Open("d:\\misc\\bud.xls");
my $Sheet = $Book->Worksheets('bud_05');

 $LastRow =
$Sheet->UsedRange->Find({What=>"*",SearchDirection=>xlPrevious,SearchOrder=>
xlByRows})->{Row};

 $LastCol = $Sheet->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious,SearchOrder=>xlByColumns})->{Column};

foreach my $row (2..$LastRow)
{
     my $descr1 = $Sheet->Cells($row,1)->{'Value'};
     my $descr2 = $Sheet->Cells($row,2)->{'Value'};
     my $descr3 = $Sheet->Cells($row,3)->{'Value'};
     my $descr4 = $Sheet->Cells($row,4)->{'Value'};

     foreach my $col (5..$LastCol)
     {
         my $budval = $Sheet->Cells($row,$col)->{'Value'};
         printf
"%d,%d,%s,%s,%s,%s,%d\n",$row,$col,$descr1,$descr2,$descr3,$descr4,$budval;
     }
}

$Book->Close;




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

Date: Thu, 18 Nov 2004 17:29:40 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Not Initializing Variables Correctly?
Message-Id: <8_4nd.7569$tS4.3778@trndny09>

"Buck Turgidson" <jc_va@hotmail.com> wrote in message
news:831v62-i05.ln1@turf.turgidson.com...
> I am a very weak Perl programmer,

Then it would make sense to ask the interpreter for all the help you can
get, no?

> but I have managed to put the following
> together, based on some examples I've found on the web.
>
> However, I receive a long series of the following error message,

Those are not error messages, they are warnings.  There is a rather
significant difference.

> but the
> problem is it is not consistent as to where it begins and ends (i.e.
which
> cell in the Excel spreadsheet).  This leads me to believe I am
overstepping
> some memory, or not using variables correctly.  I do not think there
is
> anything wrong with the spreadsheet.
>
> I would be grateful if someone could tell me the error of my ways.  I
don't
> even expect politeness.
>
>  "Use of uninitialized value in printf at h:\dev\perl\readbudget.pl
line 29"
>
>
> #!/usr/bin/perl -w

These days, it is preferred to add the line
use warnings;
in place of the -w switch

> #use strict;

Now why on earth would you comment that out?  That is an extremely
helpful line.  If using that line gives you errors, the correct solution
is to *fix* those errors, not to ignore them.  This is roughly the
equivalent of sticking your fingers in your ears and shouting "LA LA LA
I CAN'T HEAR YOU!!!!"

<snip a bunch of code>

> foreach my $row (2..$LastRow)
> {
>      my $descr1 = $Sheet->Cells($row,1)->{'Value'};
>      my $descr2 = $Sheet->Cells($row,2)->{'Value'};
>      my $descr3 = $Sheet->Cells($row,3)->{'Value'};
>      my $descr4 = $Sheet->Cells($row,4)->{'Value'};

Are you sure you don't want maybe an array or a hash here?  In general,
a sequence of similarly named scalar variables indicates a poorly
thought out data structure.

>      foreach my $col (5..$LastCol)
>      {
>          my $budval = $Sheet->Cells($row,$col)->{'Value'};
>          printf
>
"%d,%d,%s,%s,%s,%s,%d\n",$row,$col,$descr1,$descr2,$descr3,$descr4,$budv
al;

I would say the first step in debugging your problem would be to figure
out *which* variable is not defined.  A quick and dirty way would be to
seperate each of the printf's...

print "$row,";
print "$col,";
#...
print "$budval\n";

And then determine based on the warning's line number which variable is
undefined.  (Once you've fixed the problem, of course, you should revert
to something neater looking...)
print join ',', $row,$col,@descr,$budval;
print "\n";


Hope that at least points you in the right direction.
Paul Lalli



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

Date: 18 Nov 2004 10:01:20 -0800
From: mluvw47@gmail.com (Maverick Ieong)
Subject: Re: perl get crash when using ClearCase::CtCmd::exec
Message-Id: <d4b6522b.0411181001.2369ff2a@posting.google.com>

Sorry, I mis-type, I was supposed to do a lsvob command, but it crash.

use ClearCase::CtCmd;
@test = ClearCase::CtCmd::exec("lsvob");

Let me try to use restrict and warning, but I doubt it will solve my problem.
http://search.cpan.org/~ratl/CtCmd-1.03/CtCmd.pm

Pretty much I invoke any ClearCase::CtCmd::exec command it died right away..
I have Clearcase 2002.05.00+ install.

> I don't know anything about the package you mention and I don't have the 
> faintest idea what Rational ClearCase is.
> 
> Looking at the documentation for the module shows no usage examples similar 
> the one you show above.
> 
> Rather, it looks like you need to invoke a sub with a four-letter name in 
> the ClearCase::CtCmd package rather than calling a sub named CtCmd in the 
> ClearCase package.
> 
> <SNIP>Windows crash information</SNIP>
> 
> Oh, by the way, you should 
> 
> use strict;
> use warnings;
> 
> and definitely read the posting guidelines for this group.
> 
> Sinan.


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

Date: 18 Nov 2004 09:59:50 -0800
From: mrjaune@hotmail.com (Thierry B.)
Subject: Search file - Help needed please
Message-Id: <b4e11da7.0411180959.1ef6fbf7@posting.google.com>

Hello,

I'm a newbie and I want writing a perl script.
I explain what I want doing.

Here is my file ref.txt:

A01 /ref/a01.pdf
A02 /ref/a02.pdf
A03 /ref/a03.pdf
etc..

When you enter A01 in the html search page the script open a new
windows with the coresponding pdf file (/ref/a01.pdf).

Could anyone help me please?

Best regards,

Thierry


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

Date: Thu, 18 Nov 2004 18:27:07 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Search file - Help needed please
Message-Id: <%P5nd.5611$%M4.4069@trndny08>

"Thierry B." <mrjaune@hotmail.com> wrote in message
news:b4e11da7.0411180959.1ef6fbf7@posting.google.com...
> Hello,
>
> I'm a newbie and I want writing a perl script.
> I explain what I want doing.
>
> Here is my file ref.txt:
>
> A01 /ref/a01.pdf
> A02 /ref/a02.pdf
> A03 /ref/a03.pdf
> etc..
>
> When you enter A01 in the html search page the script open a new
> windows with the coresponding pdf file (/ref/a01.pdf).
>
> Could anyone help me please?

What have you tried so far?

The following documents will be most helpful.  If you have not done so
already, read them.  Then make an attempt, show us what you have, and we
can probably help correct errors.

perldoc CGI
perldoc -f open
perldoc -f readline
perldoc -f substr
perldoc -f print

Paul Lalli



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

Date: Thu, 18 Nov 2004 13:44:49 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: SSI Question
Message-Id: <1100803594.333576@nntp.acecape.com>

hey all,

someone told me to read and act on cookies by using  javascrpt within the
webpage.  now in my Perl reading i came across SSI statements.

i.e.<!--#exec cgi="/cgi-bin/whattimeisit.cgi"-->

and i was curious why not use statements like that to read a users cookies
and do a redirect if i have to.  now granted, i don't know if this works,
and when i get back to my programming machine i will test it.  (otherwise i
would have done that first)

but the point is, even if it does, that's doesn't make it the right way.  so
i was curious...would this be considered bad?  kloodge?  cheesy? band-aid?
etc.

thanks ahead,

daniel




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

Date: 18 Nov 2004 08:06:19 -0800
From: jstrempe@cox.net (js)
Subject: Re: SysV constants, where are they defined?
Message-Id: <51d6249f.0411180806.3efd93c0@posting.google.com>

Thank you, Jim.  I decided yesterday while trying to figure all of
this out that I would purchase that book having seen it recommended in
the past.
Sincerely,
Julie


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

Date: Wed, 17 Nov 2004 21:06:19 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: SysV constants, where are they defined?
Message-Id: <b3rs62-og6.ln1@osiris.mauzo.dyndns.org>


Quoth jstrempe@cox.net (js):
> I'm getting into some programming with IPC::Semaphore, etc.  After
> spending some time searching without success, I was wondering where
> one finds what each of the SysV constants stand for so I know a little
> bit more of what I'm doing.

In your system documentation for SysV IPC: semctl(2) and semget(2). I
admit that I find these pages (on Linux, and at a quick skim only)
pretty opaque, but then I've never tried to use sysv ipc.

You could also look in the Camel, 3rd. ed, which has a section on sysv
ipc.

Ben

-- 
   Although few may originate a policy, we are all able to judge it.
                                             - Pericles of Athens, c.430 B.C.
  ben@morrow.me.uk


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

Date: 18 Nov 2004 17:42:02 +0200
From: JMI <waggis_at_hotmail.com>
Subject: using regexes as command line parameters
Message-Id: <Xns95A5B40F63810waggishotmailcom@192.37.1.74>

Hello

Short question, but maybe somebody knows how-to

Let's imagine your program accepts two command line arguments to perform 
replaces in a string:
usage: myprogram -s "foo" -r "bar"
where s is the search regex and r the replace regex.

Everything works fine, even grouping with parenthesis, etc. As described in 
detail in the cookbook.

But:
When I want to use a captured value in the replacement regex, it does 
simply not work. Using all possible syntaxes ( as \$1, or \\$1...) only 
leads to either an exmpty value in the replaced string, or a plain-text 
"$1" text when too much is escaped.

The code looks like:

        my $rx;
        if ($case_sensitive) {
                $rx = qr/$search_pattern/;
        } else {
                $rx = qr/$search_pattern/i;
        }
        print "Patching file:\t$origin\n" if ($debug_mode || 
$verbose_mode);
        my $myfile = '';

        print "Opening $origin\n" if $debug_mode;
        open(OLD, "< $origin")
        while (<OLD>) {
                $myfile .= $_;
        }
        print "Closing $origin\n" if $debug_mode;
        close(OLD)

        open(NEW, "> $playground")
        print "Replacing $search_pattern with $replace_pattern\n" if 
$debug_mode;
        $myfile =~ s/$rx/$replace_pattern/gs;  
        print NEW $myfile
        close(NEW)

Hope it's the right place to find some people having had the same 
problem,....

thanks and best regards
JM


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

Date: Thu, 18 Nov 2004 17:18:54 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: using regexes as command line parameters
Message-Id: <2Q4nd.12483$wY2.3433@trndny05>

"JMI" <waggis_at_hotmail.com> wrote in message
news:Xns95A5B40F63810waggishotmailcom@192.37.1.74...
> Let's imagine your program accepts two command line arguments to
perform
> replaces in a string:
> usage: myprogram -s "foo" -r "bar"
> where s is the search regex and r the replace regex.
>
> Everything works fine, even grouping with parenthesis, etc. As
described in
> detail in the cookbook.
>
> But:
> When I want to use a captured value in the replacement regex, it does
> simply not work. Using all possible syntaxes ( as \$1, or \\$1...)
only
> leads to either an exmpty value in the replaced string, or a
plain-text
> "$1" text when too much is escaped.

Giving simply $1 makes the shell pass the shell's own $1 variable to
your script.
Giving \$1 passes the literal string '$1' to your script.

What you need to do is tell Perl to evaluate that literal string as
Perl:

perl -le'$_ = q/foo/; s/($ARGV[0])/$ARGV[1]/ee; print;' foo \$1

This is a trivial example, of course, but it does illustrate that perl
is correctly replacing 'foo' with the captured match (which also happens
to be 'foo').

For more info, look up the /e modifier in
perldoc perlretut
or
perldoc perlre

Paul Lalli



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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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