[27094] in Perl-Users-Digest
Perl-Users Digest, Issue: 8979 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 21 18:05:56 2006
Date: Tue, 21 Feb 2006 15:05:04 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 21 Feb 2006 Volume: 10 Number: 8979
Today's topics:
binmode must be in the middle of the file <jidanni@jidanni.org>
Re: Help me get "Directory" out of full windows path na <jgibson@mail.arc.nasa.gov>
Re: Implementing a "pull" (?) interface in perl <nomail@sorry.com>
Re: Reading Mac / Unix / DOS text files <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 22 Feb 2006 04:31:15 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: binmode must be in the middle of the file
Message-Id: <874q2s4fos.fsf@jidanni.org>
Below, I found if I place binmode() earlier, the first UTF-8 <<EOF
becomes gibberish on output. Removing it causes wide character
warnings at $p->header. I suppose it will just have to stay in between
the two. Must be my junior programmer status to blame.
require HTML::HeadParser; print <<EOF;
[some raw utf-8 characters here]
EOF
binmode(STDOUT,":utf8"); open(my $fh,"<:utf8",$_);
$p=HTML::HeadParser->new; $p->parse_file($fh); print $p->header('Title');
------------------------------
Date: Tue, 21 Feb 2006 11:35:57 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Help me get "Directory" out of full windows path name?
Message-Id: <210220061135571602%jgibson@mail.arc.nasa.gov>
In article <1SHKf.1285$XZ3.142971@news20.bellglobal.com>, Random Task
<Random@Task.be> wrote:
> Hi i am trying to get $tmpdir to contain the "directory" instead of a
> fully pathed file name ... i.e. truncate the file name.
>
> I am trying the below code ... but $1 is always empty ... help please :-)
>
> my $tmpdir = $file;
> if ( $tmpdir =~/([.]*)[\\]{1}/)
That regexp will match any number of periods followed by one backslash.
Periods are not special in character classes. And {1} is entirely
superfluous. Try
$tmpdir =~ /(.*)[\\]/
However, there are modules that will make your job easier, such as
File::Basename.
> {
> print("MATCH\n");
> $tmpdir = $1;
> print ("[--->]".$1."<----]\n");
> }
> else
> {
> print("NO MATCH\n");
> $tmpdir = $tmpdir;
> }
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Tue, 21 Feb 2006 14:38:58 -0800
From: Arvin Portlock <nomail@sorry.com>
Subject: Re: Implementing a "pull" (?) interface in perl
Message-Id: <dtg4q3$nrq$1@agate.berkeley.edu>
John Bokma wrote:
> Arvin Portlock wrote:
>
> >Is there some way to design this, module plus application,
> >so that as a record is read the application can process it
> >immediately? Is this what is know as a pull-based architecture?
> >How does the application "know" when a new record is available?
> >Does it listen for something that the module emits? I'm
> >thinking maybe it can be done with a callback. The callback
> >subroutine is written in the calling application and when
> >the end of the record is parsed, that subroutine is called.
>
> You might want to have a look at XML::Twig, which is good at "record"
> parsing. It can make a tree per record, and you get called when the
> record
> is in.
I'm familiar with XML::Twig, but I didn't know it did that.
Thanks for the tip!
Arvin
------------------------------
Date: Tue, 21 Feb 2006 19:07:36 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Reading Mac / Unix / DOS text files
Message-Id: <Xns97718FB4BB1ECasu1cornelledu@132.236.56.8>
January Weiner <january.weiner@gmail.com> wrote in news:dtfd12$m4k$1
@sagnix.uni-muenster.de:
> I'd like my script to treat text files coming from various systems
alike.
> More specifically, I'd like to recognize ends of line as one of: \r,
\l,
> \r\l. Is there a more elegant way than doing the obvious?:
You should use the codes for those characters rather than the escapes.
> while(<IF>) {
I stared at this for a long time trying to figure out what
while(<IF>) {
meant. I guess IF is short for Input File?
Here, an appropriate amount of whitespace, not using bareword
filehandles, and using an appropriate variable name would have helped
immensely with readability.
while ( <$input> ) {
> s/\r?\l?$// ; # is this correct anyway? will an end of line be
> # recognized with a Mac file?
This information is readily available by doing a cursory Google search.
Are you that lazy?
s{ \012 | (?: \015\012? ) }{\n}x
should convert any line ending convention to the one supported by your
platform.
> I would expect that there is some weird variable out there
> (like the $/)
$/ is not a weird variable. It is documented in perldoc perlvar.
Sinan
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8979
***************************************