[24916] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7166 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 22 06:07:02 2004

Date: Wed, 22 Sep 2004 03:05:19 -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           Wed, 22 Sep 2004     Volume: 10 Number: 7166

Today's topics:
        CD burning on win32 <joericochuyt@msn.com>
    Re: CD burning on win32 <daveandniki@ntlworld.com>
        FuzzySearch library updated to version 2.3 (SoftComplete Development)
    Re: FuzzySearch library updated to version 2.3 <uri@stemsystems.com>
    Re: Help with my brute force method <someone@example.com>
    Re: How is this Perl Script encrypted? <abigail@abigail.nl>
    Re: How is this Perl Script encrypted? i6033162556-signup1@yahoo.com.cn
    Re: How is this Perl Script encrypted? <tintin@invalid.invalid>
    Re: In search of elegant code: Combining two statements <dmcbride@naboo.to.org.no.spam.for.me>
    Re: In search of elegant code: Combining two statements <tore@aursand.no>
    Re: new commands written in perl <abigail@abigail.nl>
    Re: new commands written in perl <uri@stemsystems.com>
    Re: new commands written in perl <abigail@abigail.nl>
        newbie OPEN MAIL perl question <nospam@nospam.com>
    Re: newbie OPEN MAIL perl question <noreply@gunnar.cc>
    Re: newbie OPEN MAIL perl question <nospam@nospam.com>
    Re: newbie OPEN MAIL perl question <noreply@gunnar.cc>
    Re: newbie OPEN MAIL perl question <nospam@nospam.com>
    Re: newbie OPEN MAIL perl question <Joe.Smith@inwap.com>
    Re: newbie OPEN MAIL perl question <noreply@gunnar.cc>
    Re: newbie OPEN MAIL perl question <nospam@nospam.com>
    Re: perlfaq6 <jkeen_via_google@yahoo.com>
    Re: perlfaq6 <comdog@panix.com>
    Re: pp failing <iss025@bangor.ac.uk>
    Re: pp failing <iss025@bangor.ac.uk>
    Re: Problem with global text search using Regular Expre (Charles DeRykus)
    Re: Problem with global text search using Regular Expre (Charles DeRykus)
    Re: space deliminated to comma delinated with varried a (Larry Felton Johnson)
        thanks <nospam@nospam.com>
    Re: What does this do ? !/somestring/ (J. Romano)
    Re: What does this do ? !/somestring/ (Malcolm Dew-Jones)
    Re: XMLout() output causes "not well-formed (invalid to <Joe.Smith@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 22 Sep 2004 05:47:47 -0400
From: "yusufdestina" <joericochuyt@msn.com>
Subject: CD burning on win32
Message-Id: <cb4fea0ac8dd090d64c6fb1c1d6e24f3@localhost.talkaboutprogramming.com>

Is it possible to write data to a cd on a windows platform with Perl?
if so, are there any modules for this? or should I stop thinking doing
that?
tnx in adv.



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

Date: Wed, 22 Sep 2004 10:01:56 GMT
From: "Dave" <daveandniki@ntlworld.com>
Subject: Re: CD burning on win32
Message-Id: <o4c4d.1336$WY1.331@newsfe2-gui.ntli.net>


"yusufdestina" <joericochuyt@msn.com> wrote in message
news:cb4fea0ac8dd090d64c6fb1c1d6e24f3@localhost.talkaboutprogramming.com...
> Is it possible to write data to a cd on a windows platform with Perl?
> if so, are there any modules for this? or should I stop thinking doing
> that?
> tnx in adv.
>

I don't know the answer but the key question is perhaps: do any of the cd
burning programs for windows have an OLE (automation) interface? If there is
one that has then perl can be used to drive it I should think.




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

Date: 22 Sep 2004 00:25:11 -0700
From: office@softcomplete.com (SoftComplete Development)
Subject: FuzzySearch library updated to version 2.3
Message-Id: <4feb6d7a.0409212325.175d149b@posting.google.com>

FuzzySearch library  http://www.textolution.com/fuzzysearch.asp
 is  an approximate string matching concerns to find patterns in texts in
presence of "mismatches" or "errors". Approximate string matching is
fundamental to text processing, because we live in an error-prone
world. It has several applications in data analysis and data retrieval
such as, for instance, searching text under the presence of typing or
spelling errors, character recognition system, spelling correction
program, retrieving musical passages, or finding biological sequences
in presence of possibly mutations or misreads.       

FuzzySearch library contains various functions for tasks exact and
approximate string comparising and matching. All functions speedup
optimised and oriented to text processing in natural languages.Work
with ANSI and with Unicode strings is supported.   

FuzzySearch library available for Delphi, VC, VB/VBA, and also can be
used in any language as COM-object.

http://www.textolution.com


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

Date: Wed, 22 Sep 2004 08:14:02 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: FuzzySearch library updated to version 2.3
Message-Id: <x7wtympvqt.fsf@mail.sysarch.com>


and your perl question is?

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: Wed, 22 Sep 2004 05:11:43 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Help with my brute force method
Message-Id: <jQ74d.109997$XP3.90423@edtnps84>

Jeff wrote:
> Thanks, John.
> 
> I'm trying to grasp what's happening in your statement:
> 
> my $Dis = join '|', map { my @a = split; /^spool/ ? @a[ 1 .. $#a ] : ()
> } <F>;
> 
> The join is going to insert the pipe character between each of the
> strings returned by the map command.
> The map is going to operate on each line in <F>
> @a will be set to each element in the line
> 
> /^spool/ ? @a[1 .. $#a] : ()
> 
> This means that if the line starts with spool, return elements 1
> through # elements, otherwise, return an empty array.
> 
> Correct?

Correct.  Of course it assumes that there is only one line that starts with 
'spool'.  :-)


John
-- 
use Perl;
program
fulfillment


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

Date: 22 Sep 2004 01:41:02 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: How is this Perl Script encrypted?
Message-Id: <slrncl1m1e.ka0.abigail@alexandra.abigail.nl>

i6033162556-signup1@yahoo.com.cn (i6033162556-signup1@yahoo.com.cn) wrote
on MMMMXXXIX September MCMXCIII in <URL:news:23d1674e.0409211300.4914c802@posting.google.com>:
//  http://www.c3scripts.com/amazon/release/ae-040531.zip
//  
//  I am not trying to hack this demo script, but I want to encrypt my own
//  scripts and distrubate them on the internet.

It's not encrypted. It's just a stupid method of trying to hide ugly
source. It took about 5 seconds to "crack" this - of which 4.5 seconds
were spend stirring my coffee.



Abigail
-- 
perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
           ${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'


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

Date: 21 Sep 2004 20:01:17 -0700
From: i6033162556-signup1@yahoo.com.cn
Subject: Re: How is this Perl Script encrypted?
Message-Id: <23d1674e.0409211901.3d08325e@posting.google.com>

Tim Hammerquist <tim@vegeta.ath.cx> wrote in message news:<slrncl1c1i.o4r.tim@vegeta.saiyix>...
> i6033162556-signup1@yahoo.com.cn <i6033162556-signup1@yahoo.com.cn> wrote:
> >  http://www.c3scripts.com/amazon/release/ae-040531.zip
> >  
> >  I am not trying to hack this demo script, but I want to encrypt my own
> >  scripts and distrubate them on the internet.
> 
> As you indicate you have written your own scripts, I suggest examining
> the last line of code.  It will tell you how to encode your own scripts
> without ever needing to decode the script above.
> 
> HTH,
> Tim Hammerquist

Yes, I did unpack them, but it is still not working. I changed the
final line to
$b=unpack("u",$s);
print $b;

I got the file, but still can not find how they use a key to verfy the
lisence of the script. Also, once I made some change to the file then
change it back, it does not work. It has some self destruction feature
that once the script is changed, it is not working.


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

Date: Wed, 22 Sep 2004 20:21:44 +1200
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: How is this Perl Script encrypted?
Message-Id: <2rcqvbF17146vU1@uni-berlin.de>


<i6033162556-signup1@yahoo.com.cn> wrote in message 
news:23d1674e.0409211300.4914c802@posting.google.com...
> http://www.c3scripts.com/amazon/release/ae-040531.zip
>
> I am not trying to hack this demo script, but I want to encrypt my own
> scripts and distrubate them on the internet.
>
> http://www.c3scripts.com/amazon/docs6.html

Have a look at the Acme modules, in particular Acme::Bleach is a popular 
(and fun) one to use.

http://search.cpan.org/~dconway/Acme-Bleach-1.12/lib/Acme/Bleach.pm 




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

Date: Wed, 22 Sep 2004 01:15:24 GMT
From: Darin McBride <dmcbride@naboo.to.org.no.spam.for.me>
Subject: Re: In search of elegant code: Combining two statements into one (DBI)
Message-Id: <Mm44d.485991$gE.129140@pd7tw3no>

David Filmer wrote:

> (I'm gonna use a DBI query as an example, but this question is really
> a Perl syntax inquiry (how to add elegance to a bit of code), not a
> database question).

Yes ... but it does have a bearing on the solution.

> Suppose I have a database table "department" with a simple structure
> such as:
> 
>    id     integer primary key   #might not be sequential because of
> deletes
>    name   varchar
> 
> I want to build a hash (%dept) from the database such that (for
> example) $dept{2} eq "Accounting".

Hopefully, this table stays relatively small.  ;-)

> I access the database:
> 
>    $sth = $dbh->prepare("SELECT id, name FROM department");
> $sth->execute;
> 
> Now, I COULD do this:
> 
>    $dept_ref = %{$sth->fetchall_hashref('id')};

I doubt it.  This would return a hash in scalar context - just remove
the %{}, and you'd be right.

> Which gives me a situation where $dept_ref->{2}->{'name'} eq
> "Accounting" - not really very close to the data structure I want (a
> simple hash). So I COULD, instead, populate a hash like this:

Well, actually pretty close.  You could write that as
$dept_ref->{2}{'name'} - same thing, really.  So, the only difference
is that you've got a ref to the hash of hashes, rather than a hash of
hashes.

>    %dept = %{$sth->fetchall_hashref('id')};
> 
> That gets me closer - now $dept{2}{'name'} eq "Accounting." DBI does
> this, of course, because I might be selecting multiple columns. But,
> in this case, I'm only selecting a key/value pair from the database
> and would like to go directly to a simple hash. But I need an EXTRA
> STEP to get to my goal - something like this:

Extra steps are not necessarily non-elegant.  Intermediary variables
often are elegant in that they make the code easier to read.  What you
want is to merely make compact code - not always the same thing as
elegant.

>    $dept{$_} = $dept{$_}{'name'} for keys %dept; #now $dept{2} eq
> 'Accounting'
> 
> That got me what I wanted, but it's not elegant - I had to populate
> the hash and then manipulate it. Is there an elegant way I can express
> the subroutine call (in this case to fetchall_hashref) so that it does
> this in just one step?

%dept = map { $_->[0] => $_->[1] } @{$sth->fetchall_arrayref()};

I don't have time right now to check the exact syntax of the arrayref
function, but that should be pretty close.


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

Date: Wed, 22 Sep 2004 06:51:04 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: In search of elegant code: Combining two statements into one (DBI)
Message-Id: <pan.2004.09.22.04.51.04.367519@aursand.no>

On Tue, 21 Sep 2004 16:44:37 -0700, David Filmer wrote:
> Now, I COULD do this:
> 
>    $dept_ref = %{$sth->fetchall_hashref('id')};
> 
> Which gives me a situation where $dept_ref->{2}->{'name'} eq
> "Accounting" - not really very close to the data structure I want (a
> simple hash). So I COULD, instead, populate a hash like this:
> 
>    %dept = %{$sth->fetchall_hashref('id')};
> 
> That gets me closer - now $dept{2}{'name'} eq "Accounting." DBI does
> this, of course, because I might be selecting multiple columns. But, in
> this case, I'm only selecting a key/value pair from the database and
> would like to go directly to a simple hash. But I need an EXTRA STEP to
> get to my goal - something like this:
> 
>    $dept{$_} = $dept{$_}{'name'} for keys %dept; #now $dept{2} eq
> 'Accounting'
> 
> That got me what I wanted, but it's not elegant - I had to populate the
> hash and then manipulate it. Is there an elegant way I can express the
> subroutine call (in this case to fetchall_hashref) so that it does this
> in just one step?

You want to play with the 'map' function.  You also want to use
'fetchall_arrayref' instead;

  my $stDepts = $dbh->prepare( 'SELECT id, name FROM dept );
  $stDepts->execute();
  my %dept = map { $_->[0] => $_->[1] } @{$stDepts->fetchall_arrayref()};
  $stDepts->finish();


-- 
Tore Aursand <tore@aursand.no>
"There are three kinds of lies: lies, damn lies, and statistics."
 (Benjamin Disraeli)


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

Date: 22 Sep 2004 01:33:15 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: new commands written in perl
Message-Id: <slrncl1lir.ka0.abigail@alexandra.abigail.nl>

Eric Schwartz (emschwar@pobox.com) wrote on MMMMXXXIX September MCMXCIII
in <URL:news:etohdprcvy7.fsf@wilson.emschwar>:
==  
==  Notice how I used single quotes there.  Some people will tell you it's
==  mandatory; I wouldn't go that far.  But as a general principle, I do
==  think it's helpful to only use double-quotes when you expect to
==  interpolate a variable in your string.

No, no, no. As a general principle, use single quotes if your string
contains (or may contain in the future) quotes, or a dollar or @ sign
you don't want to interpolate. Otherwise, use double quotes.

You'll notice that means you will have to change quotes far less often
than if your default is single quotes.

Besides, using double quotes make feel C programmers more at ease.


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=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: Wed, 22 Sep 2004 02:00:57 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: new commands written in perl
Message-Id: <x74qlrt65i.fsf@mail.sysarch.com>

>>>>> "A" == Abigail  <abigail@abigail.nl> writes:

  A> No, no, no. As a general principle, use single quotes if your string
  A> contains (or may contain in the future) quotes, or a dollar or @ sign
  A> you don't want to interpolate. Otherwise, use double quotes.

  A> You'll notice that means you will have to change quotes far less
  A> often than if your default is single quotes.

that is debatable. your strings may morph less that way but mine don't
morph too often and i don't mind the change since i do it for the
maintainer.

  A> Besides, using double quotes make feel C programmers more at ease.

and single quotes will make the shell programmers more at ease. :)

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: 22 Sep 2004 09:26:45 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: new commands written in perl
Message-Id: <slrncl2hal.ka0.abigail@alexandra.abigail.nl>

Uri Guttman (uri@stemsystems.com) wrote on MMMMXL September MCMXCIII in
<URL:news:x74qlrt65i.fsf@mail.sysarch.com>:
][ >>>>> "A" == Abigail  <abigail@abigail.nl> writes:
][  
][   A> No, no, no. As a general principle, use single quotes if your string
][   A> contains (or may contain in the future) quotes, or a dollar or @ sign
][   A> you don't want to interpolate. Otherwise, use double quotes.
][  
][   A> You'll notice that means you will have to change quotes far less
][   A> often than if your default is single quotes.
][  
][  that is debatable. your strings may morph less that way but mine don't
][  morph too often and i don't mind the change since i do it for the
][  maintainer.

I do it for the developer - since then the program will change most often.
But usually I'm both the developer and maintainer anyway.

][   A> Besides, using double quotes make feel C programmers more at ease.
][  
][  and single quotes will make the shell programmers more at ease. :)

How so? In the shell, one uses both single, and double quotes for strings
- with similar differences as in Perl: interpolation with double quotes,
and no interpolation with single quotes. Of course, the shell has much
cooler strings than Perl has.


Abigail
-- 
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
          for (s;s;s;s;s;s;s;s;s;s;s;s)
              {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'


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

Date: Wed, 22 Sep 2004 03:11:57 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: newbie OPEN MAIL perl question
Message-Id: <1095837152.681913@nntp.acecape.com>

i like that i can easily send out automated emails using perl  "OPEN
MAIL"....can i assume that there is a command to "read mail"?  and if so,
what is it?

thank




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

Date: Wed, 22 Sep 2004 09:36:15 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: newbie OPEN MAIL perl question
Message-Id: <2rco94F18cet0U1@uni-berlin.de>

daniel kaplan wrote:
> i like that i can easily send out automated emails using perl
> "OPEN MAIL"....

Guess you mean

     open MAIL

Perl is case sensitive.

> can i assume that there is a command to "read mail"?  and if so, 
> what is it?

Sure, you can use exactly the same:

     open MAIL

It's true that the rest differs quite a lot, but don't let us be
bothered by such details.


Your question tells me that you should take, not one, but several
steps back and start learning the basics:

     http://learn.perl.org/

> thank

You're welcome.

Good luck!

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


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

Date: Wed, 22 Sep 2004 04:00:42 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: newbie OPEN MAIL perl question
Message-Id: <1095840077.763032@nntp.acecape.com>

thanks, but am a dive in kind of guy....any chance you can throw me one or
two of the commands that are specific to READING email using perl?

i need to narrow my google searches on "open mail" reading email perl

thanks!




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

Date: Wed, 22 Sep 2004 10:56:11 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: newbie OPEN MAIL perl question
Message-Id: <2rcsv1F18e1agU2@uni-berlin.de>

daniel kaplan wrote:
> thanks, but am a dive in kind of guy....

Then programming may not be for you.

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


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

Date: Wed, 22 Sep 2004 04:58:29 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: newbie OPEN MAIL perl question
Message-Id: <1095843545.930386@nntp.acecape.com>

ok, seriously, not to be rude, am a C programmer....use books just for
reference.....and am not SWITCHING to perl, but need to write three quick
scripts, thats all......if it's cool with you, i would not like to get into
a flame war...just looking for some keywords to narrow my searches
down....love newgroups, cause its where programmers go to each other for
guidance..

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2rcsv1F18e1agU2@uni-berlin.de...
> daniel kaplan wrote:
> > thanks, but am a dive in kind of guy....
>
> Then programming may not be for you.
>
> -- 
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl




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

Date: Wed, 22 Sep 2004 09:16:06 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: newbie OPEN MAIL perl question
Message-Id: <ppb4d.2288$He1.1401@attbi_s01>

daniel kaplan wrote:

> thanks, but am a dive in kind of guy....any chance you can throw me one or
> two of the commands that are specific to READING email using perl?

There are no commands in perl for reading mail.

Perl has built-in functions for manipulating strings, but reading
mail takes a full-fledged application, not one or two 'commands'.

There are many perl modules (see http://search.cpan.com/) for processing
or analysing RFC822 SMTP messages, but reading requires a human and
a Mail User Agent.  Like Eudora, Outlook Express, Thunderbird, Netscape
Messenger, Mozilla Mail, elm, pine, mutt, etc.

	-Joe


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

Date: Wed, 22 Sep 2004 11:21:16 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: newbie OPEN MAIL perl question
Message-Id: <2rcue2F17vo3nU1@uni-berlin.de>

daniel kaplan wrote:
> i would not like to get into a flame war...

Me neither.

Okay, to send a message from Perl you pass the info to a MTA. One way
to do so is to open a pipe to the MTA, and the filehandle is often
named "MAIL"... That's why you often see "open MAIL..." in Perl code.

However, I prefer to use modules for mail sending. There are quite a
few of them, and my favorite is Mail::Sender. Download it from CPAN,
and the module docs should tell you the rest.

As regards reading, I don't know if you are talking about reading
messages stored on the same file system or about remote reading, but
there are CPAN modules to help you with both.

> just looking for some keywords to narrow my searches down....

Search CPAN rather than the whole web. http://search.cpan.org/

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


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

Date: Wed, 22 Sep 2004 05:31:23 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: newbie OPEN MAIL perl question
Message-Id: <1095845522.169141@nntp.acecape.com>

thanks
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2rcue2F17vo3nU1@uni-berlin.de...
> daniel kaplan wrote:
> > i would not like to get into a flame war...
>
> Me neither.
>
> Okay, to send a message from Perl you pass the info to a MTA. One way
> to do so is to open a pipe to the MTA, and the filehandle is often
> named "MAIL"... That's why you often see "open MAIL..." in Perl code.
>
> However, I prefer to use modules for mail sending. There are quite a
> few of them, and my favorite is Mail::Sender. Download it from CPAN,
> and the module docs should tell you the rest.
>
> As regards reading, I don't know if you are talking about reading
> messages stored on the same file system or about remote reading, but
> there are CPAN modules to help you with both.
>
> > just looking for some keywords to narrow my searches down....
>
> Search CPAN rather than the whole web. http://search.cpan.org/
>
> -- 
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl




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

Date: Wed, 22 Sep 2004 03:21:10 GMT
From: Jim Keenan <jkeen_via_google@yahoo.com>
Subject: Re: perlfaq6
Message-Id: <Gc64d.3145$Ec4.2624@trndny04>

Anno Siegel wrote:
> Vittal <vsnadagouda@yahoo.com> wrote in comp.lang.perl.misc:
> 

>>
>>s#/\*[^*]*\*+([^/*][^*]*\*+)*/?//[^\n]*?("(\\.?[^"\\])*"??(\\.?[^?\\])*??.[^/"?\\]*)#$2#gs;
>>
>>print $_;
> 
> 
> That is not the regex from the "comment" faq (for Perl v5.8.1).  In
> particular, the double "??" are in error.
> 

There's something amiss with Vittal's character mapping.  Some 
characters (e.g., the vertical bar (|) and the single quote (') are 
being rendered as question marks (?).

jimk


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

Date: Tue, 21 Sep 2004 22:40:26 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: perlfaq6
Message-Id: <210920042240269793%comdog@panix.com>

In article <f9dcc290.0409200525.245af02b@posting.google.com>, Vittal
<vsnadagouda@yahoo.com> wrote:

> Hello All,
> 
> I am going the FAQ of perl. In perlfaq6, a method has been given to
> remove C/C++ comments. I am not understanding how to use it. Can
> somebody help me in understanding?

I'm not sure where you had trouble, but it looks like the example
in perlfaq6 had a syntax error.  It was missing a semicolon after
the substitution.  I've fixed this in the repository, but it won't
show up in perl until the next release.


    $/ = undef;
    $_ = <>;
  
s#/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]
*)#$2#gs;
    print;

Save this in a file (say, strip_comments), and call it with the file
you want to strip:

   perl strip_comments file.c

-- 
brian d foy, comdog@panix.com


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

Date: Wed, 22 Sep 2004 10:17:03 +0100
From: "P.R.Brady" <iss025@bangor.ac.uk>
Subject: Re: pp failing
Message-Id: <4151430F.50605@bangor.ac.uk>

Graham Wood wrote:
> "P.R.Brady" wrote:
> 
>>I'm trying to generate a self-contained executable with pp but it is
>>fighting back and I think I have a major misunderstanding somewhere!
> 
> 
> I had lots of headaches getting pp to work.  Your problem is that your
> Compress::Zlib is newer than your PAR install.  You can get the older
> one by installing an older build of perl (I think Activestate build 635
> is where I was told to get this version of Compress::Zlib).
> 
> When I finally got mine to work I ended up reinstalling perl
> (Activestate build 638 of 5.6.1), set the HTTP_proxy environment
> variable so that ppm ran properly then reinstalled PAR using my new
> working ppm.  According to the docs (and my experience) not setting
> HTTP_proxy is one of the most common reasons for difficulties using
> ppm.  Installing PAR properly with your ppm not working properly is
> painful.
> 
> Hope this helps.
> 
> Graham

Thanks Graham,
    ppm3 query * shows that I am already using Activestate 5.6.1 build 
638 and PAR 0.63.  Update attempt of PAR says it is the latest.
Which version of PAR are you using?

HTTP_proxy is unset and I now see: 
http://aspn.activestate.com/ASPN/Downloads/ActivePerl/PPM/
but ppm has worked before and our firewall does not deny 80 or 8080. 
Certainly my browser is set proxy-less and works.

Regards
Phil


Phil


-- 
Phil Brady
Information Services
University of Wales, Bangor
Adeilad Deiniol
Deiniol Rd
Bangor LL57 2UX

Tel +44 (0)1248 382960
Fax +44 (0)1248 383826

P.R.Brady@bangor.ac.uk



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

Date: Wed, 22 Sep 2004 10:58:34 +0100
From: "P.R.Brady" <iss025@bangor.ac.uk>
To: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: pp failing
Message-Id: <41514CCA.4090003@bangor.ac.uk>

Graham Wood wrote:
> "P.R.Brady" wrote:
> 
>>I'm trying to generate a self-contained executable with pp but it is
>>fighting back and I think I have a major misunderstanding somewhere!
> 
> 
> I had lots of headaches getting pp to work.  Your problem is that your
> Compress::Zlib is newer than your PAR install.  You can get the older
> one by installing an older build of perl (I think Activestate build 635
> is where I was told to get this version of Compress::Zlib).
> 
> When I finally got mine to work I ended up reinstalling perl
> (Activestate build 638 of 5.6.1), set the HTTP_proxy environment
> variable so that ppm ran properly then reinstalled PAR using my new
> working ppm.  According to the docs (and my experience) not setting
> HTTP_proxy is one of the most common reasons for difficulties using
> ppm.  Installing PAR properly with your ppm not working properly is
> painful.
> 
> Hope this helps.
> 
> Graham

Bingo!   Fixed it.
Activestate 5.6.1 638 and version 0.63 of PAR failed as above.
Using ppm3 to remove PAR and then install version 0.85 has fixed it.
Not sure where 0.63 came from but I only loaded it last week.
Thanks for the hint Graham.

Phil



-- 
Phil Brady
Information Services
University of Wales, Bangor
Adeilad Deiniol
Deiniol Rd
Bangor LL57 2UX

Tel +44 (0)1248 382960
Fax +44 (0)1248 383826

P.R.Brady@bangor.ac.uk



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

Date: Wed, 22 Sep 2004 03:57:09 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Problem with global text search using Regular Expressions
Message-Id: <I4FCB9.Lsp@news.boeing.com>

In article <e3932667.0409131452.6b9044a1@posting.google.com>,
Jayal <jayalmehta@hotmail.com> wrote:
>Hi
>I am trying to perform a global search in a string using regular
>expressions.
>
>consider the string
>
>"attgccgccgccatt"
>If I wish to search for the string "ccgcc" within it, if I use the
>operation given below, I would get only one find
>
>$a =~ /ccgcc/g;
>$location = pos......
>
>which would be the find match. 
>What do I do if I want to get both occurances?
>
>I also tried the index() function but that does not allow use of
>regular expressions. Is there any function available for this?
>

With a slight mod to Anno's solution, you could even get 
match pos's:

my $pos = 0;
while ( $s =~ /(.+?)(?=(ccgcc))/g ) {
   print "pos=", ($pos += length $1), " match=$2\n";

}

pos=4 match=ccgcc
pos=7 match=ccgcc


hth,
--
Charles DeRykus


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

Date: Wed, 22 Sep 2004 06:58:11 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Problem with global text search using Regular Expressions
Message-Id: <I4FKoz.4tM@news.boeing.com>

In article <I4FCB9.Lsp@news.boeing.com>,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>In article <e3932667.0409131452.6b9044a1@posting.google.com>,
>Jayal <jayalmehta@hotmail.com> wrote:
>> ...
>
>With a slight mod to Anno's solution, you could even get 
>match pos's:
>
>my $pos = 0;
>while ( $s =~ /(.+?)(?=(ccgcc))/g ) {
>   print "pos=", ($pos += length $1), " match=$2\n";
>
>}
>
>pos=4 match=ccgcc
>pos=7 match=ccgcc
>

Needs a mod to the mod: 

#  mod to handle match string at pos 0 
my $pos = 0;
while ( $s =~ /(^|.+?)(?=(ccgcc))/g ) {
   print "pos=", ($pos += length $1), " match=$2\n";
}

--
Charles DeRykus


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

Date: 22 Sep 2004 03:00:31 -0700
From: larryj@gsu.edu (Larry Felton Johnson)
Subject: Re: space deliminated to comma delinated with varried and need spaces between some columns
Message-Id: <4ae7bf57.0409220200.107f8270@posting.google.com>

larryj@gsu.edu (Larry Felton Johnson) wrote in message news:<4ae7bf57.0409211224.14e8090b@posting.google.com>...
> "LHradowy" <laura.hradowy@NOSPAM.mts.caaaaa> wrote in message news:<WYF3d.1170$IO.7153@news1.mts.net>...
> > I have file that looks like this...
> >        1555002                         00 0 04 27              TELN NOT BILL
> >        3555007                         00 0 06 00              CUSTOMER HAS
> > > 1
>   5555410                         00 0 12 10              CUSTOMER HAS
> > > 1
>   6755012                         00 0 12 06              CUSTOMER HAS
> > > 1
> > 
> > Notice the white spaces at beginning of the line, I DONT WANT THEM THERE
> > Notice the white spaces in the 2nd and 3rd columns, I NEED THEM THERE...
> > 
> > I need to created a perl script that takes this file and makes it look like
> > this
> > 1555002,00 0 04 27,TELN NOT BILL
> > 3555007,00 0 06 00,CUSTOMER HAS > 1
> > 5555410,00 0 12 10,CUSTOMER HAS > 1
> > 6755012,00 0 12 06,CUSTOMER HAS > 1
> > 
> > This output needs to be written to a file.
> > I have no idea how to start, if I split on a space " " the it will spit the
> > third an fourth column up. The fourth column can basically be left alone.
> > 
> > Thanks for the help.
> 

> 
> perl -pi.bak -e 's/^\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(.*)/$1,$2
> $3 $4 $5,$6/g' spaces
> 

A couple of followup things.  My g option above (after the last '/'
was a typo.  It didn't hurt or help, but was superfluous.

The second is that the whole approach to looking at lines in a file
like this bears a little bit of discussion.  When I looked at the
lines, the first thing that entered my mind wasn't "How do I get rid
of the spaces?" but "What always seems to be true about these lines?"

Basically you're looking at a line like this

some spaces, some digits,space,digits,space,digits,space,digits,space,digits,space,some
variable text with no necessity to format.

I could have used \d+ instead of \w+, but everything in the match
breaks down to
\w+, \s+ or .*

So there are only three types of things to match, digits, spaces and
the "everything else" trailing at the end.

Given this a number of the approaches people have given will all work:
regex,
splitting into an array, substr (if the positions are uniform) and
unpack (if the positions are uniform).  The task is to capture the
nonspace stuff into usable variables and print them out with inserted
whitespace and any punctuation or labeling characters you choose. 
This mental approach gives you much more control over the formatting
and use of the data than thinking of it as
simply not wanting the spaces at the beginning of line, but wanting to
preserve some of the spaces in the middle.


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

Date: Wed, 22 Sep 2004 05:31:14 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: thanks
Message-Id: <1095845511.641656@nntp.acecape.com>


-- Sergio D. Caplan Tel: (917) 403-3205 AIM: SergDC sergio@warptv.com Want
to see some of my past work? All my hard work was nominated for an award. Up
against Microsoft no less: www.WarpTV.com/articles




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

Date: 21 Sep 2004 20:11:19 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: What does this do ? !/somestring/
Message-Id: <b893f5d4.0409211911.492b96d3@posting.google.com>

Abhinav <matrix_calling@yahoo.dot.com> wrote in message news:<6hP3d.58$AE3.95@news.oracle.com>...
> 
> Hmm ..
> Reading this inside out, this would
> 
> 1. check if $_ !~ /asd/
> 2. The return value from this check is taken an expression,
> which is on the right side of $str
> 
> Hence, $str =~ expr # This is evaluated as $str =~ /expr/
> 
> This is what I could ascertain from "Programming Perl",
> page 90, "Binding Operators". I hope I am correct ?


   It looks like you are correct, Abhinav.  According to the "Binding
Operators" section of "perldoc perlop", "if the right argument is an
expression rather than a search pattern [(or a substitution or
transliteration)] it is interpreted as a search pattern at run time." 
So the code:

      $str =~ "asd";

is just a sloppy way of saying:

      $str =~ m/asd/;

   It gets weirder, however.  According to "perldoc perlop" in the
section "m/PATTERN/cgimosx", "if the PATTERN evaluates to the empty
string, the last
*successfully* matched regular expression is used instead."

   Usually this isn't a major concern, but it is if the pattern
contains a variable that is set to the empty string.  So how does that
affect you?

   Well, by tinkering around with Perl's regular expression matching,
it seems that m/PATTERN/ either returns a 1 if the match was
successful, or "" (the empty string -- which evaluates to false) if
the match was unsuccessful.  Putting a "!" in front of either will
return the other (in other words, ((!1) eq "") and ((!"") eq 1).

   Therefore, the original line of code you posted:

      $str =~ !/asd/;

is equivalent to:

      $str =~ ! ($_ =~ m/asd/);

   If $_ is either undefined or does not contain the string "asd",
then the line is also equivalent to:

      $str =~ ! ("");

which is equivalent to:

      $str =~ 1;

which is equivalent to:

      $str =~ m/1/;

which will return true only if $str contains a "1".

   On the other hand, if $_ is defined and contains the string "asd",
then the line:

      $str =~ !/asd/;

which, as I already said, is equivalent to:

      $str =~ ! ($_ =~ m/asd/);

is now equivalent to:

      $str =~ ! (1);

which is equivalent to:

      $str =~ "";

which is equivalent to:

      $str =~ m//;

which, according to the perldoc, will not try to match an empty
string, but will use the last *successfully* matched regular
expression instead.

   Therefore, if you see had lines of code:

      "Wizard of Wor" =~ m/Wor/;  # successful match
      "All your base are belong to us" =~ m/bases/;
      $_ = "wasderful";
      $str = "Hello, World!";
      $str =~ !/asd/;  # original line

the line:

      $str =~ !/asd/;  # original line

will be equivalent to:

      $str =~ m/Wor/;

because the m/Wor/ match was the last successful pattern match.  It
will therefore evaluate to true, even though $str does not contain the
string "asd".

   Strange, isn't it?

   Maybe this bizzare side-effect helps explain why, as you said in
your first post, that the code worked in some cases.  The original
line of code was meant to check for the non-existence of "asd", but
instead checked for the existence of "Wor".  Either way, it's still
possible to evaluate to true in some cases (like the one I just showed
you).

   I hope this explains things more than it confused you.  To tell you
the truth, Abhinav, your question made me search through the Perl
documentation for a good while before I figured out what was
happening.  In other words, a lot more was happening "behind the
scenes" with your code than I first realized!

   Cheers,

   Jean-Luc


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

Date: 21 Sep 2004 22:35:12 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: What does this do ? !/somestring/
Message-Id: <41510f10@news.victoria.tc.ca>

J. Romano (jl_post@hotmail.com) wrote:

: which is equivalent to:

:       $str =~ m//;

: which, according to the perldoc, will not try to match an empty
: string, but will use the last *successfully* matched regular
: expression instead.

It's documented, but it's a trap, and not mentioned in perltraps.pod as
far as I can see.  Perhaps this gotcha is mention in the faqs, but not
that I saw.

'use warnings' will warn you if the $var is undefined, but if it's defined
but length = 0 then you get no warning about the probably unexpected m//
behaviour.

The hard part is to remember to protect yourself in this situation.

The solution depends on the correct interpretation of m// at that point in
your program. Technically m// should match everything, but that may or may
not make sense in a particular situation.

if matching everything is fine then one trick is to say

	m/^/; # always matches, and isn't empty

	if ( m/$var/ ) # now forced to match if $var is empty

or you can be explicit

	if ( $var eq '' or m/$var/ )

or the reverse if appropriate

	if ( $var ne '' and m/$var/ )

or there's always 
	die unless defined $var and $var ne ''

but like I said, the hard part is to remember you need to do something at
all.


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

Date: Wed, 22 Sep 2004 09:07:09 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: XMLout() output causes "not well-formed (invalid token)" in XMLin()
Message-Id: <1hb4d.2262$He1.1137@attbi_s01>

pt wrote:

> use XML::Simple;
> # %List is a hash of hashes.
> # Key is an IP number (stored as string, not v-string)
> XMLout(\%List, OutputFile => $Fname) or die "XMLout : $Fname" ;
> 
> produces:
> <opt>
>   <211.57.214.74 ProbeCount="1" LastProbe="1092087541" />
 > </opt>

I would have expected to use something more like this:

  <opt>
   <xx addr="211.57.214.74" ProbeCount="1" LastProbe="1092087541" />
   <xx addr="204.251.212.93" ProbeCount="1" LastProbe="1095511410" />
  </opt>


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

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


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