Re: Very slow array searching

2003-07-28 Thread George P.
$l_number) { $l_status = 'TRUE'; last; } } Or, for the memory conscious, (since foreach involves loading all elements into memory) $l_status = 'FALSE'; for (my $i=0; $i < @numbers; $i++) { if ($numbers[$i] == $l_number) { $l

Re: match count

2003-07-02 Thread George P.
> right now, I am doing this: > > while ($string =~ /pattern/g){ > $count++; > if ($count > $max_count){ > $string = substr($string,0,pos($string)); > last; > } > } How about: $string =~ s/((.*?$pattern){$max_count})(.*)/$1/s; George P. > > I k

Re: looping script

2003-07-02 Thread George P.
d line, let it finish and rerun it > manually every thing works fine (with some impact on resources which I > can live with for the moment) > How do I make it rerun? > I tried wrapping the script in a > while(1){ > use My::Module; > some script > exit; Remove the &#

Re: Parsing .csv file

2003-06-24 Thread George P.
ave a better way? > Thanks in advance, > Dave > Have a look at perldoc -q "How can I split" George P. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: help with a date.

2003-03-14 Thread George P.
p. > > my $date = '03242003'; > > $date = join '/', unpack 'a2a2a4', $date; Excellent. I had skimmed through pack and unpack, but there were no important uses that I could find. So, I didn't pay much attention to them. The above example has made me t

RE: Regular Expressions http error code

2003-03-12 Thread George P.
e than once. When you say $code =~ / HTTP\/\d\.\d\" (\d+)/; $1 will contain the value captured by (\d+) Therefore, you have to check in $1 A better way to do this would be, if ($code =~ / HTTP\/\d\.\d\" (\d+)/) { print "The code is $1\n"; } else { print &qu

Re: Regular Expressions http error code

2003-03-12 Thread George P.
t yourself. I've never really worked with HTTP log data, but from the lines that you've given, I would say: my ($error_code); if ($ln =~ / HTTP\/\d\.\d\" (\d+)/) { ($error_code) = $1; } bye George P. > > Thanks much, > Derek > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Newby first little script. (Lots of errors and wrong ways of doing things)

2003-03-04 Thread George P.
On Tue, 4 Mar 2003, Paul Johnson wrote: > > George P. said: > > > On Mon, 3 Mar 2003, Scott R. Godin wrote: > > > >> > >> my @scores; > >> my @files = glob "/home/johann/smail/Spam/*"; > >> foreach my $file (@files)

Re: STILL shifting through arrays of line data

2003-03-03 Thread George P.
@param; } } I used to use this logic to move through the command line parameters. This was before I discovered Getopt Hope it helps. George P. > > Why doesn't the while loop iterate all of $rest? I can't seem to figure > out how to get the loop to act on the entir

Re: Newby first little script. (Lots of errors and wrong ways of doing things)

2003-03-03 Thread George P.
() or die()" and "close() or die()" If open fails, the program will kill itself, so the close function will never be called. Therefore there is no need to say "close() or die()" You've done it thrice in this email, so I'm presuming that it's a habitual thing.

Re: Reg ex help

2003-02-24 Thread George P.
On Mon, 24 Feb 2003, Colin Johnstone wrote: > Gidday all, > > >From this string I wish to return everything to the left of the last > occurence of "." if it exists. > > string = "3.25.23.4"; my $string = "3.25.23.4"; my $ret = ''; $ret = $1 if ($string =~ /^(.*)\./); print "$ret"; This will p

Re: improvements to code

2003-01-24 Thread George P.
On Thu, 23 Jan 2003, Pam Derks wrote: > Hi all, > > I want to grap the: > last first middle(if any) email > from a text file > > sometimes there is a middle intital, sometimes there isn't > > sample data: > Smith, Mary [EMAIL PROTECTED] > Jones, Tommy Lee [EMAIL PROTECTED] > > can someone sugges

Re: Regex needed.

2003-01-23 Thread George P.
On Wed, 22 Jan 2003, Rob Dixon wrote: > Hi George. I think you'd have had an answer by now if there was > one. I can't think of anything but I wasn't willing to post and say > 'it can't be done' without waiting for others' ideas. > > George P. w

RE: Regex needed.

2003-01-21 Thread George P.
text" and also for classes like "text[0-9]+" This has proven to be very useful. But now, I need to check for all classes other than "text"; This has me stumped!! For eg: $str = ''; $class = 'text[0-9]+' if ($str =~ /class="$class"/) { print "TAG has this class\n"; } bye, George P. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Regex needed.

2003-01-21 Thread George P.
YE, HI nor CIAO exists in $str. I could've done something like: if ($str !~ /$reg/) { ... } but, I don't want to change the code, just $reg. I've been trying to find something in Programming Perl, but couldn't. Does anyone know how you can do this?? Thanks. George

Re: File Handle?

2003-01-08 Thread George P.
perldoc -f ref Example: open ($fl, "/tmp/1.o"); if (ref($fl) eq 'GLOB') { print "Is a FILEHANDLE\n"; } else { print "Isn't a FILEHANDLE\n"; } I'm not very clear if GLOB is returned only for filehandles. bye, George P. On Wed,

Re: Perl 5.whatever....

2003-01-06 Thread George P.
On Tue, 7 Jan 2003, Jenda Krynicky wrote: > > Since you are using MS Outlook I assume you want a Windows version, > right? > Cool!! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: toggle the case

2003-01-02 Thread George P.
le'$_ = "This Is A Mixed Case Sentence."; > s/([[:alpha:]])/$1 eq lc($1)?uc($1):lc($1)/eg; print' > tHIS iS a mIXED cASE sENTENCE. > $ perl -le'$_ = "This Is A Mixed Case Sentence."; print join"",map{$_=ord;$_+=$_>64 && $_<91 ? 32:$_>96 && $_<123 ? -32:0;chr} split //;' tHIS iS a mIXED cASE sENTENCE. George P. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: macthing question...

2002-12-30 Thread George P.
quot;//; $text =~ s/"$//; if ($num eq '010') { --- Do this ---} else { --- Do this ---} } Bye, George P. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Newbie question in Perl

2002-12-30 Thread George P.
On Mon, 30 Dec 2002, Anand Ramakrishna wrote: > if (-e "newfile.txt") > { > print "WARNING !! FILE newfile.txt already exists\n"; > print "Do you want to destroy all the contents and overwrite the file\n"; > print "Type Y for Yes or N or NO\n"; > $test = ; >

Re: Substitute a word in a file

2002-12-05 Thread George P.
E "$chrs"; Thanks again. George P. On Thu, 5 Dec 2002, Tanton Gibbs wrote: > perldoc -q "How do I change one line in a file" > - Original Message - > From: "George P." <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday

Substitute a word in a file

2002-12-04 Thread George P.
Hi, I am looking for a way to open a file in read/write mode, seek to a particular position and then substitute a word with another word. The file is a simple text file. Does anyone know how to do this ? Thanks. George P. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

Re: Trailing 5 lines of a file

2002-10-29 Thread George P.
On Tue, 29 Oct 2002, zentara wrote: > On Mon, 28 Oct 2002 13:54:28 -0500, [EMAIL PROTECTED] (Nikola > Janceski) wrote: > > >without using 'tail' how can I get the trailing 5 lines of a large file > >quickly, without loading it all to memory? > > > >is there anyway without pop and shifting throu

our($var) having a lexically scoped name

2002-10-18 Thread George P.
Hi, (taken frrom Programming Perl) __BEGIN__ The our declaration declares a lexically scoped name for a global variable, which is not itself a lexical variable __END__ The part about the variable not being lexical variable can be checked by printing $main::var. However, what do you mean by a

How to check between text & binary files

2002-10-14 Thread George P.
Hi, I want to write a .pl that will take in filenames as parameters, and print out whether the files are text files or binary files. The problem I'm having is that I can't figure out a good rule to use while deciding whether a file is a text-file or a binary-file. If someone has created such a

Re: excluding @@

2002-10-10 Thread George P.
On Thu, 10 Oct 2002, Javeed SAR wrote: > Hi all, > > > I want get the last part of this sentence excluding @@ > i.e i should get my output in a variable($put) like this for the following > sentence: > > EnternalID_GetDateofBirth.vbp > > > M:\jav_test\Technical_Docs\.@@\main\int_1_2b\techdoc_1_2

Re: regexp hides info?

2002-09-24 Thread George P.
On Tue, 24 Sep 2002, David Samuelsson (PAC) wrote: > I have an array with a lot of data. > > i want to remove certain elements from it: > so i ran: >for (@array){ >s/$current_user.*//; >} > > nw when i print it, all $current user are gone as i wanted, but i

Re: Regular expression

2002-09-12 Thread George P.
On Fri, 13 Sep 2002, Javeed SAR wrote: > > > I have a statement as follows; > I need to split them into 3 parts; > > * test_merge1 \\blrk35ed\views\test_merge1.vws > > > LIke this: > $var1 should have * > $var2 should have test_merge1 > $var3 should have \\blrk35ed\views\test_merge1.vw

Re: new output error

2002-09-11 Thread George P.
On Tue, 10 Sep 2002, Mike Singleton wrote: > The output file (myfile.csv) is blank... any ideas out there? Thanks! > > === Start=== > use strict; > my $JOBSTART = 'JOBSTART'; > my $CONDSTART = 'CONDSTART'; > my $JOBEND = 'JOBEND'; > my $CONDEND = 'CONDEND'; > my $JOBCANC = 'JOBCANC'; > my $XFER