Re: must satisfy _unknown_ number of regexp patterns

2009-11-05 Thread Robert Wohlfarth
ed!\n" } > Now I'm thinking, it is quite impossible to dynamically create all those if > tests. Perhaps I can just open a file for writing, write a new perl script > which will have those codes, and execute it at the end. > For more dynamic you can try something like this... $match = 1; map { $match = 0 if ($word !~ /$_/) } @options; if ($match) { print "All pattern matched\n" } Hope that helps. -- Robert Wohlfarth

Re: splitting and replacing characters

2009-11-09 Thread Robert Wohlfarth
> Will a "for" loop work for your needs? The one below uses "substr" to extract every two characters. my $line="abcdefghijkl"; for (my $i = 0; $i < length( $line ); $i += 4) { print substr( $line, $i, 2 ), "\n"; } -- Robert Wohlfarth

Re: set fonts for GD

2009-11-13 Thread Robert Wohlfarth
xis_font('arial', 15) or die $graph->error; > $graph->set_y_axis_font('arial', 15) or die $graph->error; > > Apache's error_log says: > > Cannot find TTF font: arial > Does setting the font path with GD::Text->font_path help? On Ubuntu, "arial.ttf" is located in /usr/share/fonts/truetype/msttcorefonts. -- Robert Wohlfarth

Re: How to complete the loop while debugging.

2009-11-17 Thread Robert Wohlfarth
pport available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1):foreach (1..5) {print "$_\n"; } DB<1> n main::(-e:1):foreach (1..5) {print "$_\n"; } DB<1> n 1 main::(-e:1):foreach (1..5) {print "$_\n"; } DB<1> c 2 2 3 4 5 main::(-e:2):print "done\n"; DB<2> The "c 2" continues until it reaches line 2 - outside of the loop. HTH -- Robert Wohlfarth

Re: IF... OR... not working

2009-11-24 Thread Robert Wohlfarth
e. The code doesn't want to match ANY of the patterns. It needs a truth table like this: www * result 0 0 0 0 1 0 1 0 0 1 1 1 That truth table matches the AND operator. Does this make sense? -- Robert Wohlfarth

Re: Can I design a website using Perl

2009-12-05 Thread Robert Wohlfarth
good > tutorial link would be really appreciated. > Check out one or more of the Perl web frameworks. I'm experimenting with Catalyst right now: http://www.catalystframework.org/. -- Robert Wohlfarth

Re: could not execute psexec

2009-12-07 Thread Robert Wohlfarth
t;C:\\commands\\AutoIT\\sch.bat\""; > system("$cmd") or die "$!"; > Try using 'psexec.exe' as the command. It's been a while since I've used my Windows scripts. And I seem to remember having to use the extension. Or maybe that's just old age... -- Robert Wohlfarth

Re: sort %hash by key

2009-12-07 Thread Robert Wohlfarth
code do what you want? foreach(my $key (sort keys %channels)) { print $key, ' => ', $keys{$key}; } -- Robert Wohlfarth

Re: being smart about script structure

2009-12-12 Thread Robert Wohlfarth
add subroutines where they make sense - for code used by more than one place. Leo <http://webpages.charter.net/edreamleo/front.html> is a pretty nice tool fro writing programs in a literate style. -- Robert Wohlfarth

Re: Can you please Help perl readdir multiple folders and files with pre same name

2009-12-18 Thread Robert Wohlfarth
t;) or die "cant open > $bookingspath/$folder: $!\n"; while(defined(my $phone_data = > readdir(DIR_PHONE))){ > if (substr($phone_data,0,8) eq 'PHONELOG'){ > > &my_read_data_file($bookingspath,$folder,$phone_data); > } > } closedir(DIR_PHONE) ; > > } > > closedir(DIR) ; > > For future reference, the File::Find module also traverses a directory tree. -- Robert Wohlfarth

Re: Regexp to remove spaces

2009-12-20 Thread Robert Wohlfarth
, for example, also removes leading/trailing/multiple spaces. -- Robert Wohlfarth

Re: Regex problem

2009-12-21 Thread Robert Wohlfarth
g; > print MY_OUTPUT_FILE $line; > } > Try this: $line =~ s/(\s)243 /${1}243rd /g; Without the braces, Perl is looking for match number 1,243! Braces separate the 1 from the 243. -- Robert Wohlfarth

Re: Saturdays in a month

2009-12-22 Thread Robert Wohlfarth
urring dates (like "every Saturday"). If you can get a list of dates, then the count of the list is the number that you want. -- Robert Wohlfarth

Re: XML::Simple question

2009-12-22 Thread Robert Wohlfarth
$xmlresponse"); > # can't read the response in this manner > === > Try the "parse_string" method instead. The documentation says that XMLin guesses based on the presence of "<" and ">" characters. It appears that XMLin guesses wrong in your case. "parse_string" explicitly expects an XML string. So there's no logic to confuse. -- Robert Wohlfarth

Re: Understanding the definition of 'short-circuiting'

2009-12-29 Thread Robert Wohlfarth
_first returns true and the line prints. What about $result? Perl never called into the code for do_second, and $result never changed. We say that Perl short circuited the evaluation. It stopped executing code as soon as it knew the outcome of the logic statement. -- Robert Wohlfarth

Re: double quotes are needed

2010-01-06 Thread Robert Wohlfarth
tes "print $first, > $second, $third\n"; > > 255, 255, 255 > 765 > print "$first, $second, $third\n" prints a single, scalar value. -- Robert Wohlfarth

Re: file handling

2010-02-12 Thread Robert Wohlfarth
;. 3. Loop from 2 to 1000... 1. Increment "Field ID" by 20. 2. Substitute the new "Field ID" for the old one, using regular expressions. 3. Substitute the counter (L) in the field. 4. Write the entire block out to a new file. Is that accurate? -- Robert Wohlfarth

Re: Test if directory is not empty

2010-03-07 Thread Robert Wohlfarth
ady have extensions > The "-e" test will tell you if the target file already exists. For example: if (-e $copyToFile) { # Add extension here... } -- Robert Wohlfarth

Re: use with variable

2010-03-10 Thread Robert Wohlfarth
executes at compile time - before "$oraenv" is set. Try the "require" command: require Env::Sourced; Env::Sourced->import( $oraenv ); The perlfunc man page has more information about "use" and "require". -- Robert Wohlfarth

Re: XML Parsing/Modules

2010-04-07 Thread Robert Wohlfarth
m not > sure how to proceed like which module I've have to use etc. any pointers > would be much appreciated. > I've used XML::Parser <http://search.cpan.org/dist/XML-Parser/Parser.pm> to do simple things. The documentation is here: http://search.cpan.org/dist/XML-Parser/Parser.pm. -- Robert Wohlfarth

Re: about split and \d or . (.)

2010-04-11 Thread Robert Wohlfarth
; > my @elems3 = split(//,$var); > The first two patterns match every character. When everything is a separator, there's nothing left as data. -- Robert Wohlfarth

Re: logic not being able to score last element in the array

2010-05-05 Thread Robert Wohlfarth
',',$line); @score_key=shift(@key); return @key; } See http://perldoc.perl.org/functions/chomp.html for more information about "chomp". -- Robert Wohlfarth

Re: How do I control a C programme from perl?

2010-05-13 Thread Robert Wohlfarth
et > all the output which is too late. > See if the Expect<http://search.cpan.org/%7Ergiersig/Expect-1.21/Expect.pod>or Expect::Simple<http://search.cpan.org/%7Edjerius/Expect-Simple-0.04/lib/Expect/Simple.pm>modules will work. They let Perl control a child process using standard

Re: Developer docs

2010-05-28 Thread Robert Wohlfarth
into my > current documentation methodology so that people can still enjoy my user > docs, while I can review my devel docs within a separate `perldoc' page? > I've seen large projects like Moose put user documentation under Moose::Manual::... The developer documentation is named after the actual code module. -- Robert Wohlfarth

Re: Just asking - Tips on how to maintain your scripts ..

2010-06-05 Thread Robert Wohlfarth
se Bazaar at work (Windows). I create a branch on a USB stick to work from home (Linux). On Monday, it's a matter of merging the USB branch back into the original. -- Robert Wohlfarth

Re: Edit large data file

2010-06-16 Thread Robert Wohlfarth
th the new parsed row. >> >> Is this possible, and if so how can I do it? >> > > It is possible, you just have to write the new data to a new file. You might also want to look at the "-n", "-p", and "-i" command line options for Perl (http://perldoc.perl.org/perlrun.html). -- Robert Wohlfarth

Re: Getopt::Long

2010-06-17 Thread Robert Wohlfarth
treating "-a" as the value for "-s" because the string "-a" immediately follows the option -s. You could add validation on the value of "-s". For example... GetOptions( "n|name=s" => \$name, "a|age=i" => \$age, "s|sex=s" => \$sex, ) || die "Bad options\n";; if ($sex !~ m/m(ale)?|f(emale)?/i) { die "Invalid gender $sex\n"; } -- Robert Wohlfarth

Re: I don't wont to create more lines of code then the necessary

2010-07-09 Thread Robert Wohlfarth
message, "split" should not be called in a scalar context. use strict; use warnings; sub xpto(@) {}; xpto( split(/\n/, "fv\nfg" ) ); -- Robert Wohlfarth

Re: Calling Exit from within a subroutine

2010-07-21 Thread Robert Wohlfarth
ng to continue from here once sub foo has ended and I have not called exit here or in the sub? } elsif ($bar){ my_sub_bar(); } else { my_other_sub(); } exit 0; -- Robert Wohlfarth

Re: Strange behaviour while using DBI with binding

2010-08-19 Thread Robert Wohlfarth
oin personal_data on user.id = personal_data.id where gender = ? and position = ? order by lname limit ?,? }); $sth->execute($gender, $role, $offset, $number_rows); -- Robert Wohlfarth

Re: dereferencing hash arrays

2010-08-19 Thread Robert Wohlfarth
rHash}) while (my ($key, $value) = each %{$rHash}) To access a single entry, you can do something like this: $value = $rHash->{'field'}; -- Robert Wohlfarth

Re: Auto completing STDIN from a script

2010-10-07 Thread Robert Wohlfarth
c.perl.org/perlopentut.html#Pipe-Opens. -- Robert Wohlfarth

Re: Regular expression: Search a pattern but starting from the end of a string?

2010-11-02 Thread Robert Wohlfarth
.looong string possibly with many E's...E.no capital e' here...3456" $string =~ m/E[^E]*$/; The expression matches a capital E, followed by zero or more non-E characters, and the end of the line. -- Robert Wohlfarth

Re: reference of an array into an array

2010-11-04 Thread Robert Wohlfarth
} The first time through, @mytemp uses memory location 12345. The second time through, @mytemp uses memory 12399. Third time, it's 12563. And so on... Now you have a series of different memory locations, with different values for $a, $b, and $c. Does that make sense? -- Robert Wohlfarth

Re: regex problem

2010-11-05 Thread Robert Wohlfarth
.pm>. It handles all of these details for you. -- Robert Wohlfarth

Re: perl web apps

2010-11-22 Thread Robert Wohlfarth
miliar > with js). thoughts? > Check out Catalyst (http://www.catalystframework.org/). It handles the drudgery without forcing you into one way of doing things. -- Robert Wohlfarth

Re: Simple Script That Runs Under Perl 5.8 but not under Perl 5.10

2010-11-24 Thread Robert Wohlfarth
-- > Declare the subroutine before calling sort. Something like this... sub cmpChrs(); foreach my $chr (sort cmpChrs keys %SAM) { print "CHR=$chr\n"; } The *sort* documentation for 5.12 shows three forms: - sort SUBNAME LIST - sort BLOCK LIST - sort LIST I&

Re: Redirecting the output

2010-12-01 Thread Robert Wohlfarth
elf... > > Jim Gibson wrote: > >> Install and use the File::Tee module from CPAN: >> > > I researched the various options a while back and settled on Capture::Tiny. > Since this looks like a log file, you might also consider Log::Log4perl. -- Robert Wohlfarth

Re: glob files and subdirectories

2010-12-08 Thread Robert Wohlfarth
pan.org/%7Epetdance/File-Next-1.06/Next.pm>module. -- Robert Wohlfarth

Re: problems hashing

2011-01-06 Thread Robert Wohlfarth
d up with something like this... $fieldMap{8} = 1023240136 $fieldMap{1218} = 0 $fieldMap{1} ="00a01a2bcdc7" Perl expects the data to have a value for every key. The first error - odd number of elements - means that Perl saw a key without a corresponding value. The data has an odd number of elements. To save into a hash, it should have an even number of elements. -- Robert Wohlfarth

Re: Perl... Logging to console and Log file

2011-01-13 Thread Robert Wohlfarth
the below steps which i performed to send a message to > log. > Take a look at Log::Log4perl<http://search.cpan.org/%7Emschilli/Log-Log4perl-1.31/lib/Log/Log4perl.pm>( http://search.cpan.org/~mschilli/Log-Log4perl-1.31/lib/Log/Log4perl.pm). It handles multiple outputs seamlessly. -- Robert Wohlfarth

Re: Randomizing a 24hr time period

2011-02-09 Thread Robert Wohlfarth
7;, $h, $m; > ++$h, $m = 0 if ++$m >= 60; > } > I assume that Mike (the original poster) would get 50 times by substituting "[0..50]" in place of "[0..24]". my @sample = (shuffle @times)[0..24]; > And this last piece then sorts the 50 random times into chronological order for the cron job. It's very clever. print "$_\n" foreach sort @sample; -- Robert Wohlfarth

Re: problem with naming of variables

2011-03-28 Thread Robert Wohlfarth
do this? Thanks > > @bet1 = (0,0,0,0); > @bet2 = (0,0,0,1); > @bet3 = (0,0,1,0); > > $random_bet_position = int(rand(3) + 1); > > @selected_bet = @{bet$random_bet_position); > @bets = ( [0,0,0,0], [0,0,0,1], [0,0,1,0] ); @selected_bet = @{$bets[$random_bet_position]}; -- Robert Wohlfarth

Re: Order in which keys are stored in a hash

2011-04-06 Thread Robert Wohlfarth
doc.perl.org/functions/sort.html> for examples of how to arrange for an output ordering.* It's easy to miss if you didn't know to look for it. My limited understanding is that Perl handles the order internally. Code should never rely on a specific order. -- Robert Wohlfarth

Re: Getting script to run w/o optional module

2011-06-09 Thread Robert Wohlfarth
t. Is > that possible? > Would something like this meet your need? I found it on CPAN by searching<http://search.cpan.org>for "Module". http://search.cpan.org/~ivorw/Module-Optional-0.03/lib/Module/Optional.pm -- Robert Wohlfarth

Re: Just why?

2011-08-12 Thread Robert Wohlfarth
ers to func. Change the code like this: print func() * 5, "\n"; -- Robert Wohlfarth

Re: How to create randomly generated emails

2011-10-14 Thread Robert Wohlfarth
n vary the size (number of words) in each record. -- Robert Wohlfarth

Re: segmentation fault

2011-12-21 Thread Robert Wohlfarth
text > to xml file > \n"; > ######## > > >$writer->endTag(); >print "closing page tag for the article num: ", $testCount, > " \n"; >$testCount++; > > # print $testCount; print "\t"; > # if ($testCount == 10){ > # print "\n"; > # last; > # } > > >}#end if for en ar fr > >if (($$enText =~ /\[\[fr:/i)){ > >#print $page->title, "\n"; >$EnFrCount ++; >} > >if (($$enText =~ /\[\[ar:/i)){ >#print $page->title, "\n"; >$EnArCount ++; >} >#print "working \n"; > > }# end for while loop (for each english article) > > > $writer->endTag(); > $writer->end(); > $output->close(); > > > print "\n\n"; > print "English : "; > print $EnCount; > > print "\n\n"; > print "English/Arabic/French : "; > print $EnArFrCount; > > print "\n\n"; > print "English/Arabic : "; > print $EnArCount; > > print "\n\n"; > print "English/French : "; > print $EnFrCount; > > > > #removes any case sensativity from the very first letter of the title > #but not from the optional namespace name > sub case_fixer { > my $title = shift; > > #check for namespace > if ($title =~ /^(.+?):(.+)/) { >$title = $1 . ':' . ucfirst($2); > } else { >$title = ucfirst($title); > } > > return $title; > } > -- Robert Wohlfarth

Re: segmentation fault

2011-12-21 Thread Robert Wohlfarth
On Wed, Dec 21, 2011 at 10:37 AM, Shlomi Fish wrote: > On Wed, 21 Dec 2011 09:48:19 -0600 > Robert Wohlfarth wrote: > > > On Tue, Dec 20, 2011 at 11:25 AM, Motaz SAAD > wrote: > > > > > I am a beginner in perl and I have segmentation fault in my code. the >

Re: perl equivelent of which in bash

2012-01-04 Thread Robert Wohlfarth
uot;which" turned up File::Which<http://search.cpan.org/~adamk/File-Which-1.09/lib/File/Which.pm>. It may meet your needs. -- Robert Wohlfarth

Re: array uniq elements

2012-01-08 Thread Robert Wohlfarth
On Sun, Jan 8, 2012 at 11:15 PM, Chris Stinemetz wrote: > How do I extract uniq elements from an array? Basically I want to > preserve the order of the elements as they are first seen, but I would > like to remove any duplicates. > You may want to check out List::MoreUtils on CPAN.

Re: Foreach loop and hash of arrays

2012-02-06 Thread Robert Wohlfarth
350 => 'AL', 351 => 'AL', 995 => 'AK', 996 => 'AK', 850 => 'AZ', 851 => 'AZ', 716 => 'AR', 717 => 'AR', ); > my $customers_state = 'AZ'; my $customers_zip = '850'; if ( exists( $zips{$customers_zip} ) and $zips{$customers_zip} eq $customers_state ) { print 'yes'; } else { print 'no'; } -- Robert Wohlfarth

Re: Template toolkit issue

2012-05-02 Thread Robert Wohlfarth
HTTP headers. I would expect the script to run Template Toolkit, capture the results, and include those results in an HTTP response. -- Robert Wohlfarth

Re: someone anyone Spreadsheet::xlsx help!

2012-05-25 Thread Robert Wohlfarth
cell: my $cell = $worksheet->{Cells}[$row][$column]; print $cell->value; -- Robert Wohlfarth

Re: lexical scope

2012-06-05 Thread Robert Wohlfarth
p $line; > @array = split(/\s+/, $line,-1); > } > The "while" loop overwrites the contents of "@array". Every line overwrites the previous one. I believe that you want a two dimensional array here. -- Robert Wohlfarth

Re: return two varibles

2012-06-07 Thread Robert Wohlfarth
$val}) { return @{$apcHash{$val}}{qw/start end/}; } else { return (); } } -- Robert Wohlfarth

Re: Unexpected token error when providing a regular expression as input

2012-08-01 Thread Robert Wohlfarth
quot;(.es.){3}" before running Perl. Those extra slashes you added tell "bash" to not interpret the parenthesis. You could also get around the problem by quoting the regular expression on the command line, like this: # ./grep.pl '(.es.){3}' /usr/share/dict/words Hope that helps. -- Robert Wohlfarth

Re: DBIx schema loader (dump schema using make_schema_at) wierd behaviour

2012-08-08 Thread Robert Wohlfarth
s-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > Take a look at the documentation for DBIx::Class::Schema::Loader::Base. It explains how *make_schema_at* renames tables into classes. http://search.cpan.org/~rkitover/DBIx-Class-Schema-Loader-0.07025/lib/DBIx/Class/Schema/Loader/Base.pm#naming -- Robert Wohlfarth

Re: My long script

2012-09-15 Thread Robert Wohlfarth
and" keeps returning decimal numbers between 3 and 4, like 3.4526180 and 3.9876261 and 3.1182304. Instead of picking answers at random, what about shuffling the answers and take the top 5? They're still in a random order. And you eliminate even the possibility of an infinite loop. A modu

Re: variable definition error not caught when using strict and warnings

2012-11-09 Thread Robert Wohlfarth
value, which is what the warning tells you. Perl expects program variables to start with a letter or underscore. So "$a999" or "$num" work like you expected. You can find more about variable names here: http://perldoc.perl.org/perldata.html. -- Robert Wohlfarth

Re: Scripts in Padre do not run. Need step-by-step help in setting up, as all current procedures I have found have failed for me.

2013-05-24 Thread Robert Wohlfarth
It's been a while since I've used it. I seem to recall that standard output gets sent there. -- Robert Wohlfarth

Re: Perl and Web Development

2013-06-03 Thread Robert Wohlfarth
ple, and it's pretty easy to learn. http://www.catalystframework.org/ -- Robert Wohlfarth

Re: how to make perl program run continue when i press control+s to pause screen output

2013-06-06 Thread Robert Wohlfarth
If you want to pause the actual program, then try Ctrl+Z. On a unix/linux box that will work. See http://www.gnu.org/software/bash/manual/bashref.html#Job-Control for more information. -- Robert Wohlfarth

Re: Puzzled by ouput from this script

2013-09-11 Thread Robert Wohlfarth
On Wed, Sep 11, 2013 at 5:04 PM, Harry Putnam wrote: > while(<$cmdh>) { > print $fh; > print; > I believe this code prints the file handle. Try this: while(<$cmdh>){ print $fh $_; print; -- Robert Wohlfarth

Re: Regex not working correctly

2013-12-11 Thread Robert Wohlfarth
the number part ? > There are two sets of capturing parenthesis: * (91\d{10}|0\d{10}|[7-9]\d{9}|0\d{11}) = $1 * (\d+) = $2 The first set stores its match in $1 and the second set in $2. The pipe (or) does not reset the capture counter back to 1. The counter strictly goes from left to right. -- Robert Wohlfarth

Re: OO perl programming

2014-02-13 Thread Robert Wohlfarth
b is that objects represent "things". I think of objects as managing state - the state of an individual "thing". Modules with all class methods do not represent "things". They're just functions. -- Robert Wohlfarth

Re: Search one character against one string

2014-03-12 Thread Robert Wohlfarth
); This is a good example of how Perl flattens a parameter list. The "&is_in_string(@ar, $c)" turns into "&is_in_string('t', 'd', 's', 'd');". @_[0] only grabs the first parameter 't'. $_[1] grabs the second parameter - the 'd' from @ar. -- Robert Wohlfarth

Re: Match Variables Not Working in m//

2014-03-19 Thread Robert Wohlfarth
\w+). The "\*" matches a literal asterisk - which isn't in the string. So the match fails. Add the "s" and it does what you expect. -- Robert Wohlfarth

Re: question on escaping shell command

2014-05-15 Thread Robert Wohlfarth
ot; and treats the rest of the line like a comment. When passing "!@\#bsay0nd" to the shell, it interprets "#" as a literal character instead. -- Robert Wohlfarth

Re: Wanted: Help with DBI/CGI in Windows 8.1/IIS

2014-06-26 Thread Robert Wohlfarth
t;h1("hello world $ct"); # level 1 header >>> >>> print $q->end_html; # end the HTML >>> >> > One more thing that came up while testing your code... Did you configure > the ODBC datasource? Is Microsoft Access installed on the server? DBI will need it to read the file. -- Robert Wohlfarth

Re: Suddenly this script is not working!

2014-07-30 Thread Robert Wohlfarth
09. No other line is simply How about the 0D 0A at the end of the line? Unless the script used "chomp", the exact line is "\r\n". -- Robert Wohlfarth

Re: async, non blocking tcp server

2014-08-29 Thread Robert Wohlfarth
mer's point of view). > It sounds like you want an event loop that triggers on socket activity. Would something like AnyEvent::Socket <http://search.cpan.org/~mlehmann/AnyEvent-7.07/lib/AnyEvent/Socket.pm> work for you? I came across it by googling "perl socket event handler". -- Robert Wohlfarth

Re: Debug when script WILL NOT RUN

2015-01-31 Thread Robert Wohlfarth
tdir is a parameter to a function call. It should not have a semi-colon after it. -- Robert Wohlfarth

Re: Trying to set the iCloud directory in Perl, but failing

2021-08-13 Thread Robert Wohlfarth
ks for any info… ;) > > Wags ;) > WagsWorld > Hebrews 4:15 > Ph(primary) : 408-914-1341 > Ph(secondary): 408-761-7391 > -- Robert Wohlfarth