[28924] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 168 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 26 19:17:24 2007

Date: Fri, 23 Feb 2007 18:09:08 -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           Fri, 23 Feb 2007     Volume: 11 Number: 168

Today's topics:
    Re: fork()-ing questions <1usa@llenroc.ude.invalid>
        Get xs type from xml node? lfbayer@my-deja.com
    Re: Help with search and replace <pradeep.bg@gmail.com>
    Re: Help with search and replace <someone@example.com>
    Re: Help with search and replace <pradeep.bg@gmail.com>
    Re: Help with search and replace <glex_no-spam@qwest-spam-no.invalid>
    Re: Help with search and replace <jurgenex@hotmail.com>
        How to boost performance of my crude script? <poo@pee.com>
    Re: How to boost performance of my crude script? <1usa@llenroc.ude.invalid>
    Re: How to boost performance of my crude script? <wahab-mail@gmx.de>
    Re: new method to test Perl code <spamtrap@dot-app.org>
    Re: Regex: Why is overreaching necessary? <shannon.jacobs@gmail.com>
    Re: Text::CSV and Mysql azzi.george@gmail.com
    Re: Tool to create Perl based scripts <bpatton@ti.com>
    Re: Using Substr and Regular expressions. <1usa@llenroc.ude.invalid>
    Re: Using Substr and Regular expressions. <kent.westmoreland@gmail.com>
    Re: Using Substr and Regular expressions. <damercer@comcast.net>
    Re: which is more powerfull ? <kst-u@mib.org>
    Re: which is more powerfull ? <marcumbill@bellsouth.net>
    Re: which is more powerfull ? <greg.ferguson@icrossing.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 24 Feb 2007 00:51:19 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: fork()-ing questions
Message-Id: <Xns98E0C9F848C0Basu1cornelledu@127.0.0.1>

"Monty" <dale.schmitz@offutt.af.mil> wrote in news:1172179794.802618.104920
@v45g2000cwv.googlegroups.com:

> I'm going to end this discussion right here.  Thanks again to all!

On the UseNet, you don't get to decide when the discussion ends.

Sinan


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

Date: 23 Feb 2007 14:34:45 -0800
From: lfbayer@my-deja.com
Subject: Get xs type from xml node?
Message-Id: <1172270084.913898.226550@a75g2000cwd.googlegroups.com>

I have an xml document and an xsd.  After parsing the xml document I
would like to be able to get the type defined in the schema for a
given node (ie: xs:string, xs:boolean, etc.).

What perl modules, if any, provide this?

I would think that a validating parser would have this information
when it parsed it but I can't find any modules that provide this
through the API.

Thanks
 - Leo



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

Date: 23 Feb 2007 12:07:02 -0800
From: "Deepu" <pradeep.bg@gmail.com>
Subject: Re: Help with search and replace
Message-Id: <1172261222.684856.141180@a75g2000cwd.googlegroups.com>

> > Thanks for the reply..
> What reply? I don't see any. What are you talking about?
>
I will try to post the message correctly in future..sorry about that

I tried the code as given below:

#!/usr/local/bin/perl

my ($search,$replace) = @ARGV;

my $baseDir = "/user/bin";

opendir (DIR, $baseDir) || die "Can't open $baseDir - $!\n";

# -- Perform the operation for each DIR
foreach my $simdir (readdir DIR) {

# -- If it is a directory and ends with 1-6
  if (-d "$baseDir/$subdir" && $subdir =~ /(1|2|3|4|5|6)$/) {

# -- If the directory has subdirectories do the following operation
    opendir (SUBDIR, "$baseDir"."/$subdir"   ) || die "Can't open
$subdir - $!\n";

# -- Perform the operation for each of the sub-subdirectory
    while ( my $subsubdir = readdir (SUBDIR)) {
      if (-d "$baseDir/$subdir/$subsubdir" && $subsubdir =~ /(\d)$/) {
	chomp $subsubdir;
	if (-e "$baseDir/$subdir/$subsubdir/run.log")
	  {
	    my $temp = "$baseDir"."/$subdir/$subsubdir/File.log";
	    open (my $fh,'>',$temp) || die "Can't open $temp -$!\n";

	    while (<$fh>){
	      s/$search/$replace/g;
	    }
	    close ($fh);
	  }
      }
    }
    close SUBDIR;

# -- Else perform the same operation as before without the sub-
subdirectory
    if (-e "$baseDir/$subdir/run.log")
      {
	my $temp = "$baseDir"."/$subdir/File.log";
	open (my $fh,'>',$temp) || die "Can't open $temp -$!\n";

	while (<$fh>){
	  s/$search/$replace/g;
	}
	close ($fh);
      }
  }
}

close DIR;


But when i use this File.log becomes an empty file.

Basically File.log is present in $baseDir/subdir/ or $baseDir/$subdir/
$subsubdir

Example:

under /user/bin/ there are:

DIR1 - File.log
DIR2 - SUBDIR1 - File.log
DIR3 - SUBDIR1 - File.log
     - SUBDIR2 - File.log
DIR4 - SUBDIR1 - File.log

File.log has:
THIS IS AN ERROR TEST
THIS IS A TEST
THIS IS NOT A TEST
THIS IS AN ERROR

I need to replace ERROR with FAIL or sometimes someother word so am
trying to pass as arguments





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

Date: Fri, 23 Feb 2007 20:54:46 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Help with search and replace
Message-Id: <qwIDh.131946$Oa.37360@edtnps82>

Deepu wrote:
>>>Thanks for the reply..
>>What reply? I don't see any. What are you talking about?
>>
> I will try to post the message correctly in future..sorry about that
> 
> I tried the code as given below:
> 
> #!/usr/local/bin/perl

Missing:

use warnings;
use strict;

> my ($search,$replace) = @ARGV;
> 
> my $baseDir = "/user/bin";
> 
> opendir (DIR, $baseDir) || die "Can't open $baseDir - $!\n";
> 
> # -- Perform the operation for each DIR
> foreach my $simdir (readdir DIR) {
             ^^^^^^^
You variable should be named $subdir, at least that is the name you are using
everywhere else in this program.


> # -- If it is a directory and ends with 1-6
>   if (-d "$baseDir/$subdir" && $subdir =~ /(1|2|3|4|5|6)$/) {

You don't need capturing parentheses and a character class would be more
efficient:

   if (-d "$baseDir/$subdir" && $subdir =~ /[123456]$/) {


> # -- If the directory has subdirectories do the following operation
>     opendir (SUBDIR, "$baseDir"."/$subdir"   ) || die "Can't open
> $subdir - $!\n";
> 
> # -- Perform the operation for each of the sub-subdirectory
>     while ( my $subsubdir = readdir (SUBDIR)) {
>       if (-d "$baseDir/$subdir/$subsubdir" && $subsubdir =~ /(\d)$/) {
> 	chomp $subsubdir;
> 	if (-e "$baseDir/$subdir/$subsubdir/run.log")
> 	  {
> 	    my $temp = "$baseDir"."/$subdir/$subsubdir/File.log";
> 	    open (my $fh,'>',$temp) || die "Can't open $temp -$!\n";
> 
> 	    while (<$fh>){

You are trying to READ from a file opened WRITEONLY.  This will not work.


> 	      s/$search/$replace/g;

You are trying to modify the line in memory however this has no effect on the
file itself because you are not storing the line antwhere.


> 	    }
> 	    close ($fh);
> 	  }
>       }
>     }
>     close SUBDIR;
> 
> # -- Else perform the same operation as before without the sub-
> subdirectory
>     if (-e "$baseDir/$subdir/run.log")
>       {
> 	my $temp = "$baseDir"."/$subdir/File.log";
> 	open (my $fh,'>',$temp) || die "Can't open $temp -$!\n";
> 
> 	while (<$fh>){
> 	  s/$search/$replace/g;
> 	}
> 	close ($fh);
>       }
>   }
> }
> 
> close DIR;
> 
> 
> But when i use this File.log becomes an empty file.
> 
> Basically File.log is present in $baseDir/subdir/ or $baseDir/$subdir/
> $subsubdir
> 
> Example:
> 
> under /user/bin/ there are:
> 
> DIR1 - File.log
> DIR2 - SUBDIR1 - File.log
> DIR3 - SUBDIR1 - File.log
>      - SUBDIR2 - File.log
> DIR4 - SUBDIR1 - File.log
> 
> File.log has:
> THIS IS AN ERROR TEST
> THIS IS A TEST
> THIS IS NOT A TEST
> THIS IS AN ERROR
> 
> I need to replace ERROR with FAIL or sometimes someother word so am
> trying to pass as arguments

Something like this should work (UNTESTED):

#!/usr/local/bin/perl
use warnings;
use strict;
use File::Basename;

my ( $search, $replace ) = @ARGV;

my @files = (
    glob( "/user/bin/*/run.log" ),
    glob( "/user/bin/*[123456]/*/run.log" ),
    );

for my $file ( @files ) {
    my $new = dirname( $file ) . '/File.log';
    open my $in,  '<', $file or die "Cannot open '$file' $!";
    open my $out, '>', $new  or die "Cannot open '$new' $!";
    while ( <$in> ) {
        s/\Q$search\E/$replace/g;
        print $out;
        }
    }

__END__





John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: 23 Feb 2007 13:23:33 -0800
From: "Deepu" <pradeep.bg@gmail.com>
Subject: Re: Help with search and replace
Message-Id: <1172265812.950780.149640@t69g2000cwt.googlegroups.com>

> Something like this should work (UNTESTED):
>
> #!/usr/local/bin/perl
> use warnings;
> use strict;
> use File::Basename;
>
> my ( $search, $replace ) = @ARGV;
>
> my @files = (
>     glob( "/user/bin/*/run.log" ),
>     glob( "/user/bin/*[123456]/*/run.log" ),
>     );
>
> for my $file ( @files ) {
>     my $new = dirname( $file ) . '/File.log';
>     open my $in,  '<', $file or die "Cannot open '$file' $!";

How can i try to read and write to the same file?

>     open my $out, '>', $new  or die "Cannot open '$new' $!";
>     while ( <$in> ) {
>         s/\Q$search\E/$replace/g;
>         print $out;
>         }
>     }
>
> __END__
>



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

Date: Fri, 23 Feb 2007 16:16:54 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Help with search and replace
Message-Id: <45df67cf$0$10311$815e3792@news.qwest.net>

Deepu wrote:
>> Something like this should work (UNTESTED):
Ahhh. who wrote this reply?  Leave that in place.
>>
>> #!/usr/local/bin/perl
>> use warnings;
>> use strict;
>> use File::Basename;
>>
>> my ( $search, $replace ) = @ARGV;
>>
>> my @files = (
>>     glob( "/user/bin/*/run.log" ),
>>     glob( "/user/bin/*[123456]/*/run.log" ),
>>     );
>>
>> for my $file ( @files ) {
>>     my $new = dirname( $file ) . '/File.log';
>>     open my $in,  '<', $file or die "Cannot open '$file' $!";
> 
> How can i try to read and write to the same file?

Tie::File

or write to the new file and rename it to the old.

perldoc -f rename

or use File::Copy or possibly something on
the command line like:

perl -pi -e 's/search/replace/g' /user/bin/*/run.log 
/user/bin/*[123456]/*/run.log

or many more...

Be sure to use a test directory and files, before you
start trashing actual files.

You can find many examples on-line.  Give that a try
or try to figure it out by reading the various FAQs,
before simply replying with another question.


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

Date: Sat, 24 Feb 2007 02:05:47 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Help with search and replace
Message-Id: <%3NDh.32$Xe1.8@trndny01>

Deepu wrote:
>     my $temp = "$baseDir"."/$subdir/$subsubdir/File.log";
>     open (my $fh,'>',$temp) || die "Can't open $temp -$!\n";

Ok, you are opening the file

>     while (<$fh>){

You are reading each line in the file into $_

>       s/$search/$replace/g;

You are replacing something in $_ with something else

>     }

And then throwing it away

>     close ($fh);

> But when i use this File.log becomes an empty file.

Well, you never ever write anything anywhere.

jue

jue 




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

Date: Fri, 23 Feb 2007 17:49:51 -0500
From: DB <poo@pee.com>
Subject: How to boost performance of my crude script?
Message-Id: <qbWdnWQdNpsN8kLYnZ2dnUVZ_tijnZ2d@adelphia.com>

Hi - I admit to being a total hack at perl, but I did get the below
script to work. The problem is that is goes quite slowly.

The code parses a comma delimited text file of approx 250,000 lines and
generates another text file with modified format. For certain lines of
the data, the code must parse again through the same file and I believe
this is why it is slow.

No laughing at my code allowed... I never claimed to be a god
programmer... but can anyone tell me if I could speed things up somehow,
perhaps by loading the file into RAM all at once? Any thoughts welcome.

Thanks! DB



#!/usr/bin/perl
use warnings;

if (-e "output.txt") {
   die "outfile already exists on system";
   }

open (MYFILE, '>>output.txt');

# Print header row
print MYFILE "sku\tdesc\tremark\tprice\tgroup\tcat\twt\ttit\n";

$count=0;
$use="USE"; # define trigger strings
$NLA1="N/L";

$file = 'data.txt'; # open file
open (F, $file) || die ("Could not open $file!");

while ($line = <F>)
{

$count=$count + 1;;
my @fields1 = split(',', $line); # load array

# Initialize output variables
$SKU=$fields1[0]."-".$fields1[1];
$DESC=$fields1[2];
$REMARK="GENERAL ELECTRIC (GE) PART ".$fields1[1];
$PRICE=$fields1[4];
$GROUP="PARTS";
$CAT="GENERAL";
$WEIGHT="1";
$TITLE=$fields1[3];

print "Working on item |$fields1[1]|, length= $description_length, SKU=
$SKU count=$count \n";

$supered="NO";   #initialize

$desc_portion = substr($fields1[2],0,3);
if ($desc_portion eq $use) {  # if supered...
$supered="YES";

$length_leftover = (length($fields1[2])-4); # find the super
$sup_pn = substr($fields1[2],4,$length_leftover);

if ($sup_pn eq $fields1[1]) { #if supers to self
$supered="NO"
}
print "|$fields1[1]| supers to |$sup_pn|... \n";
}

while ($supered eq "YES")

{ #BEGIN SUPERED

   $file2 = 'data.txt';
   open (G, $file2) || die ("Could not open $file!");
   while ($line = <G>)
   {
   my @fields2 = split(',', $line); # Load array


     if ($fields2[1] eq $sup_pn) {  # we find a match

print "Match found! - sup pn: $sup_pn fields21: $fields2[1] supered:
$supered\n";

       $sup_desc_portion = substr($fields2[2],0,3);  # look up
description of super

       $length_leftover2 = (length($fields2[2])-4); # find the super
       $sup_pn2 = substr($fields2[2],4,$length_leftover2);

        if ($sup_desc_portion eq $NLA1)  {  # is NLA
        $supered="NLA";
        print "which is NLA supered: $supered\n";
        $DESCRIPTION=$DESCRIPTION." -  ".$fields2[2]." N/L/A";
        }

        elsif ($sup_desc_portion eq $use)  {  # supers again
        $supered="AGAIN";
        print "which is supers again to $sup_pn2 supered: $supered\n";
        $PRICE=$fields2[4];
        $DESCRIPTION=$DESCRIPTION." -- ".$fields2[2]." SUPERS AGAIN";
        }

        else {  # found it
        $supered="FINAL";
        print "which is supers to $sup_pn price: $fields2[4] supered:
$supered\n";
        $PRICE=$fields2[4];
        $DESCRIPTION=$DESCRIPTION." --- ".$fields2[2];
        }


     } #close we find a match

   } # close while line G

if ($supered eq "YES") {
$supered="NOT_FOUND";
$DESCRIPTION=$DESCRIPTION." - SUPER NOT FOUND";
$PRICE="0.00";
}

print "Done checking supered: $supered\n";

   close (G);


} #END SUPERED

# Output part line
print MYFILE
"$SKU\t$DESCR\t$REMARK\t$PRICE\t$GROUP\t$CATEGORY\t$WEIGHT\t$TIT\n";


} #close while line F

close (F);

close (MYFILE);


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

Date: Sat, 24 Feb 2007 00:14:31 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to boost performance of my crude script?
Message-Id: <Xns98E0C3BA8669asu1cornelledu@127.0.0.1>

DB <poo@pee.com> wrote in 
news:qbWdnWQdNpsN8kLYnZ2dnUVZ_tijnZ2d@adelphia.com:

> Hi - I admit to being a total hack at perl, but I did get the below
> script to work. The problem is that is goes quite slowly.

I haven't yet looked at your script yet, but at first sight, it looks 
very disorganized and does not follow best practices.

> The code parses a comma delimited text file of approx 250,000 lines
> and generates another text file with modified format. For certain
> lines of the data, the code must parse again through the same file and
> I believe this is why it is slow.

 ...

> perhaps by loading the file into RAM all at once?

Depends on how much RAM you have, how many times you have to re-iterate 
through the data and how loaded the system is etc.

On the other hand, if you do have to go through data many times, just 
create an SQLite database to make subsequent lookups faster.

> 
> #!/usr/bin/perl

use strict;

missing.

> use warnings;
> 
> if (-e "output.txt") {
>    die "outfile already exists on system";
>    }

my $output_fn = 'output.txt';

die "'$output_fn' already exists\n" if -e $output_fn;


> open (MYFILE, '>>output.txt');

Why are you opening the file for appending if your program is supposed 
to die if it already exists?

Always, *always* check if open succeded. Use lexical filehandles for 
better scoping:

open $output, '>', $output_fn
   or die "Cannot open '$output_fn' for writing: $!";

> # Print header row
> print MYFILE "sku\tdesc\tremark\tprice\tgroup\tcat\twt\ttit\n";


print $output 
    join("\t", qw( sku desc remark price group cat wt tit )), "\n";


> $count=0;

my $count;

Why do you need this variable? Are you just counting lines? Use $. for 
that.

> $use="USE"; # define trigger strings
> $NLA1="N/L";
> 
> $file = 'data.txt'; # open file
> open (F, $file) || die ("Could not open $file!");
> 
> while ($line = <F>)
> {
> 
> $count=$count + 1;;
> my @fields1 = split(',', $line); # load array

The rest is a mess.

The fact that you don't declare variables in the smallest possible scope 
makes verything really hard to follow. Indentation is a mess. Your code 
is not self explanatory and I cannot figure out what supered means.
 
> # Initialize output variables
> $SKU=$fields1[0]."-".$fields1[1];
> $DESC=$fields1[2];
> $REMARK="GENERAL ELECTRIC (GE) PART ".$fields1[1];
> $PRICE=$fields1[4];
> $GROUP="PARTS";
> $CAT="GENERAL";
> $WEIGHT="1";
> $TITLE=$fields1[3];
> 
> print "Working on item |$fields1[1]|, length= $description_length,
> SKU= $SKU count=$count \n";

Ahem, $description_length is undefined at this point.
 
> $supered="NO";   #initialize
> 
> $desc_portion = substr($fields1[2],0,3);
> if ($desc_portion eq $use) {  # if supered...
> $supered="YES";
> 
> $length_leftover = (length($fields1[2])-4); # find the super
> $sup_pn = substr($fields1[2],4,$length_leftover);

This is insane.

> 
> if ($sup_pn eq $fields1[1]) { #if supers to self
> $supered="NO"
> }
> print "|$fields1[1]| supers to |$sup_pn|... \n";
> }

You print out this message even if $supered is set to 'NO'. More 
insanity.


> while ($supered eq "YES")

You are using a loop when, it looks like, you should be using a 
conditional.

Since I just do not have any idea what you are trying to achieve, and no 
input data, I gave up after trying for 20 minutes to refactor your code.

Please read the posting guidelines for this group.

Sinan


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

Date: Sat, 24 Feb 2007 00:23:57 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: How to boost performance of my crude script?
Message-Id: <ero0td$s4k$1@mlucom4.urz.uni-halle.de>

DB wrote:
> Hi - I admit to being a total hack at perl, but I did get the below
> script to work. The problem is that is goes quite slowly.
> 
> The code parses a comma delimited text file of approx 250,000 lines and
> generates another text file with modified format. For certain lines of
> the data, the code must parse again through the same file and I believe
> this is why it is slow.

 From looking at your *probably really slow*
code, which does sth. like:

     ...
     open FH1, '<single_large_file.txt';
     while( <FH1> ) {

        if( xyz )
           open FH2, '<single_large_file.txt';
           while( <FH2> ) {
              match_something()
           }
           close FH2
        }
     }
     ...

on the same file - while messing (without strict)
with misspelled and uninitialized variable names
(e.g. $DESC, $DESCR, $DESCRIPTION etc.).

I'd guess from looking at your trials you'll have
sth. like a tree structure. So rewrite the whole
thing (good way to learn) -

1) first preprocess the file (read line by line) and
    store it's data (tree) in a hash of hash refs
    or array refs

2) close the file and step through your data
    structures  - to print all out

Regards
Mirco


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

Date: Fri, 23 Feb 2007 15:06:18 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: new method to test Perl code
Message-Id: <m2zm74vdtx.fsf@local.wv-www.com>

dnikolayev@gmail.com writes:

> All of this project is done in Perl.. And this is very strange, that
> Perl community here is not interested in growing this :)

I don't find that strange at all. Stupid ideas don't magically become
less stupid just because they're implemented in Perl.

What possible use would anyone have for a clumsy and limited web interface
to Perl, when the *real thing* is either included with or trivial to install
on any desktop OS you can name?

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: 23 Feb 2007 15:08:56 -0800
From: "shanen" <shannon.jacobs@gmail.com>
Subject: Re: Regex: Why is overreaching necessary?
Message-Id: <1172272136.047653.46400@k78g2000cwa.googlegroups.com>

Thank you for your interest, but I'm trying to make it clear that I'm
willing to leave the issue at this time. It's not actually a piece of
production code...

I do think the new problem might be slightly interesting, but it also
seems complicated and not worth much effort. My latest hypothesis is
that it involves an ordering assumption which is normally preserved.
The original design design of the program assumes that the values in
the search target are in sorted order, and that is still true in the
actual execution of the program. However, my special test data
violates that ordering assumption, and the interesting thing is that
this may somehow allow the flow of control to bypass a critical
branch, or possibly to reenter a later code branch that is normally
skipped.

On Feb 24, 2:24 am, Jim Gibson <jgib...@mail.arc.nasa.gov> wrote:
> In article <1172196516.875062.189...@h3g2000cwc.googlegroups.com>,
>
> Shannon Jacobs <Shannon.Jacobs.nos...@gmail.com> wrote:
>
> Please do not top-post.
>
> > I'm not sure how to take your curiosity, but as I noted, here is a
> > minimal example of a test case for the latest (but not greatest)
> > problem.
>
> >http://shanenj.tripod.com/cgi-bin/procbook0.cgi?a_SEARCH_VALUE=2471%7...
> > rchfields=authornums&sensecase=nocase&sorttype=none&datetype=comp&numorname=au
> > thnums
>
> >http://shanenj.tripod.com/cgi-bin/procbook0.cgi?a_SEARCH_VALUE=2396%7...
> > rchfields=authornums&sensecase=nocase&sorttype=none&datetype=comp&numorname=au
> > thnums
>
> No one is likely to help you without seeing the code behind these
> queries, plus the database on which they are executed. Since, as you
> have previously pointed out, that would require posting a great deal of
> irrelevant code and data, you need to first reduce the problem to the
> minimal amount necessary to reproduce the problem. I suggest that if
> you want additional help, you write a small, self-contained test
> program that demonstrates the problem with your regex. If you can do
> that, someone here will surely be able to help you. It is also possible
> that in doing so, you will discover the source of your problem (and it
> is not likely to be the fact that /2471|2396/ returns different results
> from /2396|2471/).



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

Date: 23 Feb 2007 11:52:38 -0800
From: azzi.george@gmail.com
Subject: Re: Text::CSV and Mysql
Message-Id: <1172260358.898004.199430@s48g2000cws.googlegroups.com>

On Feb 23, 1:58 pm, use...@DavidFilmer.com wrote:
> On Feb 23, 10:14 am, azzi.geo...@gmail.com wrote:
>
> > Thanks, and await for your tested resolution.
>
> Oh, not only are we supposed to fix the problems, but we're supposed
> to test it as well.  Would you like a mocha latte while we're working
> on it?
>
> Tell ya what - how 'bout I just point out a couple of obvious problems
> and let you have another swing at it.
>
> > my @data = Dumper([$csv->fields()]);
>
> You want to know where those [] are coming from?  Well, that's
> where...
>
> > my $sql_start = "INSERT INTO Start VALUES (@data);";
>
> No trailing semicolon on DBI statements.  This ain't a SQL shell.
>
> > else ($line =~ /^STOP/) {
>
> ????  Did you mean elsif (...
>
> > my $sql_stop = "INSERT INTO Stop VALUES (@data);";
>
> Why don't you print that variable out for debugging purposes?  You
> will immediately see the problem caused by trying to load Dumper()
> output straight into the database.  This is your biggest problem.
>
> --
> The best way to get a good answer is to ask a good question.
> David Filmer (http://DavidFilmer.com)

Wanted to give as much information as possible. And greatly appreciate
you clearing up that my issue was that the [ ] were put into the > >
my @data = Dumper([$csv->fields()]); statement! This helped a
tremendous amount as had used someone else's code for that aspect of
it.

Pierre



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

Date: Thu, 22 Feb 2007 07:36:51 -0600
From: "Billy Patton" <bpatton@ti.com>
Subject: Re: Tool to create Perl based scripts
Message-Id: <erk69k$8ip$1@home.itg.ti.com>

I prefer perl above all other languages. But sometimes it's not the best 
language for the job.
If you are simply looking for keywords within a file I would suggest using 
csh,sh,ksh,bash or zsh to do simple grep commands.
It's very fast.  If, your on a unix box,  cygwin,  mingw or mac osx.

"IJALAB" <balaji.draj@gmail.com> wrote in message 
news:1171968728.504714.197850@v33g2000cwv.googlegroups.com...
> Hi All,
>
> I have to automate a lot of validation scripts in Perl. Is there a
> simple way/tool to do the same. basically log files will be created
> and i have to look for certain keywords in the log files and make a
> decision to validate the tests. I am just looking to save time in
> automating my perl writing task.
> any pointers welcome..thanks a lot
>
> regards
> bala
> 




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

Date: Fri, 23 Feb 2007 20:37:15 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Using Substr and Regular expressions.
Message-Id: <Xns98E09EE45BDFasu1cornelledu@127.0.0.1>

"Manish" <marora@gmail.com> wrote in
news:1172256682.497739.287630@8g2000cwh.googlegroups.com: 

> On Feb 23, 12:54 pm, "Brian McCauley" <nobul...@gmail.com> wrote:
>> On Feb 23, 3:19 pm, "Manish" <mar...@gmail.com> wrote:

 ...

> 
>> > my ($num, $name) = ($d =~ m"$pat");
>>
>> Although the m operator _allows_ you to use non-standard regex
>> delimiters,  IMHO, it aids clairy not to do so for no reason:
>>
> 
> sorry, couldn't follow *use non-standard regex ...*, can you explain a
> little more?
> 
>> my ($num, $name) = $d =~ /$pat/;

Using the " characters as a delimeter in the match operator above is 
non-standard. While there is nothing preventing you from using that 
character, it is better not get too carried away and stick with the most 
common case unless there is a very good reason to do so. Hence, things 
are clearer if you use /$pat/ rather than m"$pat" which looks to me like 
"spat" and makes it harder to read your code.

If what is between the delimeters contains a bunch of / characters, it 
is common to use braces of exclamation marks as delimiters.

If you do not want variable interpolation, you should use single quotes 
as delimiters.

Sinan


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

Date: 23 Feb 2007 12:51:22 -0800
From: "kent.westmoreland@gmail.com" <kent.westmoreland@gmail.com>
Subject: Re: Using Substr and Regular expressions.
Message-Id: <1172263881.680949.20480@k78g2000cwa.googlegroups.com>

On Feb 23, 10:21 am, "Dan Mercer" <damer...@comcast.net> wrote:

> My guess is that if you have to ask this question,  you're not ready
> to program in perl yet.  A number of solutions are available:
>
>     use strict;
>     use warnings;
>     my $num;
>     my $name;
>     ($num,$name) = (split /_/,$ARGV[0])[1,2];
>
> is just one of many possibilities.
>
> Dan Mercer
>

Dan,

Your blunt response "My guess is that if you have to ask this
question,  you're not ready to program in perl yet." is not far from
the truth.

I only recently started to "learn" perl ( 2 days ago).  I am modifying
a script that was given to me to preform a specific task.  I wanted to
make the script easier to use but I was not having much luck with the
tutorials I found on the web.  I figured posting here was a great
place to find information that I required.

I have tried both Manish and your suggestions ( both of which work
fine) with a few modifications.

Some of my main holdbacks on perl where syntactical ( I actually had
something similar to your version using the split function but only
one variable).

Anyway, thanks to everyone for all of your examples and help!  Now I
have a lot of things to research.
Kent






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

Date: Fri, 23 Feb 2007 17:24:15 -0600
From: "Dan Mercer" <damercer@comcast.net>
Subject: Re: Using Substr and Regular expressions.
Message-Id: <kemdnfnfze486kLYnZ2dnUVZ_qqrnZ2d@comcast.com>


<kent.westmoreland@gmail.com> wrote in message news:1172263881.680949.20480@k78g2000cwa.googlegroups.com...
: On Feb 23, 10:21 am, "Dan Mercer" <damer...@comcast.net> wrote:
:
: > My guess is that if you have to ask this question,  you're not ready
: > to program in perl yet.  A number of solutions are available:
: >
: >     use strict;
: >     use warnings;
: >     my $num;
: >     my $name;
: >     ($num,$name) = (split /_/,$ARGV[0])[1,2];
: >
: > is just one of many possibilities.
: >
: > Dan Mercer
: >
:
: Dan,
:
: Your blunt response "My guess is that if you have to ask this
: question,  you're not ready to program in perl yet." is not far from
: the truth.
:
: I only recently started to "learn" perl ( 2 days ago).  I am modifying
: a script that was given to me to preform a specific task.  I wanted to
: make the script easier to use but I was not having much luck with the
: tutorials I found on the web.  I figured posting here was a great
: place to find information that I required.
:
: I have tried both Manish and your suggestions ( both of which work
: fine) with a few modifications.
:
: Some of my main holdbacks on perl where syntactical ( I actually had
: something similar to your version using the split function but only
: one variable).
:
: Anyway, thanks to everyone for all of your examples and help!  Now I
: have a lot of things to research.
: Kent

Try SAMS "Teach Yourself Perl in 24 hours" (Clinton Pierce).  Worked
for me.

Dan Mercer

:
:
:
:




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

Date: Fri, 23 Feb 2007 11:22:11 -0800
From: Keith Thompson <kst-u@mib.org>
Subject: Re: which is more powerfull ?
Message-Id: <ln649sbrx8.fsf@nuthaus.mib.org>

David Harmon <source@netcom.com> writes:
> On 19 Feb 2007 12:01:16 -0800 in comp.lang.perl.misc,
> ehabaziz2001@gmail.com wrote,
>>I need to process some files to create new one with OMR marks . which
>>is more powerfull in processing files ? awk/sed or perl or others ?
>>Thanks
>
> BEFORE POSTING read the welcome message posted twice per week in
> comp.lang.c++ under the subject "Welcome to comp.lang.c++! Read this
> first." or available at http://www.slack.net/~shiva/welcome.txt

How would that be helpful to someone posting to comp.lang.awk,
comp.unix.shell, comp.unix.questions, and comp.lang.perl.misc?

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.


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

Date: Fri, 23 Feb 2007 15:20:53 -0500
From: Bill Marcum <marcumbill@bellsouth.net>
Subject: Re: which is more powerfull ?
Message-Id: <5uu3b4-4uv.ln1@don.localnet>

["Followup-To:" header set to comp.unix.shell.]
On Fri, 23 Feb 2007 11:22:11 -0800, Keith Thompson 
  <kst-u@mib.org> wrote:
>
>
> David Harmon <source@netcom.com> writes:
>> On 19 Feb 2007 12:01:16 -0800 in comp.lang.perl.misc,
>> ehabaziz2001@gmail.com wrote,
>>>I need to process some files to create new one with OMR marks . which
>>>is more powerfull in processing files ? awk/sed or perl or others ?
>>>Thanks
>>
>> BEFORE POSTING read the welcome message posted twice per week in
>> comp.lang.c++ under the subject "Welcome to comp.lang.c++! Read this
>> first." or available at http://www.slack.net/~shiva/welcome.txt
>
> How would that be helpful to someone posting to comp.lang.awk,
> comp.unix.shell, comp.unix.questions, and comp.lang.perl.misc?
>
It might help them learn to trim their crossposts.


-- 
* joeyh_ wonders if linux is supposed to lock up when you ask 100
  processes to cat the entire cd drive


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

Date: 23 Feb 2007 13:40:39 -0800
From: "gf" <greg.ferguson@icrossing.com>
Subject: Re: which is more powerfull ?
Message-Id: <1172266839.310042.77070@j27g2000cwj.googlegroups.com>

On Feb 19, 3:20 pm, Sherm Pendley <spamt...@dot-app.org> wrote:

> What a lame attempt at starting an argument.

Based on his subject...

"Which is more powerful?"

New improved Ajax with bleach is more powerful than standard Ajax any
day.



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

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 V11 Issue 168
**************************************


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