Re: please help !! pattern match

2003-09-05 Thread Rob Anderson
"Pandey Rajeev-A19514" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi , Hello > > I need some help me to extract a pattern. The delimiters is a pair of "abcd" and "efgh". Can some one help me with an efficient use of Greedy and non greedy matches, look ahead and lookbehind feat

Re: Perl script checks for a file

2003-09-05 Thread Rob Anderson
"Anthony J Segelhorst" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Does anyone already have a perl script that checks to see if a file exists > or not a Windows Platform? > if (-e $filename) {print "There it is\n"} > > Anthony J Segelhorst > Enterprise Systems Management Team >

Re: Extracting equal entities from two different sized arrays?

2003-09-04 Thread Rob Anderson
""Freddy söderlund"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > - Original Message - > From: "Rob Anderson" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, September 04, 2003 3:30 PM >

Re: Extracting equal entities from two different sized arrays?

2003-09-04 Thread Rob Anderson
>""Freddy söderlund"" <[EMAIL PROTECTED]> wrote in > message news:[EMAIL PROTECTED] >Hi! > Hi >I have stuck my thoughts on this one, maybee someone can help me out? > >I have two arrays > >@array1 = "C:\Program files\directory1\directory2\directory3"; >@array2 = "C:\Program files\directory1\dir2

Re: Capturing passed Parameters?

2003-09-04 Thread Rob Anderson
>"Mark Weisman" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >How do you capture passed parameters in Perl on Windows? In regular perl >its: > $variable = param('passed'); Hi Mark, Erm, are you talking about passing parameters on the command line or to a cgi. if you calling pe

Re: passing an argument to a subroutine

2003-09-04 Thread Rob Anderson
r paramters you might pass. What you were doing was getting the value from an array on scalar context. When you do this in perl, it will return the __number of elements__ in the array, which is very usefull, but not what you wanted. For example. my $number_of_element = @a_big_array; HTH Rob A

Re: cutting a string

2003-09-01 Thread Rob Anderson
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What is the function of cutting a string from a point until the last character? > > For example > $string="C:/progra~1/directory1/directory2/file.txt"; > > i want to find the last backslash (/) of the string and keep the sequence > foll

Re: Parlsax parsing problem

2003-08-22 Thread Rob Anderson
"Kurt Klinner" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > while trying to parse a "large" XML document i found a > strange behaviour of the Parser Module(s) (XML::Parser:PerlSAX, > XML::Parser, XML::Parser::Expat > > If my file XML file is larger then 65536 bytes > th

Re: Regular expression help

2003-08-18 Thread Rob Anderson
7; 'data13' > >I will have a look at Text::CSV > Please do, my mistake above shows you why you shouldn't reinvent this stuff if you can get away with it. :-) Ta Rob > >Michel > >-Message d'origine- >De: Rob Anderson [mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Regular expression help

2003-08-18 Thread Rob Anderson
trying to parse it yourself? If you've got control of your data, use something like Text::CSV. The guy who maintains your code will thank you for it. otherwise, this seems to work (you'll have to print with $2 though)... /(['"])(((''|"")|[^'"

Re: Comparing two strings for first difference

2003-07-17 Thread Rob Anderson
a string of characters that > have--but it's still a good reference.) > > Thanks again, No prob, glad to be of help. Rob > > paul > > > 10:11am, Rob Anderson wrote: > > > > If anyone can offer general improvements to that approach, that'd be

Re: Comparing two strings for first difference

2003-07-17 Thread Rob Anderson
Hi Paul "Rob Anderson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > "Paul Archer" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > [snip] > > > > > If anyone can offer general improvements to that ap

Re: Comparing two strings for first difference

2003-07-17 Thread Rob Anderson
"Paul Archer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [snip] > > If anyone can offer general improvements to that approach, that'd be > great--but what I'm really interested in is finding the first element that > differs, and maybe the last as well. If there were any easy way

Re: Need Regex help !!

2003-07-11 Thread Rob Anderson
Hi Rajeev, I'm not sure why you feel the need to join your buffer into a big string. >From what you describe couldn't you just process each buffer element one by one? foreach my $buffer_entry (@buff) { if($buffer_entry =~ /(FastEthernet|down)/i) { print $buffer_entry; } } Let us

Re: Easy regex

2003-07-10 Thread Rob Anderson
"Ned Cunningham" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > HI all. > > I am trying to verify that a field has only numbers > > 12345 > 13456 > 34x34 > > if it has non numbers I want to delete the non number with a zero? > > Snip > > $mil =~ s/[0-9]/$_/; > > this returns zero. >

Re: Creating a hash of arrays from row data

2003-07-10 Thread Rob Anderson
"Sudarshan Raghavan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Rob Dixon wrote: > > >I was perturbed by your post Sardushan. I'll > >try to explain why. > > > > Wait a second, my post was not an attempt to undermine Rob Anderson's > post in any manner. I apologize if the wrong

Re: Oracle SQL

2003-07-09 Thread Rob Anderson
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > We are having a problem. Any help would be appreciated. > > 1: We are running Perl on NT. > 2: Perl is reading lines of code from a file, concatonating it in a variable, >and writing to an Oracle database. > 3: I keep on getting a

Re: Creating a hash of arrays from row data

2003-07-09 Thread Rob Anderson
"Sudarshan Raghavan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Rob Anderson wrote: > > >Hi Jeroen, > > > > > > > >>while (@values = $lcsr->fetchrow) { > >> > >> > > > >This is probably th

Re: Creating a hash of arrays from row data

2003-07-09 Thread Rob Anderson
is key if (! defined $data{$key}) {$data{$key} = []} my $array_ref = $data{$key}; push(@$array_ref, [EMAIL PROTECTED]); } Hope this helps Rob Anderson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: While loop, confused...

2003-07-03 Thread Rob Anderson
Hi Bill, I know you've had lots of comments on this, but I thought I'd throw my own style in. Why not do your check at the bottom with a "do until"? First time round the check is useless anyway, and will give you 'undef' type warnings with perl -w. It also allows you to be more positive in your co

Re: Simple question on splice

2003-06-27 Thread Rob Anderson
"Rob Anderson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > "Sitha Nhok" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Hi, if I have a multidimensional array like : > > > > @AoA = ( > >

Re: Simple question on splice

2003-06-27 Thread Rob Anderson
t it out, put deferencing it to an array by prefixing it with a @. You could also do this... my $inner_array_ref = $var[0]; print $$inner_array_ref[1]; Which will print the second element from the inner array. You'd be well advised to read up on references, and de-referencing stuff. HTH Rob Anderson > ~Sitha > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How to write to a file at certain position?

2003-06-26 Thread Rob Anderson
Hi Again, You're right, if we were dealing with a text file, you wouldn't have to use binmode. However, my original script **was** for uploading binarys, and you mentioned mp3, so it made sense to leave it in. Hope I've been of some help Rob "Li Ngok Lam" <[EMAIL PROTECTED]> wrote in message ne

Re: How to write to a file at certain position?

2003-06-26 Thread Rob Anderson
This is a snippet from an cgi based file uploader I wrote once. I think this is what you're after #/!perl -w use strict; use IO::File; my $offset = 3; my $file_binary = "fg"; sysopen(OUTFILE, "out.txt", O_WRONLY) or print "Couldn't open file for read/write ($!)\n"; binmode OUTFILE; sysseek OUTFI

Re: Array Question

2003-06-25 Thread Rob Anderson
>"Anthony Beaman" <[EMAIL PROTECTED]> wrote in message ? >news:[EMAIL PROTECTED] >I typed in 3. For example, "Sam Mary Joe". I expect to get "I know Mary", since she's [1] but I'm getting >a blank space. I've tried this on NT and on my 98 machine here at work. Hmm, are you just putting spaces bet

Re: Array Question

2003-06-25 Thread Rob Anderson
Hi Anthony >"Anthony Beaman" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >Hi! I'm still wallowing in Chapter 3 (Arrays. Why can't I get it?!?!?!? ARGH!) of Learning Perl on >Win32 Systems. I'm trying to create an exercise but I'm not getting the results that I want. Here's wha

Re: perl reg exp problem

2003-06-23 Thread Rob Anderson
Opps double clicked first time round, I blame my mouse :-) Robin, perl has online documentation for all it's functions and much more. try the following perldoc -f shift and perldoc perldoc for more general advice HTH "Rob Anderson" <[EMAIL PROTECTED]> wrote in message

Re: perl reg exp problem

2003-06-23 Thread Rob Anderson
"Robin Garbutt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] what does shift do in perl? cheers Rob. > -Original Message- > From: Janek Schleicher [mailto:[EMAIL PROTECTED] > Sent: 23 June 2003 08:52 > To: [EMAIL PROTECTED] > Subject: Re: perl reg exp problem > > > Robin

Re: compiling DBD::Oracle

2003-06-17 Thread Rob Anderson
Hi Rob, No, you're not heading down the wrong path, you just need the Oracle **client** installed on your local machine. When recompliling DBI and DBD make sure you've got the following set correctly (appropriate to your set up) ... ORACLE_HOME=/export/home/oracle/OraHome1 PATH=$PATH:/export/hom

Re: I need to make this not end

2003-06-16 Thread Rob Anderson
Hi err, Mr T. Here's a solution to your question, but from a different point of view... -- #!perl -w use strict; my $im_thinking_of = int(rand 10); my $guess; do { print "Pick a number:"; $guess = ; chomp $guess; if ($guess > $im_thinking_of)

Re: References...

2003-06-10 Thread Rob Anderson
Hi Hamish, You might well ask, "what's the difference between... print 1 + 2 * 3; ...or... print 1 + (2 * 3); ...?" The answer to this, and to your question is, not a lot. Sometimes you do need to add parenthesis to resolve ambiguities over what's dereferencing waht, but in your case you, m

Spliting comma delimited data

2003-06-09 Thread Rob Anderson
#x27;tasty', 'cheese'); my $escaped_array = join(",", map {$_ =~ s/,/\\,/g; $_} @array); my @restored_array = map { $_ =~ s/\\,/,/g; $_ } split(/[^\\],/, $escaped_array); print $restored_array[0] . "\n"; OUTPUT tast Thanks for any help Rob A

Re: bypassing "use strict"

2003-06-04 Thread Rob Anderson
Hi Paul, "Paul Morris" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi > > #!/usr/bin/perl > use strict; > $a = 123; #slips through strict > $b = 123; #slips through strict > $c = 123; #caught by strict > > Is there any reason (apart from convenience) why 'a' and 'b' should ge

Re: Reference to an array from within a hash....how to de-ref.

2003-06-02 Thread Rob Anderson
sName, $comm, $sysoid, $pollint, $pollYN) = @arr; >print ("\t$dnsName, $comm, $sysoid, $pollint,$pollYN\n"); >} HTH Rob Anderson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Learning Perl

2003-04-02 Thread Rob Anderson
Buy "Learning Perl" by O'Reilly, it's great. HTH, Rob "Ohad Ohad" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hey, > > I guess this question came up several time already so a link will be fine. > > What is the best way to learn Perl for someone with very basic programming > sk

Re: Variable scoping, static variable

2003-03-28 Thread Rob Anderson
Thanks but I don't see how this could work. I've tried using it, but to no avail "Janek Schleicher" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Rob Anderson wrote at Fri, 28 Mar 2003 14:45:07 +: > > > -- module sub routine ---

Variable scoping, static variable

2003-03-28 Thread Rob Anderson
I'm trying cache a function to help speed it up. My function lives inside a module, and is being called from a seperate script. It works if I do the following. foreach my $count (1..10) { print "$count" . test("one") . "\n"; } print "\n"; -- module sub routine sub test { my

Re: perl DBI and mysql

2003-03-28 Thread Rob Anderson
t;> line 1. > [EMAIL PROTECTED] util]# > > That's the error message of the program. > > > At 08:54 AM 3/28/2003 +, Rob Anderson wrote: > >Hi Jaws (!?), > > > >You don't say where your script is failing, or what errors it's reporting, > >

Re: perl DBI and mysql

2003-03-28 Thread Rob Anderson
Hi Jaws (!?), You don't say where your script is failing, or what errors it's reporting, which is going to make it hard for anyone to help. You could add some better error checking. Here's a couple of lines lifted from one of my CGI's. my $dbh; eval { $dbh = DBI->connect( $DATA_SOURCE, $DB_USER,

Re: Simple perl program

2003-03-25 Thread Rob Anderson
Do I get marks for this then? "Jeff Westman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Sounds like a class homework assignment to me ;-) > > > > > > what code do you have so far? or are you having trouble getting started ? > > > --- "Kipp, James" <[EMAIL PROTECTED]> wrote: > >

Re: Random numbers

2003-03-25 Thread Rob Anderson
Hi Guys, According to my bookshelf, from 5.004 onwards srand uses a seed that's "that's reasonably difficult to guess". Prior to that, it used time(). It does seem as if the seed it being set the as the same value each time. Could your program be being cached some where? Otherwise a suggestion fo

Re: Simple perl program

2003-03-25 Thread Rob Anderson
How about this case sensitive solution === #!perl -w use strict; my ($file_name, $search_string) = @ARGV; open(INFILE, "< $file_name") or die "Couldn't open $file_name for reading: $!\n"; while () { if ($_ =~ m/\Q$search_string\E/) { print "yes"; exit(); } } print "no";

Re: -w and warnings.pm

2003-03-25 Thread Rob Anderson
Dan, One thing that springs to mind is that if you're using Windows, you can't specify -w on a she-bang (well you can, but windows aint gonna do anything with it). Using warnings.pm would force this in the script, rather than relying on you webserver, whatever's calling you scripts. Hope this hel