[11808] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5408 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 17 21:07:22 1999

Date: Sat, 17 Apr 99 18:00:18 -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           Sat, 17 Apr 1999     Volume: 8 Number: 5408

Today's topics:
    Re: "mixed"-Quantifier available ? <rick.delaney@home.com>
    Re: "mixed"-Quantifier available ? <pochmann@gmx.de>
    Re: 'Require' options (Abigail)
    Re: Can i run cgi in Win95 of my PC ?? (Tad McClellan)
    Re: Complicated reg. exp. question <rick.delaney@home.com>
    Re: ifeither--How about some feedback? (Sean McAfee)
    Re: ifeither--How about some feedback? (Randal L. Schwartz)
    Re: ifeither--How about some feedback? (Ilya Zakharevich)
        invoking by "fire and forget" <e_broyles@yahoo.com>
    Re: Looking for better ways of solving a pattern matchi <rick.delaney@home.com>
    Re: Make problem in Win95 palenaka@my-dejanews.com
    Re: Make problem in Win95 <kenmar@ihug.co.nz>
    Re: Net::NNTP <cassell@mail.cor.epa.gov>
    Re: New FAQ: How can I read in an entire file all at on (Dmitry Epstein)
    Re: New FAQ: How can I read in an entire file all at on (Jim Britain)
    Re: question about format and write <rick.delaney@home.com>
    Re: Removing file extentions <mickv@home.com>
    Re: Removing file extentions <m_ching@hotmail.com>
    Re: Some troubles with format <cassell@mail.cor.epa.gov>
    Re: Split sizes instead of pattern? <m_ching@hotmail.com>
    Re: Splitting length instead of delimiting character? <m_ching@hotmail.com>
        umask <martin@guest-books.com>
    Re: Wanted: some help for a perl script <cassell@mail.cor.epa.gov>
    Re: Wanted: some help for a perl script (Tad McClellan)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Sat, 17 Apr 1999 23:26:26 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: "mixed"-Quantifier available ?
Message-Id: <37191AA9.8C24D205@home.com>

[posted & mailed]

Stefan Pochmann wrote:
> 
> Hi there,
> 
> I'd like to have a regular expression for the following problem:
> 
> It shall recognize a sequence of (unordered) tokens, but at most one 
> of each,

    print "Matched $_\n" if
        /([abc]{3})/            # a sequence of (unordered) tokens
        &&                      # but
        $1 !~ /([abc]).*(\1)/;  # at most one of each

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sun, 18 Apr 1999 01:44:13 +0200
From: Stefan Pochmann <pochmann@gmx.de>
To: Rick Delaney <rick.delaney@home.com>
Subject: Re: "mixed"-Quantifier available ?
Message-Id: <37191CCD.6B53@gmx.de>

Rick Delaney wrote:
> > I'd like to have a regular expression for the following problem:
> >
> > It shall recognize a sequence of (unordered) tokens, but at most one
> > of each,
> 
>     print "Matched $_\n" if
>         /([abc]{3})/            # a sequence of (unordered) tokens
>         &&                      # but
>         $1 !~ /([abc]).*(\1)/;  # at most one of each

Thanx, but ...

although your version requires all elements (It should be a list of
optional values), this is no big problem. But you got to admit, that it
is not very, nice, is it ?

And moreover: What do you do if this needs to be checked in a bigger
regular expression ? I don't want to waste time for matching the rest of
of it and then find out: Oops, that was wrong.

But the main problem is, if your regex finds a sequence with your first
matching, it's over ! As far as I know, perl will stop searching as soon
as it is successfull. When you test the no-more-than-one rule
afterwards, how can you tell perl to continue searching, where it has
stopped ?

-- 
"I hope the Red Sox win the championship,"

Stefan Pochmann

eMail:   pochmann@gmx.de
WWW:     http://www.student.informatik.tu-darmstadt.de/~pochmann


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

Date: 17 Apr 1999 23:39:48 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: 'Require' options
Message-Id: <7fb644$khr$1@client2.news.psi.net>

Tom Christiansen (tchrist@mox.perl.com) wrote on MMLV September MCMXCIII
in <URL:news:3718aa2d@cs.colorado.edu>:
<>  [courtesy cc of this posting sent to cited author via email]
<> 
<> In comp.lang.perl.misc, 
<>     "Egon Kraaikamp" <kraaikae@xs4all.nl> writes:
<> :Is it possible to 'require' a file outside the server's own filesystem (Unix
<> :and/or NT) e.g. by reffering to another IP address?
<> :Anyone having experiences with this?
<> 
<> You can only require files.  The trick, therefore, is to make
<> the remote machine look like a file.  The answer, of course,
<> is to use NFS mounts.  


Well, you can always do

   require $file;

and have $file be a tied object where the FETCH uses for instance
GOPHER to fetch the file from another server, then stores it on your
local machine.

But that's a bit far fetched.


Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: Sat, 17 Apr 1999 14:45:32 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Can i run cgi in Win95 of my PC ??
Message-Id: <cskaf7.uj.ln@magna.metronet.com>

Kevin !;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!; (austin95002887@yahoo.com) wrote:


: Can i run cgi in Win95 of my PC ??


   Yes.


: ( I have no Network Card, and i really do not want to buy one 
: because of this reason. )


   You do not need a network card unless you need to connect 
   to a network.

   You do not need to connect to a network to run an HTTP server.


: Because, i want to test the cgi program wriiten by myself before 
: upload the cgi to server.


   You must have an HTTP server installed to do CGI.

   So install a server on your local machine, and you
   are off to the races.


   You realize of course, that you question has absolutely 
   nothing to do with Perl?

   You install a server on your local machine to run CGI
   programs written in C or Visual Basic or any other
   language too.



   In the future, please ask CGI question in the CGI newsgroup
   and Perl questions in the Perl newsgroup.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 18 Apr 1999 00:18:49 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Complicated reg. exp. question
Message-Id: <371926F1.45CAD792@home.com>

[posted & mailed]

Alex Farber wrote:
> 
> Thanks for your reply, but it is unfortunately more complicated -
> those are some phone switches assembler files and they can have
> comments after some instruction, like this:
> 
>     JEC DR0,0,L1;       ! IF LEGP:LDIAMPROC = ZYES THEN !

Is the comment always to the end of the line or is it bounded?  This
could get pretty complicated if you have stuff like

! IF LEGP:LDIAMPROC = ZYES THEN ! PCORI:BLOCK=SHMM,IA=H'2BBB;

where the last part is not commented.

> 
> and that PCORI can appear not only at the line beginning:
> 
>     END; PCORI:BLOCK=SHMM,IA=H'2BBB;

Since all instructions end in a semi-colon, why not make that your
record separator?  

The following will not change the 5th line of data but I'm not sure if
that matters or not.  It also might add an extra semi-colon to the end
of your file if the data doesn't end with a semi-colon.

#!/usr/bin/perl -w

use strict;

$\ = $/ = ';';
my $load = 'ABCDE1234';

while(<DATA>){
    chomp;
    next unless /PCORI\s*:/;
    next if /!.*$/;
    next if s/\bCI=[A-Z]{5}\d{4}\b/CI=$load/;
    $_ .= ",CI=$load" unless /CI=/;
}
continue { print }

__END__
END; PCORI:BLOCK=SHMM,IA=H'2BBB;
PCORI:BLOCK=SHMM,IA=H'2BBB,CI=MNASF0276;
JEC DR0,0,L1;       ! IF LEGP:LDIAMPROC = ZYES THEN !
!PCORI:BLOCK=SHMM,IA=H'2BBB;
! IF LEGP:LDIAMPROC = ZYES THEN ! PCORI:BLOCK=SHMM,IA=H'2BBB;
PCORI:BLOCK=SHMM,IA=H'2BBB;

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 17 Apr 1999 22:15:31 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: ifeither--How about some feedback?
Message-Id: <7K7S2.1159$hl6.48122@news.itd.umich.edu>

In article <7faq6c$tag@enews3.newsguy.com>,
William H. Asquith <asquith@macconnect.com> wrote:
>my ($a, $b, $c, $d, $e, $f);
>while(1) {
>  ## do some stuff
>  last if($a < 4 || $b < 4 || $c || < 4 || $d < 4 || $f < 4);
>}

>I would love to shorten the above 'last if' test with one that is shorter,
>here is a suggestion.

>while(1) {
>  ## do some stuff
>  last ifeither($a, $b, $c, $d, $e, $f < 0);  # suggested form
>}

That would require changes to the "last" semantics, and there's already a
perfectly good "last if" idiom, so I think the closest thing to your above
suggestion would be:

sub either { my $sub = pop; for (@_) { return 1 if $sub->($_); } return 0; }
$less_than_zero = sub { $_[0] < 0 };

while (1) {
	## do some stuff
	last if either($a, $b, $c, $d, $e, $f, $less_than_zero);
}

Other, more eye-pleasing variants are certainly possible.

>ifeither could be generalized to
>ifeither($a, $b, $c, $d, $e, $f <= $value || $b, $c);  # etc. . .

I don't grok at all what this code is supposed to do...

>I know that there isn't an ifeither in Perl, but such a function would be
>_very_readable_ indeed.

>What other idioms do you all use for the above situation?  Please comment,
>maybe there are already better ways?

Here's how I would probably do it, if the number of values to be tested is
small:

last if map($_ < 0 ? 1 : (), $a, $b, $c, $d, $e, $f);

For large numbers of values, I'd go with something similar to the first
bit of code I wrote above, for efficiency reasons.

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: 17 Apr 1999 15:42:52 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: ifeither--How about some feedback?
Message-Id: <m1iuauq36b.fsf@halfdome.holdit.com>

>>>>> "William" == William H Asquith <asquith@macconnect.com> writes:

William> All,
William> Working today with the following.

William> my ($a, $b, $c, $d, $e, $f);
William> while(1) {
William>   ## do some stuff
William>   last if($a < 4 || $b < 4 || $c || < 4 || $d < 4 || $f < 4);
William> }

William> I would love to shorten the above 'last if' test with one that is shorter,
William> here is a suggestion.

No need for new syntax:

    my ($a,$b,$c,$d,$e,$f);

    OUTER: while (1) {
      ## do some stuff
      for ($a,$b,$c,$d,$e,$f) {
	last OUTER if $_ < 4;
      }
    }

OUTER: print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 17 Apr 1999 23:25:00 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: ifeither--How about some feedback?
Message-Id: <7fb58c$cfi$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Randal L. Schwartz
<merlyn@stonehenge.com>],
who wrote in article <m1iuauq36b.fsf@halfdome.holdit.com>:
> No need for new syntax:
> 
>     my ($a,$b,$c,$d,$e,$f);
> 
>     OUTER: while (1) {
>       ## do some stuff
>       for ($a,$b,$c,$d,$e,$f) {
> 	last OUTER if $_ < 4;
>       }
>     }

No needs for these hoop either:

   require 5.005;
   while (1) {
     ## do some stuff
     $_ < 4 and last for ($a,$b,$c,$d,$e,$f);
   }

Or even

   last if grep $_ < 4, $a,$b,$c,$d,$e,$f;

Ilya


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

Date: Sat, 17 Apr 1999 23:18:12 GMT
From: e_broyles <e_broyles@yahoo.com>
Subject: invoking by "fire and forget"
Message-Id: <7fb4re$saf$1@nnrp1.dejanews.com>

How can I start a perl program via the web and not have it stop?  The program
does not (currently) include any output to the browser.  I have also tried it
with.  When I include some dummy output (to avoid timeout errors), the
program stops after it outputs to browser.  How can I separate the two
processes (one to output some dummy text, then the other one that continues
to process even if the output text segment stops.  I am running on NT with
IIS.  Hope that someone has done this before and can give me a hand.  I have
tried this several different ways, to no avail so far.

Thanks in advance,


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sat, 17 Apr 1999 22:54:01 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Looking for better ways of solving a pattern matching and replacement task...
Message-Id: <3719130F.227491D5@home.com>

[posted & mailed]

Ian Berwick wrote:
> 
> Also, how can I get s/// to recognize that the first character in the 
> string is also the first letter of a word?

Look up \b in perlre.  Then these:

> $text =~ s/[A-Z]([\W])/H$1/g;
> $text =~ s/([\W])[A-Z]/$1B/g;

can become these:

    $text =~ s/[A-Z]\b/H/g;
    $text =~ s/\b[A-Z]/B/g;

Here's my two pass stab at it.

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

my $baa = "HELLO! This is a COMPuteR?";

$baa =~ s/(\w+)/('a' x (length($1) - 1) . 'h') ^ lc($1) ^ $1/ge;
$baa =~ s/\b(\w)/('b' ^ lc($1) ^ $1)/ge;

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 17 Apr 1999 22:48:43 GMT
From: palenaka@my-dejanews.com
Subject: Re: Make problem in Win95
Message-Id: <7fb349$que$1@nnrp1.dejanews.com>

Go download a win32 port of gcc. I like to use the mingw32 port personally,
but there is also a (slow) cygnus port and a (pretty cool) dos port DJPP.


In article <371A2E5A.71E2955E@ihug.co.nz>,
  Ken Mar <kenmar@ihug.co.nz> wrote:
> Hi all gurus,
>   I tried installing modules in my Win95. Performing the perl
> Makefile.PL was successful but the other 3 steps just couldn't proceed.
> Am I missing something? How do one do make, make install and the rest of
> it in Win95?
>   Thanks.
>
> -Ken
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 19 Apr 1999 08:05:46 +0800
From: Ken Mar <kenmar@ihug.co.nz>
Subject: Re: Make problem in Win95
Message-Id: <371A735A.AFC88CFF@ihug.co.nz>

> Go download a win32 port of gcc. I like to use the mingw32 port personally,
> but there is also a (slow) cygnus port and a (pretty cool) dos port DJPP.
 Gee I know this going to be a dumb question, but could you kindly point
me the location where I could download one? Preferably in *.zip or
something which winzip would hv no problem extracting. I found the gcc
but it's a 6+ MB whopper. Is that the correct one?

-Ken


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

Date: Sat, 17 Apr 1999 15:35:04 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Net::NNTP
Message-Id: <37190C98.48EE3FA4@mail.cor.epa.gov>

E. Yuan wrote:
> 
> Hi, there:
> 
> I have a question regarding the NNTP module, and I would appreciate any
> thoughts you may have..
> 
> I was trying to write a News client, and for that I followed the
> examples in Tom Christiansen's "Perl Cookbook". But the sample program

Be aware that, while the 'Perl Cookbook' is a great book, it is
somewhat unix-centric.. as is its lead author.  :-)  However, that's
not quite your problem here.

> in the book didn't work - it requires the Net::NNTP module, but in my
> ActiveState Perl (build 515), there's no such a module. There is
> however, a module called nntp.pm under LWP::Protocol. So I tried to use
> that, it didn't work either, because this LWP::Protocol::NNTP module
> also requires Net::NNTP.

LWP::Protocol::NNTP is not the Net::NNTP module.
 
> My questiones are: is my Perl installation wrong? where can I get the
> right NNTP module?

Your installation is not *wrong*.  But no version of Perl comes with
*every* module available at CPAN, fully up-to-date and ready to install.

Go to www.activestate.com and follow the links to a Net::NNTP version
for your Perl.
 
> Thanks in advance for your help!

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


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

Date: Sat, 17 Apr 1999 23:33:41 GMT
From: mitiaNOSPAM@nwu.edu.invalid (Dmitry Epstein)
Subject: Re: New FAQ: How can I read in an entire file all at once?
Message-Id: <3719176e.361152899@news.acns.nwu.edu>

On 17 Apr 1999 16:31:46 -0400, Uri Guttman <uri@home.sysarch.com>
wrote:
>>>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:
>
>  >> 2. If you are reading (or writing) from more than one file at the same
>  >> time, you'll probably find that reading/writing entire files is always
>  >> much faster than reading/writing them line by line.
>
>  DG> If you are reading from and writing to several files simultaneously
>  DG> you should be using 4 arg select for I/O multiplexing, you shouldn't
>  DG> just be reading everything into memory.  Once again, the problem is
>  DG> that any program that requires all files to be held in memory won't
>  DG> scale.
>
>select doesn't work on regular files, only on sockets, pipes and
>tty's. regular files are effectively always ready for i/o so they
>wouldn't block on select.
>
>and why can't you read from multiple files line by line at the same
>time? just use multiple file handles, either named or created and stored
>in some structure.

Well, a common program often looks like this:

	read line from file A
	do something
	write line to file B

Unless you set large enough IO buffers, this will amount to going back
and forth between different sections of the hard drive, which, of
course, will slow you down a lot.  And is there even a command to set
the size of IO bufers in Perl?

I agree that if there is a possibility of one day encountering a very
large file, you shouldn't just blindly attempt to suck it all in the
memory; however if you know what you are dealing with (e.g. a specific
type of input data that may even have a set length), then you
shouldn't be afraid to use this approach if there are benefits in it.

Dmitry
--
Remove NOSPAM and .invalid from mitiaNOSPAM@nwu.edu.invalid


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

Date: Sun, 18 Apr 1999 00:32:56 GMT
From: jbritain@home.com (Jim Britain)
Subject: Re: New FAQ: How can I read in an entire file all at once?
Message-Id: <3719260b.71299822@news>

On 17 Apr 1999 16:31:46 -0400, Uri Guttman <uri@home.sysarch.com>
wrote:

>slurping in whole files vs. line by line is a decision that needs to be
>made knowing the maximum size of the file, how it needs to be processed,
>speed of the program, etc. there is no absolute answer to which is
>better. i have used both many times. in fact i have my own little set of
>read_file/write_file subs to handle whole file slurping. there was a
>thread about this a few months ago (maybe it was on clp.moderated).

Yes,
comp.lang.perl.moderated:
Subject: PFR: read_file, write_file
Author: Uri Guttman <uri@sysarch.com>

is not the biginning question, but does begin the thread, and develop
a generic read_file, write_file, with the emphasis on reading.




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

Date: Sun, 18 Apr 1999 00:04:55 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: question about format and write
Message-Id: <371923A6.9E932CC9@home.com>

[posted & mailed]

Scott Knight wrote:
> 
> after i write to the log file, the lines arent the same length. i want
> that last feild to print spaces after 41 so that the second line is
> exactly the same length as the first, but for some reason, it always jumps
> to a new line after the alst variable and doesnt fill the rest of the
> space with spaces. How do i fix this?

I don't think the docs on format say anything about padding the last
field with spaces for you and I think it would be a bad thing if they
did.

You could try padding the last field variable with sprintf before the
write, but don't bother because that doesn't work either.  This might be
a bug but I think it's good that write strips off trailing whitespace. 
You shouldn't be using format/write for storing fixed length data
anyway.  

For that you should use pack or printf.

perldoc perlfunc

You might try

    printf "%-8.8s , %-10.10s, %-5.5s\n", $date, $time, $temperature;

or with tabs as separators

    $foo = pack "A8 x A10 x A5", $date, $time, $temperature;
    $foo = tr/\0/\t/;
    print "$foo\n";

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 17 Apr 1999 22:26:46 GMT
From: "Michael Villeneuve" <mickv@home.com>
Subject: Re: Removing file extentions
Message-Id: <GU7S2.821$QE6.267283@news1.rdc1.on.wave.home.com>

Hi Jeremy,

How about this?  This shouldn't make too much difference until you hit a lot
of files with multiple .'s.  There is most likely someone else out there who
has a better answer(I'm still pretty new at this):

if ($link =~ /\.(?!.*\.)/){        #if there are no other .'s
    $link =~ s/\..*//;              #remove it
}else{
    @linkarray = split(/\./,$link);        #split on .'s
    $garbage = pop @linkarray;        # send the last element to oblivion
    $link = join (/\./,@linkarray);        # join the remaining together for
the new filename
}

Keep in mind that I haven't tested this version but have used a similar
construct and it worked fine.

Cheers,
Mike

me@here.com wrote in message <3718f058.27190495@nntp.noc.netcom.net>...
>
> I have made a cgi script which will take the contents of my
>website and format it into webpages on the fly but in doing so I have
>come across the problem of removing extensions.  The following is the
>syntax used presently but I found that it will remove everything after
>the first instance of the period and not the desired last.
>
>$link =~ s/\..*//;
>
>ex: something.zip transforms into something without the .zip
>
> Now this isn't a problem for 99.9 percent of the files but
>there are a small few that have multiple periods. In these cases the
>link users see has been truncated:
>
>ex: something 1.0.zip transforms into something missing the 1.0
>
> Does anyone have a sly method (must be CPU friendly, some of
>these directories hold 2,000 files) which will remove only the last
>instance of a period and any characters following?
>
>Thanks for any assistance,
>
>-jeremy
>jeremy.witt@cacheflow.com




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

Date: Sat, 17 Apr 1999 14:09:51 -1000
From: "Michael Ching" <m_ching@hotmail.com>
Subject: Re: Removing file extentions
Message-Id: <3718f9a9.0@news.hawaii.rr.com>

$link =~ s/\.[^\.]*//;


<me@here.com> wrote in message news:3718f058.27190495@nntp.noc.netcom.net...
>
> I have made a cgi script which will take the contents of my
> website and format it into webpages on the fly but in doing so I have
> come across the problem of removing extensions.  The following is the
> syntax used presently but I found that it will remove everything after
> the first instance of the period and not the desired last.
>
> $link =~ s/\..*//;
>
> ex: something.zip transforms into something without the .zip
>
> Now this isn't a problem for 99.9 percent of the files but
> there are a small few that have multiple periods. In these cases the
> link users see has been truncated:
>
> ex: something 1.0.zip transforms into something missing the 1.0
>
> Does anyone have a sly method (must be CPU friendly, some of
> these directories hold 2,000 files) which will remove only the last
> instance of a period and any characters following?
>
> Thanks for any assistance,
>
> -jeremy
> jeremy.witt@cacheflow.com




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

Date: Sat, 17 Apr 1999 15:02:11 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Some troubles with format
Message-Id: <371904E3.F8122EB4@mail.cor.epa.gov>

agniora@usa.net wrote:
> 
> the following script is giving the error
> format not terminated at myprog.pl line 13
> 
> heres my program :
> sub write_line {
>   local ($astring, $anumber) = @_;
>   $~ = "ALINE";
>   write;
> }
> write_line "hello", 24.793;
> format ALINE =
> @<<<<<<<<<<<<                                   @#####.##
> $astring, $anumber
> .
> 
> anyone knows whats going on here?

Well, I can make a guess.  I'll guess that your format is not 
terminated at line 19.  That's what the error says.  And I'll
guess you didn't go to the perldiag manpage and look up what that
error means:

     Format not terminated
         (F) A format must be terminated by a line with a
         solitary dot.  Perl got to the end of your file without
         finding such a line.

So, odds are that there's some whitespace following your period on
line 19, and it's messing things up.  Delete the whitespace after the
period.

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


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

Date: Sat, 17 Apr 1999 13:58:19 -1000
From: "Michael Ching" <m_ching@hotmail.com>
Subject: Re: Split sizes instead of pattern?
Message-Id: <3718f6f7.0@news.hawaii.rr.com>

Is there something wrong with substr?


Mats Pettersson <mats.pettersson@falukuriren.se> wrote in message
news:3718C9C5.69E16E7C@falukuriren.se...
> Hi!
>
>
>
> I'm currently writing a script that would split up lines in a file into
>
> fields for import into a database.
>
>
>
> However most examples i see uses the split /x/ method, where in my case
>
> i would need to split a line in different sizes into an array.
>
>
>
> A line in the file may look as follows:
>
>
>
> 1999-01   6   4   2   1   7       5   3
>
>
>
> So the first field should be 7 characters the second 4 characters the
>
> third 4 characters and so on. Some of the fields might be empty (like
>
> the 7th in this example) so thats wy i just can't split with whitespace.
>
>
>
> Is there som sort of '@fields = split_size /7,4,4,4.../' command in
>
> perl?
>
>
>
> I've searched for examples and such, but don't seem to find any.
>
>
>
> Mats




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

Date: Sat, 17 Apr 1999 14:17:08 -1000
From: "Michael Ching" <m_ching@hotmail.com>
Subject: Re: Splitting length instead of delimiting character?
Message-Id: <3718fb60.0@news.hawaii.rr.com>

5 if you count the one with a different subject line
Larry Rosler <lr@hpl.hp.com> wrote in message
news:MPG.11826f095ca6dd0a9898ce@nntp.hpl.hp.com...
> [Posted and a courtesy copy sent.]
>
> Why did I get four postings of this message?
>
> In article <3718C2EB.80CB147E@falukuriren.se> on Sat, 17 Apr 1999
> 19:20:43 +0200, Mats Pettersson <mats.pettersson@falukuriren.se> says...
> ...
> > Is there som sort of '@fields = split_size /7,4,4,4.../' command in
> > perl?
>
> perldoc -f unpack
>
> A format string like 'A7 A4 A4 A4 ...' should do what you want.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Company
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com




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

Date: Sun, 18 Apr 1999 00:01:40 +0100
From: "Martin" <martin@guest-books.com>
Subject: umask
Message-Id: <7fb3up$sie$1@newnews.global.net.uk>

Hi, can anyone please help?

I need to make all files produced by a script have properties 0777.
The problem is that I wrote the (very long) script for an NT server
so did not chmod files after making them. I'm hoping I can use the
umask command to make new files have 0777 properties. I couldn't
find any info on the Perl manpages and I just found a puzzling footnote
in the Llama book. I did man umask from linux and couldn't understand
the manpage.

Will umask(00) at the top of my script cause new files made to have
default properties of 0777?

Martin




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

Date: Sat, 17 Apr 1999 15:23:10 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Wanted: some help for a perl script
Message-Id: <371909CE.4A07C387@mail.cor.epa.gov>

Eric Bohlman wrote:
> [snip of valuable advice]
> 
> With all that in mind, you have somehow come to the opinion that you
> would prefer that the changes be made by someone who:
> 
> 1) Is under no obligation to you.
> 
> 2) Isn't familiar with the script.
> 
> 3) Will not be compensated for the time to become familiar with the
> script and to make changes.

And most importantly:
  4) May be so totally incompetent that their code recommendations
  will sink you into a hideous, error-laden mire.

and
  5) May make changes which may invalidate any legal obligations the
  original authors had to maintain or support your code.  But I'm
  not a lawyer - I don't even play one on tv - so don't take my word
  for this one.
 
> [one more snip]

If you paid real cash dollars for that script, ask the company for
tech support.

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


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

Date: Sat, 17 Apr 1999 14:48:06 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Wanted: some help for a perl script
Message-Id: <61laf7.uj.ln@magna.metronet.com>

Marc Herms (marc@mercator.net) wrote:

: If someone has some spare time and would like to help me with just
: some small things for free, please let me know. 

: It4s really a small thing. 


   Then you should be able to learn enough programming to
   do it.



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

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

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