[23018] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5238 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 18 14:06:36 2003

Date: Fri, 18 Jul 2003 11:05:10 -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           Fri, 18 Jul 2003     Volume: 10 Number: 5238

Today's topics:
    Re: Behind the scene <uri@stemsystems.com>
    Re: Behind the scene <uri@stemsystems.com>
        Code to put today's date into MM-DD-YY format <his_ron@yahoo.com>
    Re: Code to put today's date into MM-DD-YY format <noreply@gunnar.cc>
    Re: Code to put today's date into MM-DD-YY format <mothra@nowhereatall.com>
    Re: Configure win98 to work with a cgi written in perl <SineSwiper@ResonatorSoft.org>
        converting javascript extracting routine to cgi <requests@zipperpulls.com>
    Re: converting javascript extracting routine to cgi <noreply@gunnar.cc>
    Re: Daily Perl puzzle <uri@stemsystems.com>
    Re: display image during runtime <zentara@highstream.net>
    Re: File::Find is slower than using recursion!? <stevea@wrq.com>
    Re: How to match all characters in a Character Class <emschwar@pobox.com>
    Re: HTML REGEX <bruce@ghbraille.com>
    Re: HTML REGEX <SineSwiper@ResonatorSoft.org>
    Re: HTML REGEX <SineSwiper@ResonatorSoft.org>
    Re: Newbie can't get CgiComments to name files correctl <me@privacy.net>
        priority queue <perseus_medusa@hotmail.com>
    Re: regl expression <pinyaj@rpi.edu>
    Re: Removing characters once a series stops <mbudash@sonic.net>
    Re: Removing characters once a series stops (Sara)
    Re: Removing Perl comments and strings using regexps <SineSwiper@ResonatorSoft.org>
        replacing hex code characters <bruce@ghbraille.com>
    Re: replacing hex code characters <SineSwiper@ResonatorSoft.org>
    Re: tab delimited file processing problem <bart.lateur@pandora.be>
    Re: tab delimited file processing problem <wksmith@optonline.net>
        Variable definition help needed <me@privacy.net>
    Re: Variable definition help needed <spam@thecouch.homeip.net>
    Re: Variable definition help needed <me@privacy.net>
    Re: Variable definition help needed <spam@thecouch.homeip.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 18 Jul 2003 16:41:39 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Behind the scene
Message-Id: <x7wuefeqil.fsf@mail.sysarch.com>

>>>>> "MP" == Matija Papec <mpapec@yahoo.com> writes:

  >> so the way you can help is to donate money to the perl foundation and
  >> help larry pay for his mortgage. :)

  MP> Is there possibility to purchase perl cd or something that would
  MP> also help?

the most direct method is to donate via:

	http://donate.perl-foundation.org/

i don't think they have anything for sale that is fund raising. that may
change in the future but i can't say for sure.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 18 Jul 2003 16:44:43 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Behind the scene
Message-Id: <x7u19jeqdh.fsf@mail.sysarch.com>

>>>>> "JA" == Jim Agnew <- VCU/MCV Neurosurgery <jpagnew@vcu.edu>> writes:

  JA> Uri Guttman wrote:
  >> 
  >> so the way you can help is to donate money to the perl foundation and
  >> help larry pay for his mortgage. :)

  JA> does buying books from O'Reilly help out at all? I was under the
  JA> impression it does...

larry used to work on perl full time while under salary from
o'reilly. that hasn't been the case for about two years as o'reilly laid
him off when the tech bubble burst. he has been partly supported under
grants from the perl foundation since then. so donating to tpf via:

	http://donate.perl-foundation.org/

is the best way to help him out right now.

thanx,

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 18 Jul 2003 16:47:05 GMT
From: "Ron" <his_ron@yahoo.com>
Subject: Code to put today's date into MM-DD-YY format
Message-Id: <dwVRa.85021$hV.5878942@twister.austin.rr.com>

I am new to cgi I would like to place a check box on my form.  When it is
checked & I run my custom Upload cgi script I would like this code to.

1. Get the current date & day of the week.
2. Put it into this format MM-DD-YY Day

I have no ideal where to start.  Suggestions Please?

Thanks,
Ron




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

Date: Fri, 18 Jul 2003 19:19:24 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Code to put today's date into MM-DD-YY format
Message-Id: <bf9ah8$cml3i$1@ID-184292.news.uni-berlin.de>

Ron wrote:
> I am new to cgi I would like to place a check box on my form.  When
> it is checked & I run my custom Upload cgi script I would like this
> code to.
> 
> 1. Get the current date & day of the week.
> 2. Put it into this format MM-DD-YY Day
> 
> I have no ideal where to start.  Suggestions Please?

     http://learn.perl.org/

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Fri, 18 Jul 2003 10:30:49 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Code to put today's date into MM-DD-YY format
Message-Id: <3f182ecd$1@usenet.ugs.com>

Hi Ron,

"Ron" <his_ron@yahoo.com> wrote in message
news:dwVRa.85021$hV.5878942@twister.austin.rr.com...
> I am new to cgi I would like to place a check box on my form.  When it is
> checked & I run my custom Upload cgi script I would like this code to.
>
> 1. Get the current date & day of the week.
> 2. Put it into this format MM-DD-YY Day
>
> I have no ideal where to start.  Suggestions Please?
>
> Thanks,
> Ron

use strict;
use warnings;
use DateTime;

my $dt = DateTime->today;

my $date = $dt->mdy;
my $dname = $dt->day_name;

print $date . $dname ."\n";

Mothra




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

Date: Fri, 18 Jul 2003 16:51:29 GMT
From: Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Subject: Re: Configure win98 to work with a cgi written in perl
Message-Id: <lAVRa.79641$sY2.36158@rwcrnsc51.ops.asp.att.net>

iris wrote:

> Hi
> 
> I have downloaded perl to my computer and would like to work on a cgi
> file.
> However, i can not get the system to return the html file.
> This thing works on unix so i know i have problems in the win98
> configuration.
> Also, when i run it on windows a dos window is opened, but it closes
> so quickly that i can not read the messages there.
> 
> How do i configure win 98 to work with cgi?
> 
> 
> Thanks,
> Iris.

Try running a command window first, then type in:

/path/to/perl /path/to/script

ActiveState Perl works well with Windows.

-- 
Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Perl hacker, computer wizard, and all-around internet guru
Resonator Software <http://www.ResonatorSoft.org/>



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

Date: 18 Jul 2003 11:19:33 -0500
From: "noViagraHere" <requests@zipperpulls.com>
Subject: converting javascript extracting routine to cgi
Message-Id: <3f17e960$0$52655$45beb828@newscene.com>

How would I accomplish this javascript code in CGI?

var lengthenval2 = theitem.indexOf(", Alter length to ",0);

var extractredeem2 = lengthenval2+18;

var extractredeemc = lengthenval2+20;

var lengthenval = theitem.substring(extractredeem2,extractredeemc);


Thanks








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

Date: Fri, 18 Jul 2003 19:22:23 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: converting javascript extracting routine to cgi
Message-Id: <bf9amr$cml3i$2@ID-184292.news.uni-berlin.de>

noViagraHere wrote:
> How would I accomplish this javascript code in CGI?

<snipped JavaScript code>

You wouldn't, since CGI isn't a programming language. I'm sure it can 
be done in Perl, though.

     http://learn.perl.org/

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Fri, 18 Jul 2003 16:49:33 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Daily Perl puzzle
Message-Id: <x7r84neq5f.fsf@mail.sysarch.com>

>>>>> "LT" == Lawrence Tierney <lawrence.tierney@bipcontracts.com> writes:

  LT> Anybody know of a website or similar which will, on a daily basis,
  LT> email you a perl problem or puzzle etc with the answer being
  LT> provided at a later date?

  LT> I ask because our dept. of programmers is looking for some way to
  LT> sort out the wheat from the chaff - a perl top-gun if you will.

this is a weekly puzzle with both beginner and expert problems.

	http://perl.plover.com/qotw/

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 18 Jul 2003 11:33:16 -0400
From: zentara <zentara@highstream.net>
Subject: Re: display image during runtime
Message-Id: <be4ghvo9gi175d01vssnuusinj0ca2t3or@4ax.com>

On 18 Jul 2003 00:53:26 -0700, alythh@netscape.net (Alythh) wrote:

>for the first time I'm trying to add graphics to a Perl program, and
>I'm thinking using the GD module.
>I see how easily you can create images/graphs... but, there is an easy
>way to open a window to display the image - during prog execution -
>and to send sometime a command to it to update the image, when
>necessary?
>
>P.S. probably the question is more general than a GD question, it
>regards how to easily display an image at runtime ...
>
>Thanks for any info

Yeah, here is a tk script which displays a captured image from
/dev/video.  It should give you enough clues how to display and
update an image. The thing to remember with tk, is if you are
displaying a photo from "memory", as opposed to from a disk file,
it must be base64_encoded and loaded with -data instead of -file.

#!/usr/bin/perl
use warnings;
use strict;
use Video::Capture::V4l;
use Imager;
use Tk;
use Tk::JPEG;
use MIME::Base64;

my $timestamp;
my $temp = '';

sub grab_one {
    $temp      = '';
    $timestamp = scalar(localtime);
    $timestamp =~ tr/ /_/;
    $| = 1;

  my $grab = new Video::Capture::V4l
      or die "Unable to open Videodevice: $!";

  # the following initializes the camera for NTSC
   my $channel = $grab->channel (0);
   my $tuner = $grab->tuner (0);
  $tuner->mode(1);
  $channel->norm(1);
  $tuner->set;
  $channel->set;

    my $frame = 0;
    my $fr    = $grab->capture( $frame, 320, 240 );
    my $count = 0;

    for ( 0 .. 1 ) {
        my $nfr = $grab->capture( 1 - $frame, 320, 240 );
        $grab->sync($frame) or die "unable to sync";

        unless ( $count == 0 ) {

            # save $fr now, as it contains the raw BGR data 
            $temp = '';
            open( JP, '>', \$temp ) or die $!;
            print JP "P6\n320 240\n255\n";    #header 
            $nfr = reverse $nfr;
            print JP $nfr;
            close JP;

            my $img = Imager->new();
            $img->read( data => $temp, type => 'pnm' )
              or warn $img->errstr();
            $img->flip( dir => "hv" );
            $img->write( data => \$temp, type => 'jpeg' )
              or warn $img->errstr;
        }
        $count++;
        $frame = 1 - $frame;
        $fr    = $nfr;
    }
}

grab_one();

my $mw = MainWindow->new();
my $image = $mw->Photo( -data => encode_base64($temp) );
$mw->Label( -image => $image )->pack( -expand => 1, -fill => 'both' );

my $label =
  $mw->Label( -text => $timestamp )->pack( -side => 'top', -padx => 3 );

my $center = $mw->Frame->pack( -anchor => 'center' );
$center->Button( -text => 'Quit', -command => [ destroy => $mw ] )
  ->pack( -side => 'left', -padx => 3 );
$center->Button( -text => 'Update', -command => \&update )
  ->pack( -side => 'left', -padx => 3 );
$center->Button( -text => 'Save', -command => \&save_it )
  ->pack( -side => 'left', -padx => 3 );

MainLoop;

sub save_it {
    open( JP, "> $timestamp.jpg" ) or die $!;
    print JP $temp;
    close JP;
    $label->configure( -text => "$timestamp.jpg  SAVED" );
    $label->update;
}

sub update {
   grab_one();
   $label->configure( -text => "$timestamp" );
   $label->update;
   $image->configure(-data => encode_base64($temp));
   $image->update;
   $mw->update;
}






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

Date: Fri, 18 Jul 2003 17:17:54 GMT
From: Steve Allan <stevea@wrq.com>
Subject: Re: File::Find is slower than using recursion!?
Message-Id: <uu19j4uv1.fsf@wrq.com>

sholden@flexal.cs.usyd.edu.au (Sam Holden) writes:

<snip>
>> Is poor performance a known problem with File::Find, or am I using it
>> improperly?  It's hard to believe it could be slower than recursion.
>> Any insights on why I'm seeing such a discrepancy?
>
>I'll take correct over fast any day.

No argument there.

>The recursive version doesn't work in the presence of symlink loops.
>Where doesn't work means infinitely recurses (well I guess it will run
>out of stack or memory at some point).
>
>I'll also take 1 line of code over 30 odd lines, and worry about
>speed if it turns out to be not fast enough for a given task.

I Agree here too.  I wasn't considering the use of the home-grown
recursive solution over the File::Find module.  I was more interested
in posting a reproducible example of what seems to be poor performance
to see if someone had any insight as to why File::Find is so much
slower than recursion.  Your point about symlinks may be hint.
Perhaps File::Find is just flat out doing more and that accounts for
the extra time.  It could also be that my sense that recursion is
inherently slow is outdated and just not true in Perl.

Anyone else have some thoughts on this?

Thanks.

-- 
-- Steve


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

Date: 18 Jul 2003 10:27:19 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: How to match all characters in a Character Class
Message-Id: <etoy8yvreag.fsf@wormtongue.emschwar>

foo <foo@bar.com> writes:
> Eric Schwartz wrote:
> >>>Is there a way in Perl to match all the characters in the Character
> >>>Class?
> 
> .* will do it.
> 
> > No, that matches any single character.  The OP was asking about
> > character classes, such as [a0-9q] and [:space:], and so forth.  To do
> 
> Are sure?  I reads more like the OP belives there is 'Character class'
> construct.

I'm not psychic, but that's how it read to me.

> > that, you'd need a way to enumerate them ...
> 
> ([:alpha:]|[:alnum:]|[:ascii:]|[:blank:]|[:cntrl:]|[:digit:]|[:graph:]|
> [:lower:]|[:print:]|[:punct:]|[:space:]|[:upper:]|[:word:]|[:xdigit:])

Er, no, 'them' is the entries in the character classes, not the
classes themselves.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Fri, 18 Jul 2003 10:40:09 -0500
From: "Boudga" <bruce@ghbraille.com>
Subject: Re: HTML REGEX
Message-Id: <vhg4s7jcs0r7ce@corp.supernews.com>

this however works well!



#!/usr/bin/perl


$ARGV[0] =~ /(.*)\.([^\.]*)/;
$outfile = "$1_cleaned.$2";

open (INFILE, "<$ARGV[0]");
open (OUTFILE, ">$outfile");

$outline="";
$bigString="";

while($outline=<INFILE>){
$outline =~ s/\n/ /gis;
$bigString .= $outline;
}

#while($outline=<INFILE>){

#print "---$outline---";
#$bigString =~ s/\n/ /gis;
$bigString =~ s/<body.*?>/<bodymatter>\n/gi;
$bigString =~ s/<p class=footnote>/<footnote>/gi;
$bigString =~ s/<b>/<strong>/gi;
$bigString =~ s/<\/b>/<\/strong>/gi;
$bigString =~ s/&nbsp;//gi;
$bigString =~ s/<meta.*>//gi;
$bigString =~ s/<\/span>//gi;
$bigString =~ s/<\/body>/<\/bodymatter>/gi;
$bigString =~ s/<\/p>/<\/p>\n/gi;
$bigString =~ s/<\/div>//gi;
$bigString =~ s/<html>/<\?xml version\=\"1\.0\"
encoding\=\"UTF\-8\"\?>\n<dtbook version\=\"1\.1\.0\">\n/gi;
$bigString =~ s/<head>/<head>\n/gi;
$bigString =~ s/<\/head>/\n<\/head>\n<book>\n/gi;
$bigString =~ s/<\/title>/<\/title>\n/gi;
$bigString =~ s/<\/table>/<\/table>\n/gi;
$bigString =~ s/<\/tr>/<\/tr>\n/gi;
$bigString =~ s/<tr>/<tr>\n/gi;
$bigString =~ s/<\/td>/<\/td>\n/gi;
$bigString =~ s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis;
$bigString =~ s/<style.*yle>/hello/gis;
$bigString =~ s/<p(.*?)>/<p>/gis;
$bigString =~ s/<table(.*?)>/<table>\n/gis;
$bigString =~ s/<br(.*?)>//gis;
$bigString =~ s/<td(.*?)>/<td>/gis;
$bigString =~ s/<div(.*?)>//gis;
$bigString =~ s/<span(.*?)>/[0]/gis;
$bigString =~ s/\[0\]//gis;
$bigString =~ s/<\/h2>/<\/h2>\n/gis;
$bigString =~ s/<\/h1>/<\/h1>\n/gis;


#$outline =~ s///gi;


print OUTFILE "$bigString";


close INFILE;
close OUTFILE;




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

Date: Fri, 18 Jul 2003 16:40:23 GMT
From: Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Subject: Re: HTML REGEX
Message-Id: <XpVRa.78449$OZ2.14377@rwcrnsc54>

Boudga wrote:

> I tried this "s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis" verbose and it
> didn't work at all for me!?!?!?

You are, again, being non-descript with your explaination of what 
"didn't work".  What was the input and what was the output?  Is this a 
really old version of Perl?

-- 
Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Perl hacker, computer wizard, and all-around internet guru
Resonator Software <http://www.ResonatorSoft.org/>



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

Date: Fri, 18 Jul 2003 16:42:11 GMT
From: Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Subject: Re: HTML REGEX
Message-Id: <DrVRa.78933$GL4.20017@rwcrnsc53>

Janek Schleicher wrote:
> Brendan Byrd/SineSwiper wrote at Fri, 18 Jul 2003 00:22:34 +0000:
>>$j =~ s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis
> 
>                            ^^
>                            .+?
> 
> In the hope that there are not more than only one style elements 
> (what is to be fair really rare).

Still, probably better to use ".+?".  Thanks...you just found a small 
bug in my code :)

-- 
Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Perl hacker, computer wizard, and all-around internet guru
Resonator Software <http://www.ResonatorSoft.org/>



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

Date: Fri, 18 Jul 2003 17:32:52 +0100
From: "Anthony Litton" <me@privacy.net>
Subject: Re: Newbie can't get CgiComments to name files correctly, and begs for help
Message-Id: <bf97g1$cjm6u$1@ID-168665.news.uni-berlin.de>



-- 
Anthony

Anthony Litton wrote:
|| Hi,
|| I'm a complete novice at this and I've been banging my head against
|| a brick wall. I apologise if this is not an appropriate place to ask
|| this question, and appreciate any help anyone can give me.
||
|| I've been trying to uses the perl script CgiComments by Jules Chan
|| (www.knurdle.com) to add comment functionality to my blog
|| (www.anthonyemigration.net/blogger.html. Nothing interesting has
|| happened to me since I started it). It does almost everything it's
|| supposed to.
||
|| The problem is this: the script successfully creates, shows, and
|| adds to a file, but when the showcount part of the script checks to
|| see if the file exists, it looks for the wrong name. Why would they
|| be different? Aren't they using the same variable?
||
|| For what it's worth, it seems to be the file creation part that's
|| incorrect. The showcount section looks for the file named as
|| $BlogItemNumber, but the file actually created is named something
|| else.
||
|| For example, the BlogItemNumber is 105761154411180725. The comment
|| file created is called 105761154411180720. The script looks for
|| 105761154411180725 and doesn't find it. Another identical example:
|| the BlogItemNumber is 105828670390199586, and the file created is
|| 105828670390199580.
||
|| Why are the files named incorrectly? Why does it always change the
|| final digit to 0?
||
|| Here are the sections of the script I'm having problems with. The
|| full script is available at
|| http://alumni.eecs.berkeley.edu/~rayning/cgicomments.txt.

<big snip>

OK, haven't solved the problem, but successfully kludged it (I believe
that's the correct term). For the benefit of future frustrated google group
searchers, here it is.
 By using the substr function I've narrowed the definintion of $blog_id to
be only the first sixteen characters of $BlogItemNumber. It works! I
replaced the line:

my($blog_id) = $cgiquery->param('blog_id');

with the lines
my($blog_ida) = $cgiquery->param('blog_id');
my($blog_id) = substr $blog_ida, 0, 16;

I'm sure that can be done more elegantly, but it works and I'm extremely
happy.

Thanks to all!
Anthony




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

Date: Sat, 19 Jul 2003 01:10:04 +0800
From: "j" <perseus_medusa@hotmail.com>
Subject: priority queue
Message-Id: <3f18289f$1@newsgate.hknet.com>

Hi all ,

    I am trying to implement a priority queue where people will submit some
job through cgi written in perl and then another independent perl script
will clear the queue. Different submitter has different priority. What's the
best way to implement a global queue that can be accessed by the cgi and the
perl script concurrently? We cannot use database though.

Thanks.

Perseus




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

Date: Fri, 18 Jul 2003 13:49:36 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: regl expression
Message-Id: <Pine.SGI.3.96.1030718134852.88233B-100000@vcmr-64.server.rpi.edu>

On Fri, 18 Jul 2003, Jeff 'japhy' Pinyan wrote:

>On Fri, 18 Jul 2003, bruno_storz wrote:
>
>>print &html_export( $template, \%html);
>
>You send TWO arguments here...
>
>> sub html_export {
>>    $line =  "<title><!-- HTML_titel --></title>";
>>    my ($htmlref) = @_;
>
>But you store the FIRST one as $htmlref.  The second argument is the hash
>ref.
>
>  my ($tpl, $htmlref) = @_;
>
>>    $line =~ s/<!-- HTML_([a-z]+) -->/$htmlref->{$1}/gix;
>>....
>>}

Oh, and get rid of the /x modifier on the regex.  It's causing the regex
engine to ignore the whitespace in your regex.

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Fri, 18 Jul 2003 15:09:08 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Removing characters once a series stops
Message-Id: <mbudash-58C92A.08091018072003@typhoon.sonic.net>

In article <3966ee66.0307180645.1bf4f959@posting.google.com>,
 jimnl69@hotmail.com (Jim) wrote:

> I have strings that I need to get the first set of numbers from. IE:
> 
> ABC123DEF
> ABC11JH8KLZ
> 
> I need to get 123 and 11 from the from the above strings.  I can strip
> the first characters off with =~ s/\D*//; but how do I strip off
> everything else, even any additional numbers, after the first set of
> numbers ends?  Thanks!
> 
> J

=~ s/^.*?(\d+).*$/$1/;

but if you just want to "get to" the numbers, why (possibly) munge the 
string?:

if ($string =~ /(\d+)/) {
  print "got: $1\n";
}
else {
  print "got nuthin\n";
}

-- 
Michael Budash


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

Date: 18 Jul 2003 10:40:10 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Removing characters once a series stops
Message-Id: <776e0325.0307180940.566d47b2@posting.google.com>

jimnl69@hotmail.com (Jim) wrote in message news:<3966ee66.0307180645.1bf4f959@posting.google.com>...
> I have strings that I need to get the first set of numbers from. IE:
> 
> ABC123DEF
> ABC11JH8KLZ
> 
> I need to get 123 and 11 from the from the above strings.  I can strip
> the first characters off with =~ s/\D*//; but how do I strip off
> everything else, even any additional numbers, after the first set of
> numbers ends?  Thanks!
> 
> J

Hello Jim:

Let's see here, how about 

  s/^\D*(\d+).+$/$1/;

Have a super weekend!
Gx


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

Date: Fri, 18 Jul 2003 16:49:41 GMT
From: Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Subject: Re: Removing Perl comments and strings using regexps
Message-Id: <FyVRa.78489$OZ2.12578@rwcrnsc54>

Tassilo v. Parseval wrote:

> Also sprach Brendan Byrd/SineSwiper:
> 
> If such a way existed, I'd like to know it, too. How I understand the
> B:: modules and the generic compiler backend O there is no such way.
> They are triggered in a CHECK block right after a script has been
> compiled. A B:: module simply provides a callback that is invoked on the
> optree of a script. So it can't work on strings.

Well, if I could code this into the current development version of LXR, 
it wouldn't need strings (all looking at files anyway), and I could just 
call another instance of perl with an OPEN command.  A little sloppy, 
but it beats re-inventing the wheel.

-- 
Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Perl hacker, computer wizard, and all-around internet guru
Resonator Software <http://www.ResonatorSoft.org/>



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

Date: Fri, 18 Jul 2003 11:56:43 -0500
From: "Boudga" <bruce@ghbraille.com>
Subject: replacing hex code characters
Message-Id: <vhg9bp6nrqvuba@corp.supernews.com>

Is it possible to substitute a hex code of "A0" with "20" in a text file
using Perl REGEX?




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

Date: Fri, 18 Jul 2003 16:58:40 GMT
From: Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Subject: Re: replacing hex code characters
Message-Id: <4HVRa.78984$GL4.19880@rwcrnsc53>

Boudga wrote:

> Is it possible to substitute a hex code of "A0" with "20" in a text file
> using Perl REGEX?

A0 doesn't translate to 20 in decimal, if that's what you mean.  If 
you're talking about the character that translates into A0, that can be 
represented with \xA0, and you can change them with s/\xA0/\x20/g.

Again, you need to be more specific in your posts to get a good answer.

-- 
Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Perl hacker, computer wizard, and all-around internet guru
Resonator Software <http://www.ResonatorSoft.org/>



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

Date: Fri, 18 Jul 2003 16:42:18 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: tab delimited file processing problem
Message-Id: <oq8ghvs6rqs9re229bt5955fumicu5e8l6@4ax.com>

Domenico Discepola wrote:

>Example Excel file row:
>col A's value=<empty>
>col B's value = "1"
>col C's value = "2"
><end of row>
>
>When you use Win32::OLE to "tell" Excel to save this as a TSV file (using
>the SaveAs method), a hex-dump of the resultant TSV file reveals row1 as:
>/^\t12$/  (using regex notation).  In other words, I lose the existence of
>col A (which I need).

No you don't. The first column comes before the first tab.

-- 
	Bart.


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

Date: Fri, 18 Jul 2003 17:56:37 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: tab delimited file processing problem
Message-Id: <pxWRa.31700$n95.4353711@news4.srv.hcvlny.cv.net>


"Domenico Discepola" <joeminga@yahoo.com> wrote in message
news:698c67f.0307171302.5b601332@posting.google.com...
> Hi all.  I have constructed a script that uses Win32::OLE to save an
Excel
> workbook as a tab-delimited text file (TSV file).  This works fine.
My next
> step is to perform formatting on each field per line in the TSV file
while
> retaining the # of fields.  The problem lies with "empty" cells in the
1st
> column of the Excel file.

I remember having similar problems in the distant past.  I used native
EXCEL commands to create the TSV file.  Details of the file format
depended on the version of EXCEL.  This is probably not a problem to
you, but beware!

Bill





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

Date: Fri, 18 Jul 2003 16:28:55 +0100
From: "Anthony Litton" <me@privacy.net>
Subject: Variable definition help needed
Message-Id: <bf93o1$cegm1$1@ID-168665.news.uni-berlin.de>

OK, this is in reference to my CgiComments problem, which asked for help on
on the 16th. The following lines are at the beginning of the script:

my($cgiquery) = new CGI;
my($blog_id) = $cgiquery->param('blog_id');

'blog_id' is an eighteen digit number, and for some reason I'm having
problems creating correctly named files. The final digit is always 0,
mysteriously. Would it be possible for me to define $blog_id as being only
the first seventeen, or sixteen digits of 'blog_id'?

Thanks for your help.

-- 
Anthony




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

Date: Fri, 18 Jul 2003 11:51:25 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Variable definition help needed
Message-Id: <1IURa.15143$124.178192@wagner.videotron.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Anthony Litton wrote:
> OK, this is in reference to my CgiComments problem, which asked for help on
> on the 16th. The following lines are at the beginning of the script:
> 
> my($cgiquery) = new CGI;
> my($blog_id) = $cgiquery->param('blog_id');
> 
> 'blog_id' is an eighteen digit number, and for some reason I'm having
> problems creating correctly named files. The final digit is always 0,
> mysteriously. Would it be possible for me to define $blog_id as being only
> the first seventeen, or sixteen digits of 'blog_id'?
> 
> Thanks for your help.
> 

Look into the substr function.

perldoc substr or http://www.perldoc.com/perl5.8.0/pod/func/substr.html


-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/GBd9eS99pGMif6wRAi3hAJ4mku5N75BaQ+Dhgq+kxWPTI5YfhgCgrAPu
yJhrqjxc9BiVKLdg5TySfCM=
=is+H
-----END PGP SIGNATURE-----



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

Date: Fri, 18 Jul 2003 17:28:16 +0100
From: "Anthony Litton" <me@privacy.net>
Subject: Re: Variable definition help needed
Message-Id: <bf977d$cm8f7$1@ID-168665.news.uni-berlin.de>

Mina Naguib wrote:
|| -----BEGIN xxx SIGNED MESSAGE-----
|| Hash: SHA1
||
|| Anthony Litton wrote:
||| OK, this is in reference to my CgiComments problem, which asked for
||| help on on the 16th. The following lines are at the beginning of
||| the script:
|||
||| my($cgiquery) = new CGI;
||| my($blog_id) = $cgiquery->param('blog_id');
|||
||| 'blog_id' is an eighteen digit number, and for some reason I'm
||| having problems creating correctly named files. The final digit is
||| always 0, mysteriously. Would it be possible for me to define
||| $blog_id as being only the first seventeen, or sixteen digits of
||| 'blog_id'?
|||
||| Thanks for your help.
|||
||
|| Look into the substr function.
||
|| perldoc substr or
|| http://www.perldoc.com/perl5.8.0/pod/func/substr.html
||
||
|| -----BEGIN xxx SIGNATURE-----
|| Version: GnuPG v1.2.1 (GNU/Linux)
|| Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
||
|| iD8DBQE/GBd9eS99pGMif6wRAi3hAJ4mku5N75BaQ+Dhgq+kxWPTI5YfhgCgrAPu
|| yJhrqjxc9BiVKLdg5TySfCM=
|| =is+H
|| -----END PGP SIGNATURE-----

You are my new favourite person. Thank you. I've replaced the line:
my($blog_id) = $cgiquery->param('blog_id');

with the lines
my($blog_ida) = $cgiquery->param('blog_id');
my($blog_id) = substr $blog_ida, 0, 16;

I'm sure that can be done more elegantly, but it works and I'm extremely
happy. Thanks again,
Anthony




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

Date: Fri, 18 Jul 2003 14:01:28 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Variable definition help needed
Message-Id: <%BWRa.5801$d34.191011@weber.videotron.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

> || Anthony Litton wrote:
> ||| OK, this is in reference to my CgiComments problem, which asked for
> ||| help on on the 16th. The following lines are at the beginning of
> ||| the script:
> |||
> ||| my($cgiquery) = new CGI;
> ||| my($blog_id) = $cgiquery->param('blog_id');
> |||
> ||| 'blog_id' is an eighteen digit number, and for some reason I'm
> ||| having problems creating correctly named files. The final digit is
> ||| always 0, mysteriously. Would it be possible for me to define
> ||| $blog_id as being only the first seventeen, or sixteen digits of
> ||| 'blog_id'?
> |||
> ||| Thanks for your help.
> |||
> ||
> || Look into the substr function.
> ||
> || perldoc substr or
> || http://www.perldoc.com/perl5.8.0/pod/func/substr.html
> You are my new favourite person. Thank you. I've replaced the line:
> my($blog_id) = $cgiquery->param('blog_id');
> 
> with the lines
> my($blog_ida) = $cgiquery->param('blog_id');
> my($blog_id) = substr $blog_ida, 0, 16;

No need for intermediate variables:

my $blog_id = substr($cgiquery->param('blog_id'), 0, 16);

Otherwise, good job :)


-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/GDX8eS99pGMif6wRAqZVAKD0sSttEdgjhphtcHLNZv/ZfBMFeQCghT00
eKE45zWG767Xi3EfOwpr9O0=
=4JGT
-----END PGP SIGNATURE-----



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

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


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