[25163] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7412 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 17 06:05:42 2004

Date: Wed, 17 Nov 2004 03:05:06 -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           Wed, 17 Nov 2004     Volume: 10 Number: 7412

Today's topics:
    Re: Advice needed: threads and queues <vetler@gmail.com>
        anyone tried http-proxy on windows? (harris)
    Re: Array -> Reference to Hash of Arrays (Tom)
    Re: DBD::CSV or  DBD::DBM or something else? <meneg@nospm.org>
        FAQ 4.0: What's MakeMaker? <comdog@panix.com>
        FAQ 5.16: How can I open a file with a leading ">" or t <comdog@panix.com>
        How to get sytem/hardware information? (Akhila)
    Re: How to get sytem/hardware information? <josef.moellers@fujitsu-siemens.com>
    Re: How to get sytem/hardware information? (replace z with h, spam protection)
    Re: How to get sytem/hardware information? <josef.moellers@fujitsu-siemens.com>
        Managing PERL5LIB with multiple perl installation <FILTERjvsSPAM@india.ti.com>
    Re: Managing PERL5LIB with multiple perl installation <postmaster@castleamber.com>
    Re: OPEN command <bik.mido@tiscalinet.it>
    Re: problems using taint to check an array be created b <1usa@llenroc.ude.invalid>
    Re: problems using taint to check an array be created b <noreply@gunnar.cc>
    Re: problems using taint to check an array be created b <1usa@llenroc.ude.invalid>
        regex - to simple to see? <g-preston1@ti.com>
    Re: regex - to simple to see? <g-preston1@ti.com>
    Re: regex - to simple to see? <1usa@llenroc.ude.invalid>
    Re: regex - to simple to see? <1usa@llenroc.ude.invalid>
    Re: regex - to simple to see? <g-preston1@ti.com>
    Re: regex - to simple to see? <gnari@simnet.is>
    Re: regex - to simple to see? <do-not-use@invalid.net>
    Re: regex - to simple to see? (Gerhard M)
    Re: Search for string and return file name (Gerhard M)
    Re: SQL ERROR <nospam@nospam.com>
    Re: SQL ERROR <nospam@nospam.com>
    Re: Time::HiRes module and timing a command... <bik.mido@tiscalinet.it>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 17 Nov 2004 09:55:39 +0100
From: "Vetle Roeim" <vetler@gmail.com>
Subject: Re: Advice needed: threads and queues
Message-Id: <opshlpq111x7nu7z@quickfix.opera.com>

On Tue, 16 Nov 2004 18:20:32 -0600, Swartz <swartz@inbox.ru> wrote:

[...]
> #!/usr/bin/perl
> use threads;
> use threads::shared;
> use Thread::Queue;

   use strict;
   use warnings;

   This will give you some additional error messages that you should fix.  
Threads is somewhat messy, and you should make sure that your code works  
properly.


> # Hash of songs
> my %song : shared =
>         ("1" => "Song 1",
>          "2" => "Song 2",
>          "3" => "Song 3",
>          "4" => "Song 4",
>          "5" => "Song 5",
>          "6" => "Song 6",
>          "7" => "Song 7",
>          "8" => "Song 8");
>
[...]
>
>         if ($song{$song_num}{locked}) {

   Your hash contains strings, so what do you expect this to do?


[...]
-- 
It's not a bug, it's the future.


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

Date: 16 Nov 2004 18:42:49 -0800
From: harris_m@yahoo.com (harris)
Subject: anyone tried http-proxy on windows?
Message-Id: <af968c64.0411161842.2113421a@posting.google.com>

Hello,
Anyone tried to install and run http-proxy module on windows 2000 or
win-xp?

I gave it a try. The program hangs up. Any one had luck to get this
working on windows?
Harris M.


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

Date: 16 Nov 2004 22:00:45 -0800
From: sudhirx@gmail.com (Tom)
Subject: Re: Array -> Reference to Hash of Arrays
Message-Id: <f50c52fa.0411162200.65b4846b@posting.google.com>

Thanks thats a lot of information.
perldoc perldsc was quite useful. 

Is it possible to store "AoA" - Array of Array as value to a hash key?

Array -> AoH -> AoA

I have an array and the individual element points to an element(in AoH).
Value of the hash key would be an AoA.
I'm trying this at my end. And would appreciate comments on this.


Brian McCauley <nobull@mail.com> wrote in message news:<cmgcac$5ns$1@sun3.bham.ac.uk>...
> Tom wrote:
> 
> > Hope my subject is right !
> > Well, Here is what 'm trying to fight with
> > 
> > How to create/add/delete/print an "Array which Refers to Hash of
> > Arrays"
> > 
> > Array - List of test cases  (Not-Unique)
> > Hash  - Key: Test Case Iteration #   (Unique)
> >         Value: <More than one value> i.e Array
> 
> If "Test Case Iteration #" is simply a sequential integer then it would 
> be more natural to use an array rather than a hash for your second level 
> structure.
> 
> If the "<More than one value>" are disimilar things like "duration", 
> "memory usage", "number of rabits pulled from hat" then it is unnatural 
> to put them in an array and would be more natural to use a hash.
> 
> Only if "<More than one value>" is a list of like values does an array 
> seem the natural choice.  e.g. "weight of first rabit","weight of second 
> rabit" ... "weight of last rabit".
> 
> Anyhow, as others have said, if you find something in the documentation 
> unclear then please tell us precicely what so that we can have a chance 
> to improve the documentation.


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

Date: Wed, 17 Nov 2004 11:07:25 +0200
From: meneg <meneg@nospm.org>
Subject: Re: DBD::CSV or  DBD::DBM or something else?
Message-Id: <pan.2004.11.17.09.07.25.108962@nospm.org>

On Mon, 15 Nov 2004 19:47:59 +0000, A. Sinan Unur wrote:

> The user id under which the web server is running will need to be able to 
> read the CSV files. That means, the whole world would need to be able 
> toread them. Putting financial information in those files is a sure 
> recipe for disaster.
> 
> Please note that your question is independent of the language you are 
> programming in. 
> 
> Sinan.

Thanks for the response. Your feedback is very helpful and I see your
point - also your point that this is more of a general dbase question -.
However I still don't drop the question on file dbases because it more of
a "do you trust your webserver?" or a "do you trust your hosting
administrator?" question. And I mean someone would argue that properly
setting up those files to be treated by the system and the webserver is
not always worse than having a badly administered database. Of course in
"average" situations postgres or mysql would be more secure but it can be
argued that a file can as well be protected under good udministering.

-meneg





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

Date: Wed, 17 Nov 2004 05:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 4.0: What's MakeMaker?
Message-Id: <cnem25$a8d$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

4.0: What's MakeMaker?

    This module (part of the standard Perl distribution) is designed to
    write a Makefile for an extension module from a Makefile.PL. For more
    information, see ExtUtils::MakeMaker.



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Wed, 17 Nov 2004 11:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 5.16: How can I open a file with a leading ">" or trailing blanks?
Message-Id: <cnfb55$ffa$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

5.16: How can I open a file with a leading ">" or trailing blanks?

    Normally perl ignores trailing blanks in filenames, and interprets
    certain leading characters (or a trailing "|") to mean something
    special.

    The three argument form of open() lets you specify the mode separately
    from the filename. The open() function treats special mode characters
    and whitespace in the filename as literals

            open FILE, "<", "  file  ";  # filename is "   file   "
            open FILE, ">", ">file";     # filename is ">file"

    It may be a lot clearer to use sysopen(), though:

        use Fcntl;
        $badpath = "<<<something really wicked   ";
        sysopen (FH, $badpath, O_WRONLY | O_CREAT | O_TRUNC)
            or die "can't open $badpath: $!";



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: 17 Nov 2004 00:43:16 -0800
From: akhilau@hotmail.com (Akhila)
Subject: How to get sytem/hardware information?
Message-Id: <6358fb6c.0411170043.5267d303@posting.google.com>

Hi All, 
  I wish to find hardware information like
    hard disk type make size
    ram size
    monitor info like company
    mouse type
    mother board chipset type 
    etc etc... 

    also all the names of RPM's installed.

 Is there any way i can do this using perl on Linux(I have fedora core 2)?
 Thanking you in advance.
Bye


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

Date: Wed, 17 Nov 2004 10:09:52 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: How to get sytem/hardware information?
Message-Id: <cnf4bt$31$1@nntp.fujitsu-siemens.com>

Akhila wrote:
> Hi All,=20
>   I wish to find hardware information like
>     hard disk type make size
>     ram size
>     monitor info like company
>     mouse type
>     mother board chipset type=20
>     etc etc...=20
>=20
>     also all the names of RPM's installed.
>=20
>  Is there any way i can do this using perl on Linux(I have fedora core =
2)?
>  Thanking you in advance.

There are a number of places to look for this information:
- /proc subsystem
- dmidecode program
- rpm program

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Wed, 17 Nov 2004 10:22:36 +0100
From: "D. Marxsen" <detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)>
Subject: Re: How to get sytem/hardware information?
Message-Id: <cnf8pg$953$1@news1.transmedia.de>

"Akhila" <akhilau@hotmail.com> schrieb im Newsbeitrag
news:6358fb6c.0411170043.5267d303@posting.google.com...
>   I wish to find hardware information like
>     hard disk type make size
>     ram size
>     monitor info like company
>     mouse type
>     mother board chipset type
>     etc etc...
>
>     also all the names of RPM's installed.

Hi,

never tried to to get sys info with Perl on my Linux system but you should
have a look at the /proc file system. Your script could scan that
information.
According the RPMs: I am pretty sure that there is an RPM command which
lists the packages (although I can't recall it). Simply call it, direct its
output into a temporary file and then read the file from your script.

Cheers,
Detlef.

--
D. Marxsen, TD&DS GmbH
detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)




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

Date: Wed, 17 Nov 2004 11:53:58 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: How to get sytem/hardware information?
Message-Id: <cnfae8$24c$1@nntp.fujitsu-siemens.com>

D. Marxsen wrote:
> "Akhila" <akhilau@hotmail.com> schrieb im Newsbeitrag
> news:6358fb6c.0411170043.5267d303@posting.google.com...
>=20
>>  I wish to find hardware information like
>>    hard disk type make size
>>    ram size
>>    monitor info like company
>>    mouse type
>>    mother board chipset type
>>    etc etc...
>>
>>    also all the names of RPM's installed.
>=20
>=20
> Hi,
>=20
> never tried to to get sys info with Perl on my Linux system but you sho=
uld
> have a look at the /proc file system. Your script could scan that
> information.
> According the RPMs: I am pretty sure that there is an RPM command which=

> lists the packages (although I can't recall it). Simply call it, direct=
 its
> output into a temporary file and then read the file from your script.

simply
open(RPM, "rpm -qa |") or die "$0: cannot start rpm\n";
while (<RPM>) {
     chomp;
     print "Package $_ is installed\n";
}

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: 17 Nov 2004 06:15:42 GMT
From: Jahagirdar Vijayvithal S <FILTERjvsSPAM@india.ti.com>
Subject: Managing PERL5LIB with multiple perl installation
Message-Id: <cneqae$k6n$1@home.itg.ti.com>

The default global installation of perl here is 5.005_03

I have installed v5.8.4 locally as a higher version was needed for some
of the modules i am using.

Now I need to constantly switch the value of PERL5LIB enviornment
variable depending on wether I am using my local scripts or scripts
developed by others . Is there a way to automate this without changing
my perl scripts?

Regards
Jahagirdar Vijayvithal S




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

Date: 17 Nov 2004 07:46:29 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Managing PERL5LIB with multiple perl installation
Message-Id: <Xns95A4120DF2088castleamber@130.133.1.4>

Jahagirdar Vijayvithal S wrote:

> The default global installation of perl here is 5.005_03
> 
> I have installed v5.8.4 locally as a higher version was needed for some
> of the modules i am using.
> 
> Now I need to constantly switch the value of PERL5LIB enviornment
> variable depending on wether I am using my local scripts or scripts
> developed by others . Is there a way to automate this without changing
> my perl scripts?

What breaks under 5.8.4?

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Wed, 17 Nov 2004 09:52:16 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: OPEN command
Message-Id: <s3ukp0140icp3h5ma6rbl1pfo2546fg252@4ax.com>

On Tue, 16 Nov 2004 08:47:17 GMT, Soxos <soxos@libero.it> wrote:

>I'm sorry, my question didn't follow the netiquette, but, as I just saw,  

As a side note this post doesn't either: please provide relevant
quotations (hopefully trimmed down to a minimum) when replying.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 17 Nov 2004 02:06:56 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: problems using taint to check an array be created by cgi
Message-Id: <Xns95A3D6CC49744asu1cornelledu@132.236.56.8>

phill hw <phill@mywebstuff.com> wrote in
news:pan.2004.11.16.23.05.10.55129@mywebstuff.com: 

> Am Mon, 15 Nov 2004 23:43:05 +0000 schrieb A. Sinan Unur:
> 
>> phill hw <phill@mywebstuff.com> wrote in
>> news:pan.2004.11.15.21.40.33.966125@mywebstuff.com: 

 ...
>>> Pseudo CGI FORM:
>>> <FORM>
>>> <input type="text" name="s" value="aslakslad1231">
>>> <p><input type="checkbox" name="sport" value="1">Football</p>
>>> <p><input type="checkbox" name="sport" value="2">Basketball</p>
>>> <p><input type="checkbox" name="sport" value="3">Hockey</p>
>>> <SUBMIT BUTTON>
>>> </FORM>
>> 
>> May I suggest that this is probably not a good way to set up the
>> form? Life would probably be easier if you had, e.g.
>> 
>> <p><input type="checkbox" name="sport" value="Hockey">Hockey</p>

 ...

> My code: 
> my ($s) = $query->param('s') =~ /^([\w]+)$/ if $query->param('s');
> 
> is from the perl cookbook
> http://www.hk8.org/old_web/linux/cgi/ch08_04.htm so I consider it safe
> as I am very restrictive on params. 

On the other hand, using that page is tantamount to stealing from the 
authors. Please don't use those pages, and complain loudly when you 
encounter them. The authors of these books need to eat too.

And, it does not change my opinion that the line above is too long, 
unnecassarily uses [\w+] etc.

> I have to admit your method reads more clearly as the action on the 
> undefined $s is immediately apparent. 

It is something I learned reading this group. I would rather read

> my $s = $query->param('s');
> 
> if(defined $s and $s =~ /^(\w+)$/) {
>     $s = $1;
> } else {
>     $s = '';
> }

than the method you have above.

> I will test your method:
> 
> use Data::Dumper;
> 
> my %valid = map { $_ => 1 } qw(Basketball Football Hockey);
> my @sports = qw(Basketball Hockey /etc/password);
> @sports = map { $valid{$_} ? ($_) = ( $_ =~ /^(.+)$/ ) : '' } @sports;
> 
> print Dumper \@sports;
> 
> but what concerns me here is that the values are stored in the cgi
> script which I find hard to maintain. That is why I only pass numberic
> values back because they are then matched to values in a db. Hockey,
> Football and Hockey are easy examples.

But you are going to maintain a mapping between those values and the actual 
names anyway.
 
> What about if my form looked like:
> 
> Which of the following have you backed up?
> <p><input type="checkbox" name="passwd" value="/etc/passwd">etc/p>
> <p><input type="checkbox" name="passwd"
> value="/var/mysql.users">mysql/p> <p><input type="checkbox"
> name="passwd" value="/etc/pppoe.secrets">pppoe/p> 

Well, so long as those were the valid inputs, then you would untaint 
against them. I do not see what difference it makes in terms of untainting. 
By untainting, you are making sure that the input you are receiving is 
something you are expecting and know how to deal with in your script. So, 
no one help you if, after verifying that the user sent the input 
'/etc/passwd', decide to echo the contents of that file. The taint 
mechanism makes sure you won't inadvertently do so.

>>Again, \d is a character class of its own. And, by the way, is 
>>98732733288272727377474665522241131323263848292939994987287349823897123
>>2838 
>>12384732872398479283748237498237462134732647362472364872364873264872642
>>3444 23424 a valid value for sports?
> 
> Opps, I really do need to check the length! Thanks for pointing that
> out. 

More than just length, there must be rule that tells you exactly which 
numbers are valid, but length is a consideration too.

Sinan.


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

Date: Wed, 17 Nov 2004 03:30:53 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: problems using taint to check an array be created by cgi
Message-Id: <2vvre4F2ornupU1@uni-berlin.de>

phill hw wrote:
> If I use the following script, I cannot use the data contained in the @sports array
> as it is still considered tainted.
> 
> #!/usr/bin/perl -Tw
> 
> use strict;
> use CGI qw/:standard :html3/;
> use CGI::Carp 'fatalsToBrowser';
> 
> if (param())
> {
>  my ($query) = new CGI;
>  my ($s) = $query->param('s') =~ /^([\w]+)$/ if $query->param('s');
>  my (@sports) = $query->param('sports')=~ /^([\d]+)$/ if $query->param('sports');

The m// operator shall be applied to a string, not a list or array.

> How can I correctly parse the @sports array to allow for numbers only without
> having to construct a second array?

You need to untaint each element separately. The map() function comes to 
mind:

     my @sports = map { /^(\d+)$/ } $q->param('sport');

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


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

Date: 17 Nov 2004 04:17:02 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: problems using taint to check an array be created by cgi
Message-Id: <Xns95A3ECDB3ED9Fasu1cornelledu@132.236.56.8>

phill hw <phill@mywebstuff.com> wrote in
news:pan.2004.11.15.21.40.33.966125@mywebstuff.com: 

>  my ($s) = $query->param('s') =~ /^([\w]+)$/ if $query->param('s');

See http://tinyurl.com/4vr53

Sinan


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

Date: Tue, 16 Nov 2004 21:24:55 -0600
From: "Jerry Preston" <g-preston1@ti.com>
Subject: regex - to simple to see?
Message-Id: <cnega7$dqo$1@home.itg.ti.com>

I am trying to breakdown the following line:

SPLIT #1:--> XXXXXXX... .......... .....

              ^       ^^^^^^^^^^     ^^^^^^^^^   ^^^^^

I want the 1, XXXXXXX..., .......... and  .....

I am using:

        $line[ 0 ] =~ /SPLIT #(\d+):-->\s+(\w{10})\s+(\w{10})\s+(\w{5})/;

and I am only getting the "1".  I do not see what I am doing wrong.

I know it is simple but what am I missing?



Thanks,



Jerry





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

Date: Tue, 16 Nov 2004 22:05:37 -0600
From: "Jerry Preston" <g-preston1@ti.com>
Subject: Re: regex - to simple to see?
Message-Id: <cneimh$f5n$1@home.itg.ti.com>

OK!

$line[ 0 ] = "SPLIT #1:--> XXXXXXX... .......... .....";
This      $line[ 0 ] =~ /SPLIT #(\d+):-->\s+(\w{7})/; gives
$1 = "XXXXXXX", but I need to get all of the "." as well.
I know the X & . any combination are in the lengths of 10, 10 and 5.
Sometimes there are space in the blocks.

Why can I not get the "." included ?

Thanks,

Jerry

"Jerry Preston" <g-preston1@ti.com> wrote in message
news:cnega7$dqo$1@home.itg.ti.com...
> I am trying to breakdown the following line:
>
> SPLIT #1:--> XXXXXXX... .......... .....
>
>               ^       ^^^^^^^^^^     ^^^^^^^^^   ^^^^^
>
> I want the 1, XXXXXXX..., .......... and  .....
>
> I am using:
>
>         $line[ 0 ] =~ /SPLIT #(\d+):-->\s+(\w{10})\s+(\w{10})\s+(\w{5})/;
>
> and I am only getting the "1".  I do not see what I am doing wrong.
>
> I know it is simple but what am I missing?
>
>
>
> Thanks,
>
>
>
> Jerry
>
>
>




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

Date: 17 Nov 2004 04:23:54 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: regex - to simple to see?
Message-Id: <Xns95A3EE056456Casu1cornelledu@132.236.56.8>

"Jerry Preston" <g-preston1@ti.com> wrote in
news:cneimh$f5n$1@home.itg.ti.com: 

> $line[ 0 ] = "SPLIT #1:--> XXXXXXX... .......... .....";
> This      $line[ 0 ] =~ /SPLIT #(\d+):-->\s+(\w{7})/; gives
> $1 = "XXXXXXX", but I need to get all of the "." as well.
> I know the X & . any combination are in the lengths of 10, 10 and 5.
> Sometimes there are space in the blocks.


use strict;
use warnings;

use Data::Dumper;

my $s = 'SPLIT #1:--> XXXXXXX... .......... .....';

my @matches = ($s =~ /^SPLIT #(\d+):-->\s+(\S+)\s+(\S+)\s+(\S+)\s*$/);
print Dumper \@matches;

D:\Home> perl t.pl
$VAR1 = [
          '1',
          'XXXXXXX...',
          '..........',
          '.....'
        ];

> Why can I not get the "." included ?

I am not sure. Are you forgetting that . is special in regexes?

Sinan.


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

Date: 17 Nov 2004 04:27:42 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: regex - to simple to see?
Message-Id: <Xns95A3EEAA4C548asu1cornelledu@132.236.56.8>

"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in 
news:Xns95A3EE056456Casu1cornelledu@132.236.56.8:

> "Jerry Preston" <g-preston1@ti.com> wrote in
> news:cneimh$f5n$1@home.itg.ti.com: 
> 
>> $line[ 0 ] = "SPLIT #1:--> XXXXXXX... .......... .....";
>> This      $line[ 0 ] =~ /SPLIT #(\d+):-->\s+(\w{7})/; gives
>> $1 = "XXXXXXX", but I need to get all of the "." as well.
>> I know the X & . any combination are in the lengths of 10, 10 and 5.
>> Sometimes there are space in the blocks.

I missed the last sentence above in my response before.

use strict;
use warnings;

use Data::Dumper;

my $s = 'SPLIT #1:--> XXXX XX... .......... .....';

my @matches = ($s =~ /^SPLIT #(\d+):-->\s+(.{10})\s+(.{10})\s+(.{5})\s*$/);
print Dumper \@matches;

__END__

D:\Home> perl t.pl
$VAR1 = [
          '1',
          'XXXX XX...',
          '..........',
          '.....'
        ];


Sinan.


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

Date: Tue, 16 Nov 2004 22:21:24 -0600
From: "Jerry Preston" <g-preston1@ti.com>
Subject: Re: regex - to simple to see?
Message-Id: <cnejk5$fmi$1@home.itg.ti.com>

OK!

This works great!!!

        $line[ 0 ] =~ /SPLIT
#(\d+):-->\s+([\w|\W]{10})\s+([\w|\W]{10})\s+([\w|\W]{5})/;

Jerry


"Jerry Preston" <g-preston1@ti.com> wrote in message
news:cneimh$f5n$1@home.itg.ti.com...
> OK!
>
> $line[ 0 ] = "SPLIT #1:--> XXXXXXX... .......... .....";
> This      $line[ 0 ] =~ /SPLIT #(\d+):-->\s+(\w{7})/; gives
> $1 = "XXXXXXX", but I need to get all of the "." as well.
> I know the X & . any combination are in the lengths of 10, 10 and 5.
> Sometimes there are space in the blocks.
>
> Why can I not get the "." included ?
>
> Thanks,
>
> Jerry
>
> "Jerry Preston" <g-preston1@ti.com> wrote in message
> news:cnega7$dqo$1@home.itg.ti.com...
> > I am trying to breakdown the following line:
> >
> > SPLIT #1:--> XXXXXXX... .......... .....
> >
> >               ^       ^^^^^^^^^^     ^^^^^^^^^   ^^^^^
> >
> > I want the 1, XXXXXXX..., .......... and  .....
> >
> > I am using:
> >
> >         $line[ 0 ] =~ /SPLIT
#(\d+):-->\s+(\w{10})\s+(\w{10})\s+(\w{5})/;
> >
> > and I am only getting the "1".  I do not see what I am doing wrong.
> >
> > I know it is simple but what am I missing?
> >
> >
> >
> > Thanks,
> >
> >
> >
> > Jerry
> >
> >
> >
>
>




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

Date: Wed, 17 Nov 2004 07:01:13 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: regex - to simple to see?
Message-Id: <cnesqr$ba5$1@news.simnet.is>

"Jerry Preston" <g-preston1@ti.com> wrote in message
news:cnejk5$fmi$1@home.itg.ti.com...
> OK!
>
> This works great!!!
>
>         $line[ 0 ] =~ /SPLIT
> #(\d+):-->\s+([\w|\W]{10})\s+([\w|\W]{10})\s+([\w|\W]{5})/;

\w means a word character (no fullstops or spaces included)
\W means characters that are not in \w
[\w\W] means any character
[\w|\W] means any character and doubly so if |
 . means any character
 .{10} means any 10 characters

so :
#(\d+):-->\s+(.{10})\s+(.{10})\s+(.{5})/;


gnari





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

Date: 17 Nov 2004 10:01:41 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: regex - to simple to see?
Message-Id: <yzd3bz8df2i.fsf@invalid.net>


"Jerry Preston" <g-preston1@ti.com> writes:
> I am trying to breakdown the following line:
> 
> SPLIT #1:--> XXXXXXX... .......... .....
> 
>               ^       ^^^^^^^^^^     ^^^^^^^^^   ^^^^^

I suppose the above line is an attempt to show which parts of the
input line you're interested in extracting. Note that if you use
tab characters and/or a proportional font when you're writing, what
looks good to you may turn out wrong when others read it.
(If others use a proportional font when reading, that is not your
fault, of course.)

The below is what looks good for a fixed-width font:

> SPLIT #1:--> XXXXXXX... .......... .....
> 
>        ^     ^^^^^^^^^^ ^^^^^^^^^  ^^^^^


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

Date: 17 Nov 2004 01:44:34 -0800
From: notruf_1102003@yahoo.de (Gerhard M)
Subject: Re: regex - to simple to see?
Message-Id: <942c5b0d.0411170144.30b6a0e@posting.google.com>

"Jerry Preston" <g-preston1@ti.com> wrote in message news:<cnega7$dqo$1@home.itg.ti.com>...
> I am using:
> 
>         $line[ 0 ] =~ /SPLIT #(\d+):-->\s+(\w{10})\s+(\w{10})\s+(\w{5})/;
> 
> and I am only getting the "1".  I do not see what I am doing wrong.

What are you doing?
  if ($line[0] =~ /..../) ...

Do you use $1...$4 or maybe @list=($line[0]=~/.../)? 
So please provide some more code. 

Gerhard


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

Date: 17 Nov 2004 02:17:26 -0800
From: notruf_1102003@yahoo.de (Gerhard M)
Subject: Re: Search for string and return file name
Message-Id: <942c5b0d.0411170217.e5f81e8@posting.google.com>

"Örjan Johansson" <misc@actitud.NOSPAM.se> wrote in message news:<9Jwmd.122063$dP1.422386@newsc.telia.net>...
> Hi all!
> 
> I'm trying to figure out how to go through all files with a certain 
> extension in a directory, search for a string and return the names of the 
> files that contains the string. I have written scripts before that opens a 
> single file for reading and writing, but have no clue how to go through all 
> files in a folder, like a wildcard  *.log kind of thing. Any pointers?
> 
> TIA,
> Örjan

if you're using ...IX try 
  grep -l "text" *.log

using perl try glob
foreach $file (glob "*.log") {
 open FH,$file;
 while (<FH>) {
   if (m/text/) {print $file; last; }
 }
 close FH;
}


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

Date: Tue, 16 Nov 2004 21:48:18 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: SQL ERROR
Message-Id: <1100659785.711576@nntp.acecape.com>

"Tyler" <tyler.bowler@gmail.com> wrote in message
news:ca5e307a.0411150751.5ff256f8@posting.google.com...
> I am trying to prepare an SQL statement to read a database.  I am
> using DBI v1.41  However this code works on an older server that is
> running DBI v.1.14.  I am putting my values into an array and then
> comparing them in the Where clause.  Should I have to dereference my
> array that I am putting my values into?  I have tried to deference by
> doing the following.  @@arrayname[0] , @arrayname->[0] and
> $$arrayname.


first off, i am new here (to Perl) so take everything i say with a grain of
salt.  but i have finally successfully made my first few modules, and they
all used DBI quite heavily.

also you definitly you want to put up as others haev already said, a working
snippet of your code that runs by itself and duplicates your
error...afterall, is the problem in your prepare statement?  hard to tell
without your code.

but i will say this, i don't understand what you are doing with your array.

if you have @arrayname (an array of elements to be used later in your DBI
search)
then you access each variable with   $arrayname[x]    where x = the index of
the array you are getting...
and of other use:

$arraytot     = @arrayname;  (returns the total # of elements in @arrayname)
$arraylast    = $#arrayname;  (returns the LAST index elements in
@arrayname...so if $arraytot = 7, $arraylast would = 6)

you can find all this in "perlfaq4"

as for dereferencing, that is a different bird.  and unless your originating
array is coming in as a reference to that array, not a part of this.

again please remember, am still new to perl myself, so some of my terminolgy
might be incorrect.  but hope i was somewhat helpfull.

daniel






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

Date: Tue, 16 Nov 2004 23:01:24 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: SQL ERROR
Message-Id: <1100664173.403547@nntp.acecape.com>

"daniel kaplan" <nospam@nospam.com> wrote in message
news:1100659785.711576@nntp.acecape.com...
[...a bunch of stuff...]

i meant also to say, but forgot, when you look at this error you mentioned:

"DBD::CSV::st execute failed: dbih_getcom handle
DBD::CSV::Statement=HASH(0x1e849
ec) is not a DBI handle (has no magic) at
C:/Perl/site/lib/SQL/Statement.pm line
 164."

i can't say it's related to the array part of your question, and not the DBI
module.  but is it possible, and (as much as that is hated here) i am just
so purely throw sh*t against the wall....is it possible that not using the
array structure properly, the DBI statement you prepare with the array, is
so improperly constructed that you get the error because of that, and not
the DBI module?


one test would be to hardcode in your module the first variable you want to
use in the WHERE clause (i.e. "Male"), and see if you still get the error?

daniel




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

Date: Wed, 17 Nov 2004 09:52:17 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Time::HiRes module and timing a command...
Message-Id: <c44mp0dav9cmhnhtvvq25qdo39itsnrth1@4ax.com>

On 16 Nov 2004 09:54:08 -0800, adam_cheney@hotmail.com (Adam) wrote:

>ClearCase. Searching for ways to do this lead me to the Time::HiRes
>module. This isn't present on our system (Solaris), so I downloaded

OTOH Time::HiRes is in the core modules as of recent enough perls. So
installing one may well be an overkill for this particular task only,
but you still may want to do it anyway...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

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


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