[22834] in Perl-Users-Digest
Perl-Users Digest, Issue: 5055 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 29 06:06:11 2003
Date: Thu, 29 May 2003 03:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 29 May 2003 Volume: 10 Number: 5055
Today's topics:
[PE] - Cerco Perl e PerlCgi con manuale in italiano in (Romolo Cappola)
Re: Bioperl? <dragaoon@sappers.no>
copying files to another directory Marck_us_invalid@hotmail.com
Re: copying files to another directory <REMOVEsdnCAPS@comcast.net>
Re: DMake (newbie) <randy@theoryx5.uwinnipeg.ca>
Re: DMake (newbie) <daniel_newhouse@earthlink.net>
Re: DMake (newbie) <randy@theoryx5.uwinnipeg.ca>
Re: does this make sence ? (about undef error on select <webmaster@neverseenbefore.com>
eval { }; does not shield -p on unopened filehandle Sys (Nick Simicich)
Re: eval { }; does not shield -p on unopened filehandle <tassilo.parseval@rwth-aachen.de>
Re: Expanding a newcommand in latex <mgjv@tradingpost.com.au>
hard time with regexp to validate image <woloski@sion.com>
Re: hard time with regexp to validate image (Malcolm Dew-Jones)
Re: hard time with regexp to validate image <jurgenex@hotmail.com>
Re: hard time with regexp to validate image <krahnj@acm.org>
Re: hard time with regexp to validate image <woloski@sion.com>
Re: hard time with regexp to validate image <noreply@gunnar.cc>
Re: hard time with regexp to validate image <noreply@gunnar.cc>
Re: Help: Elements missing when I pass HoH and Array to (entropy123)
Help: Printing Out an Object?/Overloaded Operation Erro (entropy123)
Re: Q about assignments for unmatched regex (Malcolm Dew-Jones)
regular expression matches but $1 left undefined (justin)
Re: removing last part of a line <stevenm@bogus.blackwater-pacific.com>
Re: removing last part of a line <REMOVEsdnCAPS@comcast.net>
Re: setpgrp, setgid - not working, what am I missing? <s_grazzini@hotmail.com>
Re: sort request <usenet@dwall.fastmail.fm>
Re: sort request <creafin1998@yahoo.com>
Tempopary files on Win32 <beromko@yahoo.com>
Re: uninitialized value in eval block? <tassilo.parseval@rwth-aachen.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 29 May 2003 09:38:04 GMT
From: rcappola@webzone.it (Romolo Cappola)
Subject: [PE] - Cerco Perl e PerlCgi con manuale in italiano in ambiente windows 98 o 2000 da scaricare
Message-Id: <3ed5d390.12922218@news.webzone.it>
Ho installato una specie di Web Server con Apache 2.0.43 su windows 98
che mi funziona.
Ho installato un Php e un Mysql
Mi manca Perl Cgi e le istruzioni per settare bene Php, MySql e Perl
Lo scopo è di realizzare un piccolo negozio elettronico e provarlo.
Conosco abbastanza bene il linguaggio Sql Oracle Lite.
Mi farebbe comodo una dritta.
Ringraziamenti e cordiali saluti.
Romolo Cappola
------------------------------
Date: Wed, 28 May 2003 20:02:17 -0700
From: "Bertt" <dragaoon@sappers.no>
Subject: Re: Bioperl?
Message-Id: <bb3tes$qeq$1@news.astound.net>
Uri Guttman wrote:
>>>>>> "B" == Bertt <dragaoon@sappers.no> writes:
>
> >> Abigail,
> >>
> >> Yes and no. I've not tried the Bioperl route so far. The Graph
> module >> on CPAN may/may not be sufficient for my needs - right
> now I think its >> not....so I decided to see if there is a
> 'BioPerl' module which I can >> implement.
>
>> Don't worry too much about abby, she/he/it used to be a real
>> helpful person around here before sliding down the abyssful
>> trollistic ceaspit ;p
>
> that last phrase is more like moronzilla style. calling abigail a
> troll
> is a good ans ure way to get most regulars to killfile you. now who is
> the troll?
>
>> Really though, I've never seen your previous question answered, and
>> it has been a while so there absolutely no harm in asking again in
>> a different way.
>
>> Don't let adigail push you way either ;p
>
> and your very helpful answer is? not much perl content here. and
> abigail
> did discuss graph stuff and modules with the OP. i don't see much
> pushing away. you have much to learn and i doubt you will learn it
No Abigail did not. She/he/it only offered one line that too had nothing to
do with Perl. Please do not try to insert something that is blatently not
there.
--
Bertt
------------------------------
Date: Thu, 29 May 2003 12:13:38 +0400
From: Marck_us_invalid@hotmail.com
Subject: copying files to another directory
Message-Id: <k0gbdvg3rkfut4q8h80kkt8i0k7vijfjhn@4ax.com>
I need to copy all files from a directory to another one.
I tried this: (copy from defaultfolder to folder)
my @files = `ls $defaultfolder/*.*`;
my $filename;
foreach $filename(@files)
{
`cp $filname $folder/`;
}
That fails with a strange "cp: missing destination file" !
But if I do the job "by hand", it works fine.
What's up ?
------------------------------
Date: Thu, 29 May 2003 05:03:50 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: copying files to another directory
Message-Id: <Xns938A3DAAE4901sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Marck_us_invalid@hotmail.com wrote in
news:k0gbdvg3rkfut4q8h80kkt8i0k7vijfjhn@4ax.com:
>
> I need to copy all files from a directory to another one.
>
> I tried this: (copy from defaultfolder to folder)
>
> my @files = `ls $defaultfolder/*.*`;
> my $filename;
>
> foreach $filename(@files)
> {
> `cp $filname $folder/`;
> }
>
> That fails with a strange "cp: missing destination file" !
>
> But if I do the job "by hand", it works fine.
>
> What's up ?
Change "cp" to "echo cp" to see what command you're trying to
execute.
I suggest you add
use strict;
use warnings;
to the top of your program.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE+1dr6Y96i4h5M0egRAhIuAKDr+ll6My2dFnLpiMfXsozbmIXaGwCcDsAD
dihgsHBgT48nD0s8G5s0dRs=
=dOX5
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 28 May 2003 20:05:13 -0500
From: "Randy Kobes" <randy@theoryx5.uwinnipeg.ca>
Subject: Re: DMake (newbie)
Message-Id: <d1dBa.22943$NC4.106645@news1.mts.net>
"Daniel L Newhouse" <daniel_newhouse@earthlink.net> wrote in message
news:r9cBa.21705$Io.1902516@newsread2.prod.itd.earthlink.net...
>
> "Brian McCauley" <nobull@mail.com> wrote in message
> news:u9of1n7zuc.fsf@wcl-l.bham.ac.uk...
> > My advice is don't.
> >
> > If you consider yourself a newbie you shouldn't be trying to build
> > Perl on Windows.
>
> I'm a newbie to Perl but not to programming, C, or Windows generally.
Is there a particular reason you want to use dmake? VC++ comes
with nmake, and building Perl then just involves editing a few
configuration settings in win32/Makefile in the Perl sources. You
might also want to use the Perl sources ActivePerl provides at
http://aspn.activestate.com/ASPN/Downloads/ActivePerl/Source,
which contains in particular some recent Win32 fixes not yet
worked into the Perl CPAN sources.
best regards,
randy kobes
------------------------------
Date: Thu, 29 May 2003 02:27:20 GMT
From: "Daniel L Newhouse" <daniel_newhouse@earthlink.net>
Subject: Re: DMake (newbie)
Message-Id: <ceeBa.20198$rO.1872729@newsread1.prod.itd.earthlink.net>
"Randy Kobes" <randy@theoryx5.uwinnipeg.ca> wrote in message
news:d1dBa.22943$NC4.106645@news1.mts.net...
>
> Is there a particular reason you want to use dmake? VC++ comes
> with nmake, and building Perl then just involves editing a few
> configuration settings in win32/Makefile in the Perl sources. You
> might also want to use the Perl sources ActivePerl provides at
> http://aspn.activestate.com/ASPN/Downloads/ActivePerl/Source,
> which contains in particular some recent Win32 fixes not yet
> worked into the Perl CPAN sources.
>
I went to ActiveState's web site earlier and didn't realize you can
download an msi package for ActivePerl!
Nevertheless, I am inferring from the documentation that if I build
with Visual C++ Perl will plug into the GUI. There was even a
dll-PerlCRT.dll that I think accompishes this.
Nmake is not compatible with command.com. I mentioned that
I was using Windows98SE precisely so people wouldn't waste
time suggesting that I use Nmake.
------------------------------
Date: Wed, 28 May 2003 22:13:00 -0500
From: "Randy Kobes" <randy@theoryx5.uwinnipeg.ca>
Subject: Re: DMake (newbie)
Message-Id: <%UeBa.22991$NC4.107303@news1.mts.net>
"Daniel L Newhouse" <daniel_newhouse@earthlink.net> wrote in message
news:ceeBa.20198$rO.1872729@newsread1.prod.itd.earthlink.net...
>
> "Randy Kobes" <randy@theoryx5.uwinnipeg.ca> wrote in message
> news:d1dBa.22943$NC4.106645@news1.mts.net...
> >
> > Is there a particular reason you want to use dmake? VC++ comes
> > with nmake, and building Perl then just involves editing a few
> > configuration settings in win32/Makefile in the Perl sources. You
> > might also want to use the Perl sources ActivePerl provides at
> > http://aspn.activestate.com/ASPN/Downloads/ActivePerl/Source,
> > which contains in particular some recent Win32 fixes not yet
> > worked into the Perl CPAN sources.
> >
> I went to ActiveState's web site earlier and didn't realize you can
> download an msi package for ActivePerl!
>
> Nevertheless, I am inferring from the documentation that if I build
> with Visual C++ Perl will plug into the GUI. There was even a
> dll-PerlCRT.dll that I think accompishes this.
>
> Nmake is not compatible with command.com. I mentioned that
> I was using Windows98SE precisely so people wouldn't waste
> time suggesting that I use Nmake.
Is it nmake that has problems with command.com, or certain
things that Perl assumes are possible (like STDERR redirection
via a 2>&1 syntax) that give problems? If it's the latter, then I think
it's easier to fix a few things in Perl (generally in ExtUtils::MakeMaker
and friends) that do these things, rather than trying to get dmake
to work with VC++.
best regards,
randy kobes
------------------------------
Date: Thu, 29 May 2003 04:34:20 +0200
From: "Dieter D'Hoker" <webmaster@neverseenbefore.com>
Subject: Re: does this make sence ? (about undef error on select)
Message-Id: <bb3rl1$5f6qm$1@ID-155251.news.dfncis.de>
"Rocco Caputo" <troc@netrus.net> wrote in message
news:slrnbd5n5i.1hhb.troc@eyrie.homenet...
> [Followups directed to comp.lang.perl.misc.]
>
> On Mon, 26 May 2003 07:10:55 +0200, Dieter D'Hoker wrote:
> > I'm running a perl game server ,
> > but I keep getting this shutdown error every few days :
> >
> > Can't use an undefined value as a symbol reference at
> > /usr/libdata/perl/5.00503/mach/IO/Select.pm line 57.
> > ( $@ and $! are empty in my Sig DIE_ )
> >
> > I guess this is because in "my @ready =
> > IO::Select->select($Misc{readable}, $Misc{writable}, undef,
SELECTINTERVAL);
> > "
> > selects gets an undef (that's in $Misc{readable}or $Misc{writable}) .
> > I tried checking everything else when i adding a file handle checking if
> > it's undef :
> >
> > if (defined $new and ($new ne undef) ) {
> > $Misc{readable}->add($new);"
> > }
> >
> > etc. etc.
>
> [...]
>
> > so I thought , is there a way to check if there is a way to check all
> > handles if they are undef or not before using the select call ,
> > so I came up with this , but I don't know if it makes any sence or will
just
> > slow down my server (ping is very important on a gameserver ) :
> >
> > my @readhandles = $Misc{readable}->handles;
> > my @writehandles = $Misc{writable}->handles;
>
> [...]
>
> foreach ($Misc{readable}->handles) {
> next if defined;
> warn "readable has an undef handle";
> $Misc{readable}->remove($_);
> }
>
> foreach ($Misc{writable}->handles) {
> next if defined;
> warn "writable has an undef handle";
> $Misc{writable}->remove($_);
> }
though I did this , the servers STILL shuts down with "Can't use an
undefined value as a symbol reference at
/usr/libdata/perl/5.00503/mach/IO/Select.pm line 57" error ...
Now I don't understand it anymore ...
anyone ANY ideas ?
--
Dieter D'Hoker
http://dieter.dhoker.com/
news:free.nl.dieter.dhoker & news:alt.nl.fan.dieter.dhoker
Tetrinet SeRVer : TSRV.COM
------------------------------
Date: 29 May 2003 00:01:44 -0700
From: njs.google@spameater.squawk.com (Nick Simicich)
Subject: eval { }; does not shield -p on unopened filehandle Sys::Syslog::_PATH_LOG error under 5.8.0
Message-Id: <3c9fda93.0305282301.5c11ffea@posting.google.com>
I maintain a package called demime, which is designed to remove mime
from e-mail. It is mostly for mailing lists, but it also works for
personal e-mail. It removes attachments, and renders html to plain
text if there is no plain text alternative already.
I do not have Perl 5.8.0 installed, but someone who did tried to run
demime and had an error reported against the following code fragment:
if ($] > 5.00402) {
if(defined Sys::Syslog::_PATH_LOG and -p
Sys::Syslog::_PATH_LOG) {
Sys::Syslog::setlogsock('unix') if defined
Sys::Syslog::setlogsock;
}
}
Executing this in context produced the following error:
-p on unopened filehandle _PATH_LOG at /home/majordom/demime line 178.
Duh! -p is supposed to tell me if this is a filehandle (or if not a
filehandle, if the text value represents a file) that is a named pipe.
If it is not a named pipe, like if it is not open, the answer should
simply be no. And _PATH_LOG, at least in syslog.h, is not a
filehandle, it is a constant that returns the position of the unix
filesystem socket that is used to talk to the syslogd. In my copies
of Linux, this is #define _PATH_LOG "/dev/log"
Because of that I would not expect this naked variable to be
considered an unopened filehandle, I would consider it to be a
subroutine call that should return a constant value. Or not.
Well, this is mostly an efficiency thing - if the underlying code has
the ability to use the Unix socket, I believe the Unix socket will be
faster, and if it does have the ability to use the Unix socket, then
UDP to localhost will have to do. But it (SHOULD*) not cause a
malfunction if this code does not execute, so it seemed that if it was
producing an error, it was reasonable to shield it in an eval {} and
to allow it to normally silently fail.
So, I suggested that the user install the following change to the
above code fragment:
eval {
if ($] > 5.00402) {
if(defined Sys::Syslog::_PATH_LOG and -p
Sys::Syslog::_PATH_LOG) {
Sys::Syslog::setlogsock('unix') if defined
Sys::Syslog::setlogsock;
}
}
};
if ($@ and $::debug) {
warn "Ignored the following error: $@";
}
The EXACT SAME ERROR MESSAGE was produced. Not "Ignored the following
error: -p on unopened filehandle _PATH_LOG at /home/majordom/demime
line 178."
And the function failed hard, the eval did not shield it. The user was
still stuck.
Given that the advisability of "making the use of -p against a closed
filehandle a catastrophic failure or even a voiced error" is a matter
of opinion (I think this is a bad change), the user reports that the
test broke through the eval shield. I can't test it, again, but this,
in my opinion, is a SERIOUS BUG, if true. Anyone trying to be safe
does things like hiding untrusted code inside of eval. If someone can
crack out of eval, no telling what they can do.
I then added the following to the patch:
if ($] > 5.00402 and $] < 5.008 ) {
So that this code would simply not be executed at all under 5.8.0 or
higher, and the problem was bypassed. I had a hidden agenda: I was
beginning to doubt that the user was actually editing the executable
(even though the reported line numbers were changing along with the
edits).
This worked, the user was able to operate, indicating that the user
was actually editing the real code. This also confirms to me that the
user has a real bug here. This simple -p test is breaking right out
of the eval, and I simply do not see why it should be able to.
If anyone is actually interested in trying to reproduce the problem,
the original code is available at
http://majordomo.squawk.com/njs/demime/. The complete discussion of
the problem is available in the archives of the demime-l mailing list.
http://scifi.squawk.com/demime.html talks about the mailing list,
subscribe at demime-l-subscribe -> scifi.squawk.com. Archives
available to subscribers using typical majordomo2 methodology.
-=-=-=-
*during the period I have maintained this code, I recall discovering a
release where the logging function would only work if I redirected
logging to the Unix socket. This was some time in the past.
------------------------------
Date: 29 May 2003 09:19:56 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: eval { }; does not shield -p on unopened filehandle Sys::Syslog::_PATH_LOG error under 5.8.0
Message-Id: <bb4jbs$cq6$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Nick Simicich:
> I maintain a package called demime, which is designed to remove mime
> from e-mail. It is mostly for mailing lists, but it also works for
> personal e-mail. It removes attachments, and renders html to plain
> text if there is no plain text alternative already.
>
> I do not have Perl 5.8.0 installed, but someone who did tried to run
> demime and had an error reported against the following code fragment:
>
> if ($] > 5.00402) {
> if(defined Sys::Syslog::_PATH_LOG and -p
> Sys::Syslog::_PATH_LOG) {
> Sys::Syslog::setlogsock('unix') if defined
> Sys::Syslog::setlogsock;
> }
> }
>
> Executing this in context produced the following error:
>
> -p on unopened filehandle _PATH_LOG at /home/majordom/demime line 178.
>
> Duh! -p is supposed to tell me if this is a filehandle (or if not a
> filehandle, if the text value represents a file) that is a named pipe.
> If it is not a named pipe, like if it is not open, the answer should
> simply be no. And _PATH_LOG, at least in syslog.h, is not a
> filehandle, it is a constant that returns the position of the unix
> filesystem socket that is used to talk to the syslogd. In my copies
> of Linux, this is #define _PATH_LOG "/dev/log"
>
> Because of that I would not expect this naked variable to be
> considered an unopened filehandle, I would consider it to be a
> subroutine call that should return a constant value. Or not.
>
> Well, this is mostly an efficiency thing - if the underlying code has
> the ability to use the Unix socket, I believe the Unix socket will be
> faster, and if it does have the ability to use the Unix socket, then
> UDP to localhost will have to do. But it (SHOULD*) not cause a
> malfunction if this code does not execute, so it seemed that if it was
> producing an error, it was reasonable to shield it in an eval {} and
> to allow it to normally silently fail.
You can't shield it with an eval{}, because the above is not an
error-message but a mere warnings. eval() doesn't trap those.
You can turn this particular warning off, though. For a recent Perl (>=
5.6.0), put the offending code into a block of itself and add
no warnings 'unopened';
for this block of code.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Thu, 29 May 2003 01:26:52 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Expanding a newcommand in latex
Message-Id: <slrnbdaoes.1lr.mgjv@verbruggen.comdyn.com.au>
On 24 May 2003 07:15:40 +0200,
Niels L. Ellegaard <gnalle@ruc.dk> wrote:
>
> When I write latex I make frequent use of newcommands such as
> \newcommand{\pt}[3]{\left(\frac{\partial#2}{\partial#1}\right)_{#3}}
>
> Sadly I have problems if I wish to share my tex-file with other
> people. Therefore I am looking for a perlscript that can produce a new
> latex-file where the newcommand has been expanded.
\begin[wildly]{offtopic}
This comes up regularly on comp.text.tex, which is a much better place
to ask this question. While there are valid reasons for wanting to do
this, it might not be necessary for you to do it. When posting to
comp.text,tex, make sure you explain _what_ the problems are that you
refer to, so they can give you the appropriate answer.
If you then still need to expand \newcommand tags, Peter Schmitt will
most likely offer to send you his macros.
\end{offtopic}
> I am not a great master of perl and I guess that I should sit down and
> learn instead of asking stupid questions usenet groups, but still I
> would be very grateful if someone could point me to an example of perl
> code that expands a latex newcommand that takes arguments.
Perl is not necessarily the best tool for this. LaTeX, in general,
isn't trivial to parse, and unless your input files are simple, and
regular, you're going to be in for a wild ride. The only stuff I've
ever written to parse LaTeX will only work reliably with _my_ input
files. I'd try very hard to find another way before writing something
myself, if I were in your situation.
If you can guarantee that your \newcommands and their subsequent
invocations all follow a certain rigid format, it could be not too
hard to write some regular expressions. If you can't guarantee a rigid
format, it becomes harder. It depends mainly on your input files and
the way they're written on how hard it's going to be to write
something.
Martien
--
|
Martien Verbruggen | Make it idiot proof and someone will make a
Trading Post Australia | better idiot.
|
------------------------------
Date: Thu, 29 May 2003 01:57:18 -0300
From: "Matias Woloski" <woloski@sion.com>
Subject: hard time with regexp to validate image
Message-Id: <bb43ur$5hga8$1@ID-148083.news.dfncis.de>
I'm trying to write a regular expression to validate valid images. This
means that will have to match
Match
1) myfile1.gif
2) myfile
3) myfile.mine.jpg
4) my file.jpeg
etc..
Non-match
1) file.exe
2) file.vbs
3) file.notknownextension
etc
Those are the basic cases
So far I did this one
^[^\.]+(?:\.(?:gif|jpe?g))?$
This will validate every case but leaves out the case 3) where there are two
points in the input.
Now that's the problem... How would you change or create a new regexp to
deal with that?
thanks,
Matias
------------------------------
Date: 28 May 2003 22:07:53 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: hard time with regexp to validate image
Message-Id: <3ed595a9@news.victoria.tc.ca>
Matias Woloski (woloski@sion.com) wrote:
: I'm trying to write a regular expression to validate valid images. This
: means that will have to match
: Match
: 1) myfile1.gif
: 2) myfile
: 3) myfile.mine.jpg
: 4) my file.jpeg
: etc..
: Non-match
: 1) file.exe
: 2) file.vbs
: 3) file.notknownextension
: etc
: Those are the basic cases
: So far I did this one
: ^[^\.]+(?:\.(?:gif|jpe?g))?$
: This will validate every case but leaves out the case 3) where there are two
: points in the input.
: Now that's the problem... How would you change or create a new regexp to
: deal with that?
(untested)
$is_gif_or_jpeg_extension = $filename =~ m/\.gif$|\.jpg$|\.jpeg$/;
which should say "YES, a match" if the filename ends with any one of .gif
.jpg or .jpeg
------------------------------
Date: Thu, 29 May 2003 05:09:16 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: hard time with regexp to validate image
Message-Id: <0CgBa.23446$8i4.2648@nwrddc02.gnilink.net>
Matias Woloski wrote:
> I'm trying to write a regular expression to validate valid images.
> This means that will have to match
>
> Match
> 1) myfile1.gif
> 2) myfile
> 3) myfile.mine.jpg
> 4) my file.jpeg
> etc..
>
> Non-match
> 1) file.exe
> 2) file.vbs
> 3) file.notknownextension
> etc
>
> Those are the basic cases
> So far I did this one
>
> ^[^\.]+(?:\.(?:gif|jpe?g))?$
>
> This will validate every case but leaves out the case 3) where there
> are two points in the input.
>
> Now that's the problem... How would you change or create a new regexp
> to deal with that?
Unless you insist on doing it the hard way you wouldn't.
First of all you should use File::Basename to split the full name into path,
name, and extension.
And then you would simply use exist() to check if the extension exists in a
hash that contains all known/wanted extensions.
jue
------------------------------
Date: Thu, 29 May 2003 05:32:26 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: hard time with regexp to validate image
Message-Id: <3ED59B5E.FBD2CF01@acm.org>
Matias Woloski wrote:
>
> I'm trying to write a regular expression to validate valid images. This
> means that will have to match
You could use the File::MMagic module.
http://search.cpan.org/author/KNOK/File-MMagic-1.19/
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 29 May 2003 02:34:55 -0300
From: "Matias Woloski" <woloski@sion.com>
Subject: Re: hard time with regexp to validate image
Message-Id: <bb465c$5kh99$1@ID-148083.news.dfncis.de>
> $is_gif_or_jpeg_extension = $filename =~ m/\.gif$|\.jpg$|\.jpeg$/;
>
Thanks,
but this won't validate extensionless files, will?
Matias
------------------------------
Date: Thu, 29 May 2003 09:33:23 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: hard time with regexp to validate image
Message-Id: <bb4dt7$5lr1m$1@ID-184292.news.dfncis.de>
Matias Woloski wrote:
> I'm trying to write a regular expression to validate valid images.
> This means that will have to match
>
> Match
> 1) myfile1.gif
> 2) myfile
> 3) myfile.mine.jpg
> 4) my file.jpeg
> etc..
>
> Non-match
> 1) file.exe
> 2) file.vbs
> 3) file.notknownextension
> etc
>
> Those are the basic cases
> So far I did this one
>
> ^[^\.]+(?:\.(?:gif|jpe?g))?$
>
> This will validate every case but leaves out the case 3) where
> there are two points in the input.
>
> Now that's the problem... How would you change or create a new
> regexp to deal with that?
How about:
/(?:\.(?:gif|jpe?g)$)/ or !/\./
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 29 May 2003 09:41:43 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: hard time with regexp to validate image
Message-Id: <bb4ecr$5lr1m$2@ID-184292.news.dfncis.de>
Gunnar Hjalmarsson wrote:
> /(?:\.(?:gif|jpe?g)$)/ or !/\./
Should better be just:
/\.(?:gif|jpe?g)$/ or !/\./
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 28 May 2003 18:46:00 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Re: Help: Elements missing when I pass HoH and Array to subroutine at same time...
Message-Id: <90cdce37.0305281746.2823a28a@posting.google.com>
Gunnar,
Thanks man, that did the trick.
entropy
------------------------------
Date: 28 May 2003 21:47:09 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Help: Printing Out an Object?/Overloaded Operation Error with Graph Module?
Message-Id: <90cdce37.0305282047.5c451888@posting.google.com>
Hey all,
I'm trying to get the Graph::DFS module up and running and one of the
things I think I need is the DFS routine -> apparently its output is
an 'object' :) and I don't know how to print out object
attributes...that might be my problem...any advice?
Operation `""': no method found, argument in overloaded package
Graph::DFS at
./addgraph.pl line 196, <INPUT> line 69 (#5)
(F) An attempt was made to perform an overloaded operation for
which no
handler was defined. While some handlers can be autogenerated in
terms
of other handlers, there is no default handler for any operation,
unless
fallback overloading key is specified to be true. See overload.
Uncaught exception from user code:
Operation `""': no method found, argument in overloaded
package Graph::DFS at ./addgraph.pl line 196, <INPUT> line 69.
The code (as pertains to DFS and Graph)
my %G;
$G = Graph ->new(@ainr);
print "Graph->new(@ainr);
$b = $G->undirected($d);
print "undirected($d): $b\n";
$E = $G->add_edges(@E);
print "add_edges(@E): $G\n";
$S = $G->has_edges(@E);
print "has_edges: $S\n";
@EC = $G->edge_classify();
for $iter ( 0 .. $#EC ) {
print "\t [ @{$EC[$iter]} ],\n";
}
print $G->strongly_connected_graph, "\n";
my %param;
my $dfs;
$dfs = Graph::DFS->new($G, %param);
print "dfs: $dfs\n";
The error occurs when I actually try to print out $dfs...
Help much appreciated!
Thanks,
entropy
------------------------------
Date: 28 May 2003 21:49:28 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Q about assignments for unmatched regex
Message-Id: <3ed59158@news.victoria.tc.ca>
Jason Parker-Burlingham (jasonp@uq.net.au) wrote:
: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) writes:
: > Michael Powe (michael+gnus@trollope.org) wrote:
: > : hello,
: >
: > : i am looping through a file matching lines to a regex. however, some
: > : lines don't return a match. so, i have something like this:
: > : ...snip...
: >
: > while (<FH>)
: > {
: > if ( my ($one,$two,$three,$four,$five,$six) = /$re/ )
: > { # the re matched, and $one etc are in scope and can be used
: > }
: > else
: > { # the re did not match, and you can't even accidently
: > # use the variables due to their scope.
: > }
: > }
: The variables aren't out of scope in the else block, although they are
Gee, you're right.
------------------------------
Date: 29 May 2003 03:00:59 -0700
From: justinrobertson@btinternet.com (justin)
Subject: regular expression matches but $1 left undefined
Message-Id: <48f83c27.0305290200.5111231e@posting.google.com>
Is it ever possible for a regular expression containing brackets to
match a string and still leave $1 undefined? Because that's what's
happening to me.
This is the regular expression:
GET\s(?:/docs/([A-Fa-f0-9]{32})|/servlet/s\?Name=ShowDoc&(?:id=([A-Fa-f0-9]{32})|pid=([A-Fa-f0-9]{4}-[A-Fa-f0-9]{2}-[A-Fa-f0-9]{2}-[A-Fa-f0-9]{2}-[A-Fa-f0-9]{2})))
And the string is:
GET /servlet/s?Name=ShowDoc&pid=4559-01-01-00-00&login=1&ref=undefined&ctx=slst&ht=null&seq=1050469368984
HTTP/1.0
After this match, I thought that $1 should be set to
"4559-01-01-00-00" but it is in fact always undefined.
This tiny bit of code shows the problem.
$re = 'GET\s(?:/docs/([A-Fa-f0-9]{32})|/servlet/s\?Name=ShowDoc&(?:id=([A-Fa-f0-9]{32})|pid=([A-Fa-f0-9]{4}-[A-Fa-f0-9]{2}-[A-Fa-f0-9]{2}-[A-Fa-f0-9]{2}-[A-Fa-f0-9]{2})))';
$line = 'GET /servlet/s?Name=ShowDoc&pid=4559-01-01-00-00&login=1&ref=undefined&ctx=slst&ht=null&seq=1050469368984
HTTP/1.0';
if ($line =~ /$re/) {;
print $1;
}
Interestingly though, if you change the last lines to:
print ($line =~ /$re/);
You get "4559-01-01-00-00".
Can anyone help? I've tried $2, $3, etc but no joy. Thanks in advance.
------------------------------
Date: Thu, 29 May 2003 00:31:37 -0700
From: Steve May <stevenm@bogus.blackwater-pacific.com>
Subject: Re: removing last part of a line
Message-Id: <bb4cju$8l0$1@quark.scn.rain.com>
Eric J. Roode wrote:
> "John W. Krahn" <krahnj@acm.org> wrote in news:3ECE5A43.F8D1AC6E@acm.org:
>
>
>>Everything after the first '/'.
>>
>>perl -pi.bak -e's!(?<=/).*!!' temp1.txt
>
>
> Why so complex? Imho, negative lookbehind assertions are for unusual
> cases. Why not simply
>
> s!/.*!/!;
>
>
>
>>Everything after the last '/'.
>>
>>perl -lpi.bak -e's!(?<=/)[^/]*$!!' temp1.txt
>
>
> Why not simply s!/[^/]*$!/! ?
>
Though the above is fine I find myself shy about using * in regexes,
having been punished by the Cargo Gods numerous times. :-)
Another simple solution might be:
s![^/]+$!!
s.
------------------------------
Date: Thu, 29 May 2003 04:56:18 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: removing last part of a line
Message-Id: <Xns938A3C644CD33sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Steve May <stevenm@bogus.blackwater-pacific.com> wrote in
news:bb4cju$8l0$1@quark.scn.rain.com:
> Eric J. Roode wrote:
>> Why not simply s!/[^/]*$!/! ?
>>
>
> Though the above is fine I find myself shy about using * in regexes,
> having been punished by the Cargo Gods numerous times. :-)
>
> Another simple solution might be:
>
> s![^/]+$!!
Oh yeah. That would be simpler yet.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE+1dkuY96i4h5M0egRAtZNAJoC0ojQFU97ktyGjQllwIPZ/iGJ+wCfdNpv
b/afzhJRHSNwLaGWsm/ZT60=
=C/Yt
-----END PGP SIGNATURE-----
------------------------------
Date: Thu, 29 May 2003 04:16:48 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: setpgrp, setgid - not working, what am I missing?
Message-Id: <QQfBa.77264$h42.32436@twister.nyc.rr.com>
Matthew O. Persico <persicom@acedsl.com> writes:
> Well, I must be doing something really wrong. I tried three methods:
> 1) setpgrp()
This sets the "process group" which has nothing at all to do with
user groups.
> 2) assigining to $) and $( directly
> 3) POSIX::setgid.
You need to be root for either of these -- or you need a suid-root
program to change the group id for you. sg(1) would do the trick,
if you had it.
You could also change the owning group of each file:
$ perldoc -f chown
Or create all the files in a sticky-bit directory owned by the
right group.
--
Steve
------------------------------
Date: Thu, 29 May 2003 01:49:45 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: sort request
Message-Id: <Xns9389DE0D8222Adkwwashere@216.168.3.30>
Michael Budash <mbudash@sonic.net> wrote:
> In article <vdahc0nbv1g9bf@corp.supernews.com>,
> "John Smith" <creafin1998@yahoo.com> wrote:
>
>> Could someone please help me write an efficient perl sort routine
>> for dates? I need to sort dates in the following format: 28-May-03
>> It must chronologically sort ascending or descending. Thanks in
>> advance to anyone who is up to the challenge.
>
> i smell schoolwork... but...
[snip code]
Seems easier to me to use Date::Parse and a Schwarztian transform, and
cache the results of the date parsing in case there are duplicated
dates.
use strict;
use warnings;
use Date::Parse;
my @dates = qw/28-May-03 21-Feb-01 21-May-03 15-Sep-04/;
my @sorted = map $_->[0] =>
sort { $a->[1] <=> $b->[1] }
map [$_, parse_date($_)] => @dates;
print "@sorted"; # deliberate double-quotes :-)
{
my %date;
sub parse_date {
my $date_str = shift;
return $date{$date_str} if defined $date{$date_str};
$date{$date_str} = str2time($date_str);
}
}
Oh well. TMTOWTDI.
I do hope this isn't homework.
--
David Wall
------------------------------
Date: Wed, 28 May 2003 21:05:15 -0500
From: "John Smith" <creafin1998@yahoo.com>
Subject: Re: sort request
Message-Id: <vdaqeknc28f35a@corp.supernews.com>
Thanks guys. I rarely use the newsgroups. You guys are great. I noticed
some others that post slams against others and seem to pre-judge and stick
some ads or links to useless sites at the end of their messages. Too bad,
what a waist of energy. I certainly won't let them get to me and enjoy the
otherwise general acedemic spirit of this group. Thanks again for teaching
me something new about Perl.
"David K. Wall" <usenet@dwall.fastmail.fm> wrote in message
news:Xns9389DE0D8222Adkwwashere@216.168.3.30...
> Michael Budash <mbudash@sonic.net> wrote:
>
> > In article <vdahc0nbv1g9bf@corp.supernews.com>,
> > "John Smith" <creafin1998@yahoo.com> wrote:
> >
> >> Could someone please help me write an efficient perl sort routine
> >> for dates? I need to sort dates in the following format: 28-May-03
> >> It must chronologically sort ascending or descending. Thanks in
> >> advance to anyone who is up to the challenge.
> >
> > i smell schoolwork... but...
>
> [snip code]
>
> Seems easier to me to use Date::Parse and a Schwarztian transform, and
> cache the results of the date parsing in case there are duplicated
> dates.
>
> use strict;
> use warnings;
> use Date::Parse;
>
> my @dates = qw/28-May-03 21-Feb-01 21-May-03 15-Sep-04/;
> my @sorted = map $_->[0] =>
> sort { $a->[1] <=> $b->[1] }
> map [$_, parse_date($_)] => @dates;
> print "@sorted"; # deliberate double-quotes :-)
>
> {
> my %date;
> sub parse_date {
> my $date_str = shift;
> return $date{$date_str} if defined $date{$date_str};
> $date{$date_str} = str2time($date_str);
> }
> }
>
> Oh well. TMTOWTDI.
>
> I do hope this isn't homework.
>
> --
> David Wall
------------------------------
Date: Thu, 29 May 2003 11:36:30 +0300
From: "Roman Khutkyy" <beromko@yahoo.com>
Subject: Tempopary files on Win32
Message-Id: <bb4gpg$1lte$1@news.uar.net>
1. During uploading files from user mashine (thruough browser form) to
server Perl creates temporary files in C:\Temp directory (CGItemp****) and
does not delete them after aploading finished. How to make Perl clean after
itself.
2. I'm trying to read those files like this:
$filename=$query->param('filename');
open (INFILE,"<$filename");
binmode(INFILE);
But this method works only if load files from IE browser (from this browser
returned parameter of filefield includes full file name including path). Any
other browser (Opera, Mozilla) returns only filename without path, and
result of reading in this case is empty file. Is there any method to read
from TEMP file or to make Perl to read downloaded files as STDIN (it must be
so but it doesn't)
------------------------------
Date: 29 May 2003 06:41:35 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: uninitialized value in eval block?
Message-Id: <bb4a2v$64f$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Tad McClellan:
> SeeMySig <spam.me.senseless@sitting.duck> wrote:
>> The question is, where do I look for the source of the violation in eval
>> 18 line 32?
>
>
> step 1) determine what the 18th eval() is that your program is evaluating.
>
> step 2) count in that eval to the 32nd line.
>
> step 3) look for undef values near there
For larger pieces that are executed within an eval(), it's sometimes not
a bad idea to add #line comments:
eval <<EOEVAL;
...
#line 100 (oops)
die;
EOEVAL
Results in the much more meaningful
Died at (oops) line 100.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5055
***************************************