[12261] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5861 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 2 13:07:28 1999

Date: Wed, 2 Jun 99 10:00:19 -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           Wed, 2 Jun 1999     Volume: 8 Number: 5861

Today's topics:
        comparing 3 numeric values elvis@NOTGRACELANDclark.net
        do blocks as lvalues - the saga continues - proposed ne <B.A.McCauley@bham.ac.uk>
    Re: GD, PPM, XML: Parser <cassell@mail.cor.epa.gov>
    Re: how to attach a file to the mail? <cassell@mail.cor.epa.gov>
    Re: How to list all installed modules <cassell@mail.cor.epa.gov>
    Re: Is split (surprisingly, amazingly) slow? <uri@sysarch.com>
    Re: microso?t perl (Marcel Grunauer)
    Re: microso?t perl (Marcel Grunauer)
    Re: microso?t perl <dgris@moiraine.dimensional.com>
    Re: Newbie - would appreciate a hand to get started - T (Bill Moseley)
    Re: open FILE,$path || open FILE,$altpath; <bakulin@eximb.kiev.ua>
    Re: pipes?? <dhenders@cpsgroup.com>
    Re: req: sendmail specs (I.J. Garlick)
    Re: Running a Background Process from CGI (Mark R.)
    Re: sendmail doesn't work <bill@fccj.org>
    Re: String extraction problem - please help? <pavel@asei.cz>
    Re: String extraction problem - please help? <B.A.McCauley@bham.ac.uk>
        String to String1 to String2 ??? <bill@fccj.org>
    Re: Timeout question...(CODE INCLUDED)...Please help! <B.A.McCauley@bham.ac.uk>
    Re: undesired result with .* in s command <dhenders@cpsgroup.com>
    Re: Win32 NetShareGetInfo <cassell@mail.cor.epa.gov>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 02 Jun 1999 16:51:07 GMT
From: elvis@NOTGRACELANDclark.net
Subject: comparing 3 numeric values
Message-Id: <%hd53.407$cb5.38316@ord-read.news.verio.net>


I have 3 values:
$start = "6/15/1999" ;
$end = "6/30/1999" ;
$current = "6/16/1999" ; 

Ok, so that is easy to get the numeric values off those dates (month/day/year)

I want to find out if $current lies between (or on) $start and $end dates.

Is there an easy way to do this.

I am thinking...seconds from January, 1970 but I forget how to do that.

Any suggestions?

-- 
Bill
elvis@NOTGRACELAND.clark.net


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

Date: 02 Jun 1999 16:44:43 +0100
From: Brian McCauley <B.A.McCauley@bham.ac.uk>
Subject: do blocks as lvalues - the saga continues - proposed new pragma
Message-Id: <u9wvxm61zo.fsf_-_@wcl-l.bham.ac.uk>

In this on-going one-man thread:

Brian McCauley <B.A.McCauley@bham.ac.uk> writes:

> Brian McCauley <B.A.McCauley@bham.ac.uk> writes:
> 
> > Is this bug or what?
> > 
> > ( do { @a } ) = ("x","y");
> > 
> > Error: Can't modify array deref in scalar assignment
> > 
> > Why is this seen as a scalar assignment?

OK what's the game?  I've just tried this in the development version
and now I get "Can't modify do block"!

WTF not?  do blocks _are_ lvalues.  At least they in every context
except those where parser spits out the "Can't modify" error.

${ \ do { $a } } = 1;  # Does indeed set $a=1

&{ sub { $_[0] = 1 } } ( do { $a }); # Does indeed set $a=1

for ( do { $a } ) { $_ = 1 }; # Does indeed set $a=1

Or perhaps do blocks "officially" are not be lvalues (whatever
"officially" means in this context).  In this case all the above
should also fail to modify $a (either silently or with an error).

Perhaps we should have a "use lvalues" pragma to allow do blocks (and
subroutine entries and method calls and anything else that one could
reasonably want) to act as lvalues in _all_ contexts.

Maybe under "no lvalues" do blocks should _never_ act as lvalues in
any context.  If so then it is debatable whether the absense of "use
lvalues" should be the same as "no lvalues" or should retain to the
current (inconsitant) behaviour for stict backwards compatiability.

Note that IMHO a subroutine should never be treated as returning an
lvalue unless "use lvalues" was in effect where it was defined.  It is
debatable if a subroutine defined under "use lvalues" but called under
"no lvalues" should be considered to return an lvalue - probably not.

-- 
     \\   ( )  No male bovine  | Email: B.A.McCauley@bham.ac.uk
  .  _\\__[oo   faeces from    | Phones: +44 121 471 3789 (home)
 .__/  \\ /\@  /~)  /~[   /\/[ |   +44 121 627 2173 (voice) 2175 (fax)
 .  l___\\    /~~) /~~[  /   [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
  # ll  l\\  ~~~~ ~   ~ ~    ~ | http://www.wcl.bham.ac.uk/~bam/
 ###LL  LL\\ (Brian McCauley)  |


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

Date: Wed, 02 Jun 1999 09:33:31 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: GD, PPM, XML: Parser
Message-Id: <37555CDB.2AF7B99D@mail.cor.epa.gov>

Matt Sergeant wrote:
> 
> David Cooper wrote:
> >
> > Hello
> >
> > I've installed ActiveState build 517.
> > When I use PPM to install GD (or anything else for that matter) I get the
> > following error:
> >
> > no element found at line 1, column 0, byte -1 at
> > C:/Perl/site/lib/XML/Parser.pm
> > line 153
> 
> I think this means your ppm.xml file is either missing, empty, or
> broken. You might need to re-install ActivePerl to get it working again
> :(

Errm, maybe not.  Before you re-install, you might go to the
ActiveState website and check under Packages/support.  PPM uses the
XML::Parser module internally, so it's possible to hose this
[like trying to install a new XML::Parser module from PPM
itself].  I think ActiveState has a doc on fixing this problem.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 02 Jun 1999 09:17:08 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: how to attach a file to the mail?
Message-Id: <37555904.D8477CC2@mail.cor.epa.gov>

Gleb Ekker wrote:
> 
> Hi,
> 
> can anybody help me with my problem - how to attach a file to the mail
> sent by using Sendmail program? Better would be not to use any module.

No modules, huh?  Okaaaaaay...

> Usually I send mails from my scripts as follows:
> 
> #!/usr/bin/perl
                 ^^^^
  #!/usr/bin/perl -w

You need to use that -w flag.  And you ought to consider the following
for lines #2 and #3:

use strict;
use diagnostics;   # only needed until you learn to interp
                   # the error messages without it

> $mailprog = "/usr/sbin/sendmail";
> $recipient= "globus\@infonet.ee";
> 
> open(MAIL, "|$mailprog $recipient") || die;

If you're going to do this instead of using Mail::Mailer
or a similar module, you need to get the sendmail switches
in there, and you need to get them correctly.  I would think
you need -oi at a minimum.  and you really ought to check
the return status and print $! out so you have some idea
why your fork failed.

> print MAIL "To: $recipient\n";
> print MAIL "From: Your Web Site\n";
> print MAIL "Subject: Test Mail\n\n";
> print MAIL "? ? ? ? ? ? ? ? ? ? ? ?\n\n";

Use a here-doc.  It will look cleaner.

> close(MAIL);

You ought to check the status of the close() as well.
 
> What line must I put to attach some file, for example, test.zip?

This is a MIME issue now.  You'll have to go read the MIME
specs and be sure to get all the headers and everything just
right, or it won't work.  Or you could just use the fine
MIME::Lite module, which would take care of all that for you.
But since you don't want to use a module, you'll have to go
do all that other stuff now...
 
HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 02 Jun 1999 09:04:30 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Jasmine <djm@tintagel.net>
Subject: Re: How to list all installed modules
Message-Id: <3755560E.2F9798C1@mail.cor.epa.gov>

[courtesy cc sent to poster]

Jasmine wrote:
> 
> Hello,
> 
> Is there a way to determine all of the modules that are installed on my
> hosts installation of perl?

Well, while rootbeer and Uri have given you some suggestions,
the route that will probably be the easiest [no guarantee of
the best] for you would be to use the CPAN.pm module which
may already be installed on your host's system.  If you have
access, you can do the following:

[1] at the command line, type:
    perl -MCPAN -e shell
to get a CPAN shell prompt,
[2] then type this command:
    autobundle

This should create a file that will look something like
  $CPAN/.cpan/Bundle/Snapshot_current_date_and_time.pm
which should contain a list of all the modules installed.

Alternatively, if you only need to check on the presence/
absence of a handful of modules, you can check individually
like this:

perldoc CPAN

If the CPAN.pm module is properly installed, you will
get the docs on it.  If not, you'll get an error message
telling you the docs were not found.  You can use that
as a fairly good [but not perfect] indicator of the presence
of that particular module.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 02 Jun 1999 12:39:14 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Is split (surprisingly, amazingly) slow?
Message-Id: <x7iu96d0b1.fsf@home.sysarch.com>

>>>>> "dk" == digital kensai <kensai@nortel.com> writes:

  dk> I ran some tests and got about a 14 second (versus 26 second) run-time,
  dk> allbeit on a cheesy test -- using unpack instead of split:

  dk> $ perl -e 'for(0..1000000){print "12)23456)214g sdg ewetwet) seyte ea5) SWTE(
  dk> erY)\n"}' | time ./count.pl

do you know about the Benchmark.pm module? it makes life a lot easier for
testing these kinds of things. for one thing, it eliminates the compiling
and loop overhead that clouds the actual benchmark comparisons. it
should be in your perl installation.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 02 Jun 1999 15:44:50 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: microso?t perl
Message-Id: <375550af.2554943@enews.newsguy.com>

On Wed, 02 Jun 1999 08:02:07 -0700, Jerome O'Neil
<jeromeo@atrieva.com> wrote:

>Daniel Grisinger wrote:
>> 
>> [subject line intentionally munged to avoid my killfile :-)]
>> 
>> This worries me.
>> 
>>  http://www.activestate.com/press/releases/Microsoft.htm
>
>What's this all about?
>
>> Q: Will the work be Open Source? 
>> 
>> A: Most of the work will be released as Open Source. Part of 
>> our business model is to sell value add, proprietary components.
>> Rest assured though, that everything added to core Perl will be 
>> released under the same terms as Perl. 
>
>Smells fishy.  I'm always nervous when some MS goob tells me to "rest
>assured."
>
>More importantly... should I care?

Probably. I don't know what extension to Perl they have in mind, but
the worst-case scenario surely is that they take the Perl source,
modify it in some way that integrates it tightly with Windows, then
try to take it from there. Like with Java.

And although I write this from an NT box, I feel the dark shadows
looming behind me. Time to make the jump to Linux.

Regards
Marcel Grunauer
--
Codewerk Ltd                      marcel@codewerk.com
Just Another Perl Hacker          phone: +44-171-624 7408


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

Date: Wed, 02 Jun 1999 16:02:45 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: microso?t perl
Message-Id: <37565449.3476759@enews.newsguy.com>

On 2 Jun 1999 15:25:25 GMT, fl_aggie@thepentagon.com (I R A Aggie)
wrote:

>On 02 Jun 1999 08:59:18 -0600, Daniel Grisinger
><dgris@moiraine.dimensional.com>, in
><m3lne2hcmx.fsf@moiraine.dimensional.com> wrote:
>
>+ This worries me.
>+  http://www.activestate.com/press/releases/Microsoft.htm
>
>Who sez you have to use their stuff, and who sez that p5p has to
>roll it into the perl core?
>
>James

No one says that, but if MS releases some proprietary extensions to
Perl and enough people start using them you get a fragmentation just
like we had (have) with Java.

Sure, you can look at your Unix box and say "so what? if they want to
hack Perl, they should do so under Unix". Right, but fragmentation and
the ensuing confusion (imaging people asking questions about those
proprietary extensions in c.l.p.m - I know what Tom's response will
be) serves no one.

Sorry about the scaremongering.

Regards
Marcel Grunauer
--
Codewerk Ltd                      marcel@codewerk.com
Just Another Perl Hacker          phone: +44-171-624 7408


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

Date: 02 Jun 1999 10:00:00 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: microso?t perl
Message-Id: <m37lpmh9tr.fsf@moiraine.dimensional.com>

Jerome O'Neil <jeromeo@atrieva.com> writes:

> What's this all about?
> 
> > Q: Will the work be Open Source? 
> > 
> > A: Most of the work will be released as Open Source. Part of 
> > our business model is to sell value add, proprietary components.
> > Rest assured though, that everything added to core Perl will be 
> > released under the same terms as Perl. 

Well, of course everything added to the core will be open sourced,
the artistic license assures that.  

Of course that doesn't stop an evil, monopolistic company from
offering proprietary extensions.  It doesn't stop a company with no
interest or standing in the perl community from exploiting years
of hard work, donated by a cast of thousands, for its own gain.

It's already started with Activestate releasing binary-only slaveware
such as their debugger and their perlex engine.  It won't stop there,
of course, if they enjoy any success.  

Before you know it perl on windows will be a twisty little maze
of incompatibilites and extensions only available in a slick,
install-wizard based package for those with the money to pay.  Those
without money--well, do they really matter?

Down that path lies code-forking (witness HipPerl), wasted
effort, and bad feelings.  We shouldn't go there.

There is, fortunately, a simple solution.  Don't use activeperl.
Don't recommend activeperl.  If you'd like to help the POBs get
perl give them the urls for egcs and for the perl souce kit.

Use only real perl, compiled from source code that you have,
modifiable by anyone.  

Eschew slaveware, use only real perl.

> More importantly... should I care?

Only you can answer that question.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Wed, 2 Jun 1999 08:51:02 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Newbie - would appreciate a hand to get started - Thanks in advance
Message-Id: <MPG.11bef2c42bd12f3398973c@206.184.139.132>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <7j3ht4$hes$1@news3.Belgium.EU.net>, 
jde222RemovethiS@iname.com says...
> I would like to get this working to get me started:
> A simple .html file, which i start with ie5 browser, calling a simple .pl file,
> which produces just a print "hello" and passes control back to the .html thing
> Once this runs, i think i would be able to build on it further

Do you have a web server running on your PC?

No?  There are a lot of options.  Try www.apache.org for one.


-- 
Bill Moseley mailto:moseley@best.com


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

Date: Wed,  2 Jun 1999 18:54:49 +0300
From: "Boris Bakulin" <bakulin@eximb.kiev.ua>
Subject: Re: open FILE,$path || open FILE,$altpath;
Message-Id: <2.07b3.YVVZ.FCPIVD@eximb.kiev.ua>

In <37539A39.F90800DA@siemens.at> Wolfgang Gtzinger (wolfgang.goetzinger@siemens.at) wrote:
Hi!

i want to open and print the file $path to stdout. if the file $path
does not exist i want to open and print $altpath (which always exists).

i tried the following code:

-------------------------------------------------
$path="/home/file_a"
$altpath="/home/default"

open FILE,$path || open FILE,$altpath;
while (<FILE>) {
        print;
}
-------------------------------------------------

but if $path does not exist, $altpath is not opened.
what is wrong?
i think the answer is easy, but i just started perl...sorry

thanx for your help!!


Try this:

use strict;
#use File::Copy;

my    $path= '/home/file_a';
my $altpath= '/home/default';

open(FILE,$path) or open(FILE,$altpath);
while (<FILE>) {
        print;
}




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

Date: 02 Jun 1999 10:52:39 -0500
From: Dale Henderson <dhenders@cpsgroup.com>
Subject: Re: pipes??
Message-Id: <87675661mg.fsf@camel.cpsgroup.com>

>>>>> "James" == James Stevenson <James@linux.home> writes:

    James> Hi i am trying to exec an external program am i need to
    James> read the data that it prints to the STDOUT how can i do
    James> this and is it down with pipes??

    James> thanks

     if I understand the question, you want to spawn an external
     program and read its data through a pipe in the parent process. 

     try

     open (CHLDSTOUT, "cat foo.txt |");
     
     (replace "cat foo.txt" with your process name)

     for more info try perldoc -f open or man perlfunc



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

Date: Wed, 2 Jun 1999 16:34:06 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: req: sendmail specs
Message-Id: <FCpKou.IpB@csc.liv.ac.uk>

In article <7j3coc$ir$1@zonnetje.nl.net>,
"Bastiaan S van den Berg" <office@asc.nl> writes:
> 
> Andrzej Filip heeft geschreven in bericht <3755335E.3427F78A@bigfoot.com>...
>>
>>
>>Bastiaan S van den Berg wrote:
>>
>>> does anyone know a site to , or information about handling the
>>> /usr/lib/sendmail program?
>>>
>>> i'm trying to send mail from a perl program with the following commands ,
>>> does anyone have an idea why it won't send mail?
>>>
>>> cul8r
>>> buZz
>>
>>1) Add -oi command line option to sendmail invocation.
>>2) Check exit code returned by sendmail (close exit code)

Can't see the rest of this thread, so some one may have already suggested
this.

Goto

	ftp://thrush.omix.com/pub/perl/modules/Mail-Sendmail-1.10.tar.gz

and get Byron's excelent sendmail module (not available from CPAN) and use
that, it's much easier. Even if you don't want to use it (there are
strange people who wont use modules !!!!) then the code therin and how
Byron deals with the returned sendmail error codes will deffinately help
you.

I have been using it for nearly a year now with no ill effects, it's been
resposible for correctly passing several thousand emails to sendmail in
that time without a hitch.

-- 
Ian J. Garlick
ijg@csc.liv.ac.uk

We are Pentium III of Borg. Prepare to be identified.
Deactivation is futile.



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

Date: Wed, 02 Jun 1999 16:20:03 GMT
From: markro@nortelnetworks.com (Mark R.)
Subject: Re: Running a Background Process from CGI
Message-Id: <37555727.144988530@carnews0>

Hi guys,

Thanks for your help.

I haven't solved it yet though.  Following is my latest position:

# fork process into child and parent.
$pid = fork();
if ($pid == 0 ) {
  # child process -- run RS/1
  close STDIN;
  close STDOUT;
  #exec ("$rs1CallPre $rs1CallPost >> /tmp/.h.log &");
  system ("$rs1CallPre $rs1CallPost >> /tmp/.h.log &");
} else {
  # parent process -- Make response page
  &HTMhead;
  print "An email will be sent to <FONT
COLOR=\"blue\">$in{\"emailid\"}\@nortelnetworks.com</FONT>
         when the web page is created.<BR><HR WIDTH=\"50%\">";
  print "For debugging, the RS/1 call is as follows:<BR>";
  print "<FONT FACE=\"Courier New\" SIZE=\"-1\"> $rs1CallPost
</FONT><BR>";
  &HTMfoot;
  exit;
}


Ideas:
1. I've tried both exec and system and seem to get the same results.
2. I've tried both with "exit" and without.
3. I'm also noticing that I get the output received from the a program
called from RS/1 (an analysis package we have).  The RS/1 output goes
as expected to the .h.log file but, it calls another program (webify -
chops up postscript file) and the output from that comes to the Web
window.

Any help is greatly appreciated.

Thanks,
M.

On Mon, 31 May 1999 13:24:35 -0400, rjk@linguist.dartmouth.edu (Ronald
J Kimball) wrote:

>Mark R. <markro@nortelnetworks.com> wrote:
>
>> I have a Perl-CGI script which makes a call to another script (not a
>> Perl script).  I want the script which is called from the Perl script
>> to be run in the background.  Is there any easy way to do this?
>> Presently, using the "system" command to make the call, the procedure
>> must be fully completed before the user sees the response page.  The
>> procedure that I want in the background eventually emails the user
>> something.  The reason I want it in the background is because it
>> updates web pages of data and depending on what the user selects, it
>> could take a very long time.
>
>I think you want to use fork().  The parent should print out the
>response page and exit.  The child should close STDOUT, and run the
>system command.
>
>-- 
> _ / '  _      /       - aka -
>( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
>    /                                http://www.tiac.net/users/chipmunk/
>        "It's funny 'cause it's true ... and vice versa."



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

Date: Wed, 02 Jun 1999 12:41:12 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: sendmail doesn't work
Message-Id: <37555e5d.0@usenet.fccj.cc.fl.us>

In article <928336338.638375@proxy1.bigplanet.com>, "Sherry" 
<vision4@bigplanet.com> wrote:


> http://easyhomebiz.virtualave.net
>
> I'm having trouble with a pre-written perl script.  It functions beautifully
> in accepting links, collecting e-mail addresses and posting links.  It does
> not send an automatic e-mail after a link is posted like it should.
>
> My permissions are set at chmod666 for all files except my links.cgi which
> is set for 777
>
> The cgi script is:
>
<snip>
> # FFA Blaster requries that you are running Windows 95\/98.
> #
> # Copyright 1998-99 SPCK Software - All rights reserved
<snip>
> # Server path of sendmail or equivalent.
> $mailprog = "/usr/sbin/sendmail";


These two are mutually exclusive...

Are you running on Windows?  If so, you prolly need blat.exe
If you REALLY ARE on nix, I would delete the following line
from the source code:

> # FFA Blaster requries that you are running Windows 95\/98.

PS - They spelt requires wrong as well;
should you really trust them?

HTH,
-Sneex-  :]
______________________________________________________________________
Bill Jones  Data Security Specialist  http://www.fccj.org/cgi/mail?dss

         Jacksonville Perl Mongers
         http://jacksonville.pm.org
         jax@jacksonville.pm.org

         Running LinuxPPC RedHat 5.0 (Hurricane)
       __ _                     http://www.linuxppc.org
      / /(_)_ __  _   ___  __   http://www.apache.org
     / / | | '_ \| | | \ \/ /   http://www.redhat.com
    / /__| | | | | |_| |>  <    http://www.perl.com
    \____/_|_| |_|\__,_/_/\_\   http://www.gimp.org



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

Date: Wed, 02 Jun 1999 18:12:03 +0200
From: Pavel Hlavnicka <pavel@asei.cz>
Subject: Re: String extraction problem - please help?
Message-Id: <375557D3.D48415DF@asei.cz>

Try this:

$line="/usr/home/avert/www/cgi/archive_98/dec/news_2";
print "$1, $2" if $line =~ m[_(\d+)/(\w+)];

It supposes uniqueness of _98/dec/ picture in the string


Andrew Collington wrote:
> 
> Hi there,
> 
> I have an array of strings, such as:
> 
> $lines[0]="/usr/home/avert/www/cgi/archive_98/dec/news_2"
> $lines[0]="/usr/home/avert/www/cgi/archive_99/jan/news_1"
> 
> and many more in that array.  Now I'm going through that array in the
> normal way with foreach, such as:
> 
> foreach $line (@lines) {
>   ...
> }
> 
> My problem is this...  I would like to be able to extract the '_??' part
> of the string, and the 3 character long month abreviation too (jan, feb,
> ..., dec), but without the /'s.  The directory
> '/usr/home/avert/www/cgi/' renamins constant, but the _?? ranges from
> _96 to _99.  The month changes all the time, as does the news_x part
> (which I am not interested in).
> 
> I know it would be something like 'if ($line =~
> /(something)archive(something)/)' to extract the require strings, but I
> just don't know regular expression enough (at all!) to do that.  Though
> I know you would use $1, $2, etc as the strings matched, but.. well, you
> get my problem... :)
> 
> Any help you can offer on this would be very much appreciated!
> 
> Thanks!
> 
> Andy


-- 
Pavel Hlavnicka
A.S.E.I. Ltd; Prague
tel.: +420 2 24106102
e-mail: pavel@asei.cz


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

Date: 02 Jun 1999 17:22:57 +0100
From: Brian McCauley <B.A.McCauley@bham.ac.uk>
Subject: Re: String extraction problem - please help?
Message-Id: <u96756wp0e.fsf@wcl-l.bham.ac.uk>

Andrew Collington <webmaster@avert.org> writes:

> $lines[0]="/usr/home/avert/www/cgi/archive_98/dec/news_2"
> $lines[0]="/usr/home/avert/www/cgi/archive_99/jan/news_1"

> My problem is this...  I would like to be able to extract the '_??' part
> of the string, and the 3 character long month abreviation too (jan, feb,
> ..., dec), but without the /'s.  The directory
> '/usr/home/avert/www/cgi/' renamins constant, but the _?? ranges from
> _96 to _99.  The month changes all the time, as does the news_x part
> (which I am not interested in).
> 
> I know it would be something like 'if ($line =~
> /(something)archive(something)/)' to extract the require strings, but I
> just don't know regular expression enough (at all!) to do that.  Though
> I know you would use $1, $2, etc as the strings matched, but.. well, you
> get my problem... :)

Your problem is inability to read man pages.

There are many possible right answers.  One is:

$line =~ m[archive_(\d+)/(\w+)/\w+$]

-- 
     \\   ( )  No male bovine  | Email: B.A.McCauley@bham.ac.uk
  .  _\\__[oo   faeces from    | Phones: +44 121 471 3789 (home)
 .__/  \\ /\@  /~)  /~[   /\/[ |   +44 121 627 2173 (voice) 2175 (fax)
 .  l___\\    /~~) /~~[  /   [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
  # ll  l\\  ~~~~ ~   ~ ~    ~ | http://www.wcl.bham.ac.uk/~bam/
 ###LL  LL\\ (Brian McCauley)  |


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

Date: Wed, 02 Jun 1999 12:21:29 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: String to String1 to String2 ???
Message-Id: <375559bb.0@usenet.fccj.cc.fl.us>

In article <7j29nm$pe2$1@nntp3.atl.mindspring.net>, 
<joeyandsherry@mindspring.com> wrote:


>
> Thanks in Advance.
>
> I'm writing a script and I've chosen to have the selections from a form
> named as such:
> $string1;
> $string2;
> $string3;
> etc.
>
> I'm using these variables in an "IF" statement, and because there is a
> hundred of them...Id there a way to use a "while" statement to add 1 to the
> end of each variable and then have it recognized by perl as being a string?
>
> Is this possible?


Not a CGI question; you should really ask
this in comp.lang.perl.misc

???
Add '1' to $string, then '1' to $string1 making $string2?
I don't think so...

Perl automatically switches from strings to numbers
as it feels it needs to.  You could force things
by trying some string math -

$string += $string;

But most likely you won't get the results you
expect.  I have CC'ed comp.lang.perl.misc for you;
please read any additional answers there.

Maybe someone in that clpm group knows how
to make $string to $string1 to $string2, et al...

HTH,
-Sneex-  :]
______________________________________________________________________
Bill Jones  Data Security Specialist  http://www.fccj.org/cgi/mail?dss

         Jacksonville Perl Mongers
         http://jacksonville.pm.org
         jax@jacksonville.pm.org

         Running LinuxPPC RedHat 5.0 (Hurricane)
       __ _                     http://www.linuxppc.org
      / /(_)_ __  _   ___  __   http://www.apache.org
     / / | | '_ \| | | \ \/ /   http://www.redhat.com
    / /__| | | | | |_| |>  <    http://www.perl.com
    \____/_|_| |_|\__,_/_/\_\   http://www.gimp.org


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

Date: 02 Jun 1999 17:37:59 +0100
From: Brian McCauley <B.A.McCauley@bham.ac.uk>
Subject: Re: Timeout question...(CODE INCLUDED)...Please help!
Message-Id: <u94skqwobc.fsf@wcl-l.bham.ac.uk>

Mitch <portboy@home.com> writes:

> I'm working on a timeout issue.  Here's how the problem is setup.  There

[ snip ]

>                 alarm(5);

[ snip ]

>                 if ($@ =~ /timeout/) {

Where does "timeout" come from?

When an evel is killed by a SIGALRM I see $@ eq "Alarm clock".

I think this may well be OS dependanant.

To force the value of $@ ...

local $SIG{'ALRM'} = sub { die 'timeout' };

-- 
     \\   ( )  No male bovine  | Email: B.A.McCauley@bham.ac.uk
  .  _\\__[oo   faeces from    | Phones: +44 121 471 3789 (home)
 .__/  \\ /\@  /~)  /~[   /\/[ |   +44 121 627 2173 (voice) 2175 (fax)
 .  l___\\    /~~) /~~[  /   [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
  # ll  l\\  ~~~~ ~   ~ ~    ~ | http://www.wcl.bham.ac.uk/~bam/
 ###LL  LL\\ (Brian McCauley)  |


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

Date: 02 Jun 1999 10:56:37 -0500
From: Dale Henderson <dhenders@cpsgroup.com>
Subject: Re: undesired result with .* in s command
Message-Id: <874skq61fu.fsf@camel.cpsgroup.com>

>>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:

    Larry> [Posted and a courtesy copy mailed.]  In article
    Larry> <7j1hpq$8hn$1@autumn.news.rcn.net> on 1 Jun 1999 21:02:50
    Larry> GMT, Steve <stevenh@erols.com> says...
    >> I am new to Perl, and I'm having a problem with the .*
    >> expression in the substitute function.
    >> 
    >> I am trying to strip the middle portion out of a string where I
    >> don't know what that portion is.  For example, <p
    >> align=center>, I would like to have just <p>.  To do that, I
    >> tried $var =~ s/<p.*>/<p>/ig;

    Larry> That didn't work since the .* matches the longest possible
    Larry> pattern. ...

    Larry> .*? matches the shortest possible pattern.  Read about
    Larry> 'non-greedy quantifiers' in perlre.

     another (more complex) posibility is /<p[^>]*>/



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

Date: Wed, 02 Jun 1999 09:37:32 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Trevor Crisp <trevor@cbcu.cam.ac.uk>
Subject: Re: Win32 NetShareGetInfo
Message-Id: <37555DCC.EA070BBB@mail.cor.epa.gov>

[courtesy cc sent to poster]

Trevor Crisp wrote:
> 
> Perl Newbie in need of help!!!! ;-)
> =====================
> 
> Under WindowsNT4, a script is needed to create a home folder for a
> particular user.  This folder needs to be shared and need permission
> modification.
> 
> A script has been written that creates the folder and also shares it.
> How do you retrieve and view the share info with NetShareGetInfo?
> 
> How do you modify the share and security permissions with Win32
> functions in a perl script?  How do you retrieve and view this info as
> well?

This ng tends to be fairly unix-centric, so you may not get a
good answer here.  If that is the case, then you may want to
go to a listserv which is primarily win32-centric instead.
Go to   http://www.activestate.com/support/mailing_lists.htm
to subscribe to the perl-win32-users list.  Then ask there.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

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

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