Re: Split not acting the way I want it to

2008-12-10 Thread Paul Lalli
;ll just suggest an alternative: print substr($ipAddress, rindex($ipAddress, ".") + 1); Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: algorithm permute

2008-11-13 Thread Paul Lalli
nstall That final command will copy the installed module to the real library directory. THAT is the path that you need for use lib. perldoc perlmod for more information Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: algorithm permute

2008-11-10 Thread Paul Lalli
you haven't installed it to "/u/sharan/local/perl/perm_install/lib/perl5/site_perl". Try running find / -name Permute.pm 2> /dev/null to see where, if at all, the module is located on this system. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Accessing hash of arrays?

2008-10-03 Thread Paul Lalli
}, which is itself already a reference. And you are trying to pass that array-reference-reference as a parameter. If you want to pass a reference to the array, use $targetdMessages{$tFolder} If you want to dereference the reference and pass the array elements, use @{$targetdMessages{$tFolde

Re: negate a string

2008-10-01 Thread Paul Lalli
On Sep 29, 10:21 pm, [EMAIL PROTECTED] (Loke) wrote: > On Sep 29, 11:03 am, [EMAIL PROTECTED] (Paul Lalli) wrote:> On Sep 28, > 3:18 pm, [EMAIL PROTECTED] (Loke) wrote: > > > > Hi. I am trying to filter strings which do not have :// in them, I am > > > able to find

Re: negate a string

2008-09-29 Thread Paul Lalli
work. if ($string !~ m{://}) { ... } Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Bulk assignment to list of references

2008-08-19 Thread Paul Lalli
you could do would probably be something involving a postfix for, like: my @new_vals = (4, 5, 6); my $i = 0; ${$_} = $new_vals[$i++] for @l; Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Regular expression: How to determine wether entry is a number?

2008-07-30 Thread Paul Lalli
On Jul 29, 12:09 pm, [EMAIL PROTECTED] (Jan-Henrik) wrote: > On 29 juil, 17:40, [EMAIL PROTECTED] (Paul Lalli) wrote: > > On Jul 29, 8:46 am, [EMAIL PROTECTED] (Jan-Henrik) wrote: > > Thank you very much for the detailed answer, I'll use it as a > reference in the future.

Re: Regular expression: How to determine wether entry is a number?

2008-07-29 Thread Paul Lalli
On Jul 29, 12:21 pm, [EMAIL PROTECTED] (Aruna Goke) wrote: > Jan-Henrik wrote: > > Dear Group, > > > I'm new to Perl and I have a simple question: > > > I ask for the entry of a number vie : > > > > > #!/usr/bin/perl -w > > use strict; > > > my $foo; > > pri

Re: Regular expression: How to determine wether entry is a number?

2008-07-29 Thread Paul Lalli
n example of what you want to do - what the string will contain before you do something to it, and what the string will look like afterwards. Good luck, Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Check if directory is empty on Win32

2008-06-27 Thread Paul Lalli
dir\/\.\.?$/ } glob("$dir/* $dir/.*"); return @contents == 0; } sub is_empty2 { my $dir = shift; opendir my $dh, $dir or die "Cannot open $dir: $!"; my @contents = grep { ! /^\.\.?$/ } readdir($dh); return @contents == 0; } __END__ Results: empty is empty empty is empty subdir is not empty subdir is not empty file is not empty file is not empty dotfile is not empty dotfile is not empty This is perl, v5.10.0 built for MSWin32-x86-multi-thread Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: File search program!

2008-06-20 Thread Paul Lalli
lesson for yourself, to learn how to recurse manually, I guess that's fine. But File::Find is the "right" way to do it. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Compressing multiple columns into one

2008-06-19 Thread Paul Lalli
t; 90 > 50 > > The second line contains the sum of elements 1, 2 > and 3. > > Thanks for any input, #!/usr/bin/perl use warnings; use strict; use List::Util qw/sum/; my @array = qw{ 10 20 30 40 50 }; my $start = 1; my $end = 3; my @out = @array; splice @out, $start, ($end

Re: File search program!

2008-06-19 Thread Paul Lalli
s, not double-backslashes. It is only the cmd shell that insists you use \ instead of / So I would take your program and rewrite it like this: #!/usr/bin/perl use strict; use warnings; use File::Find; print "Enter the name of file/folder to search:\n"; chomp(my $fn=); find(\&Wanted,

Re: hash keys

2008-06-12 Thread Paul Lalli
f values to be passed to sprintf(). Anywhere Perl expects a list, if it sees a function/subroutine, it calls that function/subroutine in list context. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Meaning of [EMAIL PROTECTED]

2008-06-12 Thread Paul Lalli
@temp1 at the time it was created. In your modification, $temp2[$cnt] is a reference to @temp1. In the OP, if any following statements modify @temp1, those changes will not be reflected in @{$temp2[$cnt]}. Similarly, changes to @{$temp2[$cnt]} will not be reflected in @temp1. In your modifi

Re: algorithm/permute.pm

2008-03-24 Thread Paul Lalli
package quickly in my home path and try out this call? perldoc -q install Found in /opt2/Perl5_8_4/lib/perl5/5.8.4/pod/perlfaq8.pod How do I install a module from CPAN? Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: perl warnings

2008-03-17 Thread Paul Lalli
ined("$action"))' but that still produces a warning. > >      if ( ! $action ) {...} That'll work great until some jackass puts "?action=0" in the URL. Using defined() is correct. It's what he's passing to defined() that's not. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: perl warnings

2008-03-17 Thread Paul Lalli
string will *always* be defined, regardless of whether or not the variable is. if (defined($action)) { ... } not if(defined("$action")) { ... } $ perl -wle' my $foo; if (defined("$foo")) { print "1 yes"; } else { print "1 no" } if (defined($foo))

Re: Time::Piece capturing parsing problems

2008-02-28 Thread Paul Lalli
ib/Time/Piece.pm line 470. > 28/02/2008 > > TEST 1 > eval error: Error parsing time at C:/Perl/site/lib/Time/Piece.pm line 470. > $ Looks to me like Time::Piece is just printing a warning rather than die()ing on that particular error. I'd suggest simply turning warnings into er

Re: Why doesn't this work: matching capturing

2008-02-26 Thread Paul Lalli
/^.{8}150.{18}24510.{21}(.{6})(.)/ and print "Tract $1 BLKGRP $2\n"; Try enabling warnings to see of your two variables are undefined (which they would be if the pattern didn't match) or just empty strings (which they would be if the pattern matched but nothing was captured - this, of course, isn't possible, since a six-character match can't possibly be the empty string). Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: array question

2008-02-26 Thread Paul Lalli
from CPAN: #!/usr/bin/perl use strict; use warnings; use List::MoreUtils qw/zip natatime/; my @foo = (1, 2, 3); my @bar = qw/a b c/; my $it = natatime 2, zip(@foo, @bar); while (my ($f, $b) = $it->()) { print "$f - $b"; } __END__ 1 - a 2 - b 3 - c Paul Lalli -- To unsubscribe

Re: OO question

2008-02-26 Thread Paul Lalli
ke sense. Can I add an attribute > to an object after I've created it in this way. Go back to basics. An object is just a hash[1], a reference to which happens to be blessed into a specific class. But it's still just a hash. Anything you can do to a normal hash, you can do to

Re: Are comments allowed before package declarations in modules?

2008-02-26 Thread Paul Lalli
ts safe. what happened when you tried it? You can put all the comments you want before a `package` statement. Your misremembering is likely tied to the fact that you can't put any comments (or anything else) before the shebang in the main file. Paul Lalli -- To unsubscribe, e-mai

Re: Object Oriented Perl

2008-02-19 Thread Paul Lalli
hat come bundled with perl itself (perldoc perltoot, perldoc perlobj, perldoc perlmod, perldoc perlboot, etc) While I love Damian's Perl Best Practices, I don't think I've ever read his OOP book. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Hash values as array indexes inside Arrays

2008-02-16 Thread Paul Lalli
65 2 3 3 3 \; > > Because of the backslash? And in your mind, what's wrong the backslash? $ perl -le' @foo = qw \ a b c \; print for @foo; ' a b c Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Pseudo-hashes are deprecated

2008-01-29 Thread Paul Lalli
mming Perl (third edition)' Section 9.4.3 One of us is very confused. I'm guessing you. There is no such thing as "9.4.3" in the third edition of the Camel. There is a chapter 9, of course, and indeed it deals with multi-dimensional structures. But there is no such example

Re: creating multiple variables in loop

2008-01-25 Thread Paul Lalli
size of the array minus 1. What are you actually trying to accomplish? If for some reason you think you need to know where in an array some value (even another array ref) is stored, you're using the wrong data structure. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Recover doesn't match regular expression

2008-01-23 Thread Paul Lalli
language. That's perfectly fine. However, in that case, you should really try to speak Perl rather than speak English. Show an example of what you're trying to do. Show sample input and desired output. Show whatever code you already have. Your question, as worded, does not make any sen

Re: about the dot

2008-01-22 Thread Paul Lalli
o says Perl interpreter will ignore the blackspace around an operator? I > saw it doesn't here. > Ok you may say 3.4 is a float not a statement with '.' operation, but this > case really make people confused. I challenge you to find a single person "confused" by

Re: 答复: Help in system function

2008-01-17 Thread Paul Lalli
ot;...") caues the output to be printed to the screen. `...` causes the output to be returned. In either case, the OP said the command is not being executed, which means it's not generating any output. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional co

Re: print a selection of a file

2008-01-09 Thread Paul Lalli
; operator, which looks just like the range operator: .. while (my $line = <$file>) { if (/HORCM_INST/ .. /^\s*$/) { print $line; } } read more about it in: perldoc perlop Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: parsing post parameters

2008-01-09 Thread Paul Lalli
for is the ref() function, which returns a true value if given a reference (actually, it returns a string representing what type of reference it's given: 'ARRAY', 'HASH', 'CODE', 'SCALAR', etc), and returns a false value if given a non-reference. ref([E

Re: What is happening with this filehandle?

2008-01-08 Thread Paul Lalli
generates is redirected to the file myfile.txt In a "normal" open for writing: open (COND, '> file.txt') or die ...; whatever is printed to COND ends up in the file file.txt In a pipe-open for writing: open (COND, '| file.pl') or die ...; whatever is printed to C

Re: avoid using a temporary variable

2008-01-08 Thread Paul Lalli
minates the temporary variable but doesn't work: > > $ ls | perl -e 'print join(" ", chomp(<>))' ls | perl -e' print join(" ", map { chomp; $_ } <>)' Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Use parentheses in translation strings

2008-01-02 Thread Paul Lalli
r, which will replace the string '' with the string '(\d\d\d\d)', so long as you remember to escape the backslashes: s//(\\d\\d\\d\\d)/; or: s/y{4}/(\\d\\d\\d\\d)/; for more information: perldoc perlop perldoc perlre Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: how to accept array elments using loop

2007-12-28 Thread Paul Lalli
does it not meet your needs? What do you want to do instead of that? Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Hi... Help regarding chdir

2007-12-19 Thread Paul Lalli
mith. If that's the "error" you're talking about, please read: perldoc -q directory Found in /usr/lib/perl5/5.8/pods/perlfaq8.pod I {changed directory, modified my environment} in a perl script. How come the change disappeared when I exited the script? How do

Re: Use of uninitialized value in numeric eq (==)

2007-12-13 Thread Paul Lalli
nt "$_ = $opts_hash{$_}\n"; > > } > > } > > An alternative way to write that: > > for (sort keys %opts_hash) { > next unless defined $opts_hash{$_}; Or: for (grep { defined $opts_hash{$_} } sort keys %opts_hash) { :-) Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: seek/tell usage

2007-12-11 Thread Paul Lalli
e of your whiny little rant I read. Hence, I felt no particular desire to be helpful to you. So I replied in a way that made me happy. I couldn't care less that it didn't make you happy. So long. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: seek/tell usage

2007-12-11 Thread Paul Lalli
;hpdb pre seek bytes <$bytes> \n"; > print FILE "line\nline\nline\nline\n"; > > ## go back to 100 bytes before previous end of file. > seek(FILE, -($bytes -100) ,2); > while(){ >print "hpdb tell by line:" . tell(FILE) . "\n";} > &g

Re: Extra Commas in output!

2007-12-06 Thread Paul Lalli
e quote. Your data above is not separated by a doublequote followed by a comma followed by a double quote. Your fields are separated by commas followed by spaces. Therefore, your @tmpArray contains exactly one element - the entire string. But then you're going ahead and assuming there are 42 elements in the array, and trying to assign variables to all 42 of them, and then printing out 42 different variables. > print CSV_OUT > "($customers_id,$customers_name,$customers_company,$customers_street_addres-s,$customers_suburb,$customers_city,$customers_postcode,$customers_state,$c-ustomers_country,$customers_telephone,$customers_email_address,$customers_a-ddress_format_id,$delivery_name,$delivery_company,$delivery_street_address,-$delivery_suburb,$delivery_city,$delivery_postcode,$delivery_state,$deliver-y_country,$delivery_address_format_id,$billing_name,$billing_company,$billi-ng_street_address,$billing_suburb,$billing_city,$billing_postcode,$billing_-state,$billing_country,$billing_address_format_id,$payment_method,$payment_-module_code,$shipping_module,$shipping_method,$coupon_code,$cc_type,$cc_own-er,$cc_number,$cc_expires,$cc_cvv,$last_modified,$date_purchased,$orders_st-atus,$orders_date_finished,$currency,$currency_value,$order_total,$order_ta-x,$paypal_ipn_id,$ip_address)\n"; I'm not looking at all of this mess, but where the hell did $ip_address and $paypal_ipn_id come from? They're not listed among your 42 variables. Post code that you're actually running. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: regex parsing-Beginner

2007-12-04 Thread Paul Lalli
you would have seen that. change @new = $line; to push @new, $line; so that each matching value of $line gets added to the end of @new, rather than overwriting the existing contents. push @new, $line means roughly the same thing as @new = (@new, $line); except it's more efficient. Think of 'push' as the same sort of shortcut as the .= operator, so you can write $text .= $string; rather than $text = $text . $string; perldoc -f push for more information. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: "premature end of header" script error

2007-11-29 Thread Paul Lalli
print the header. If you're using the CGI module (and if you're not, you should be), just stick this line before any of your print statements: print header; Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Time Comparison Easier Than I'm Making them

2007-11-28 Thread Paul Lalli
n > someone > please just point me to what I can use? I'll figure it out from there. use Time::Local; my $record = '2007-11-28 10:43:30"; my ($y, $m, $d, $h, $i, $s) = split /[-: ]/, $record; my $ts = timelocal($s, $i, $h, $d, $m-1, $y-1900); my $now = time(); if (($now

Re: How to get the name of the variable a reference is "pointing" at

2007-11-20 Thread Paul Lalli
2 => \%Hash2, hash3 => \ %Hash3); while (my ($name, $ref) = each %hash_named) { while (my ($key, $val) = each %{$ref}) { debug("$name: $key => $val"); } } Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Problem with Hashes

2007-11-16 Thread Paul Lalli
} = $event_line[0]; > $events[$cnt]{start} = $event_line[1]; > $events[$cnt]{end} = $event_line[2]; > $events[$cnt]{display} = $event_line[3]; > $events[$cnt]{link} = $event_line[4]; > $cnt++; This should all be replaced creating a single hashref and pushing it onto @events: my $hashref; @{$hashref}{qw/title start end display link/} = @event_line; push @events, $hashref; Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: interface Perl script with an external website (Pass Values to a web)

2007-11-16 Thread Paul Lalli
ut (@inputs) { if ($input->{id} eq 'blablah') { $input->{value} = "whatever"; } } __END__ Frankly, I have no idea if that would do the right thing when you later try to submit the form. I stand by my original recommendation - fix the HTML. Paul Lall

Re: variably named subroutines

2007-11-09 Thread Paul Lalli
e asked is: use an array of subroutine references. my @foo_bar_subs = ( sub { print "I'm the first sub!\n"; }, sub { print "I'm number 2!!\n"; }, # . . . ); #call the first foo_bar_sub: $foo_bar_subs[0]->(); Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Hash slice

2007-11-09 Thread Paul Lalli
t; }; > #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use List::MoreUtils 'each_array'; my @keys = qw/fe fi fo fum/; my @one = (1..4); my @two = (11..14); my $it = each_array @one, @two; my %h; @[EMAIL PROTECTED] = map { [ $it->() ] } [EMAIL PROTECTED]; print Dumper(\%h); __END__ Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Splitting two numbers joined by a minus sign

2007-11-09 Thread Paul Lalli
make such an assumption. The OP's subject does not match the OP's goal. Oh well. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Splitting two numbers joined by a minus sign

2007-11-08 Thread Paul Lalli
th a solution, but I'm sure there's an easier way. Is > there a more elegant way of doing it? Split on either whitespace or on a minus sign that is both followed by and preceded by a digit: my @fields = split /\s+|(?<=\d)-(?=\d)/, $line; Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: What's the different of ( -name=>value ) and ( name=>value )

2007-11-08 Thread Paul Lalli
bleName. It's up to the programmer whatever he/she likes better. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Referencing a hash to be dereferenced...

2007-11-06 Thread Paul Lalli
On Nov 6, 12:55 pm, [EMAIL PROTECTED] (Chas. Owens) wrote: > On 11/6/07, Paul Lalli <[EMAIL PROTECTED]> wrote: > snip> > my $filekey = $filekey.$sched_id; > > > This makes no sense. You're declaring a variable on the left and > > assigning it to

Re: Referencing a hash to be dereferenced...

2007-11-06 Thread Paul Lalli
On Nov 6, 12:55 pm, [EMAIL PROTECTED] (Chas. Owens) wrote: > On 11/6/07, Paul Lalli <[EMAIL PROTECTED]> wrote: > snip> > my $filekey = $filekey.$sched_id; > > > This makes no sense. You're declaring a variable on the left and > > assigning it to

Re: Referencing a hash to be dereferenced...

2007-11-06 Thread Paul Lalli
. ALL subroutines in perl are passed by reference. I think you meant "You do not need to pass a reference to it", which is remarkably different. There's that less than pedantic attention to detail again... Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Referencing a hash to be dereferenced...

2007-11-06 Thread Paul Lalli
in, strict would tell you when you make mistakes like this. > my $temp_file = "/tmp/.bw3-temp-${filekey}.tmp"; > return $temp_file; I don't understand the point of creating and storing a variable only to then immediately return it. Why not just return the

Re: How to get teh line before a last from file

2007-11-06 Thread Paul Lalli
$fh, '<', $file or die $!; my ($last, $before_last); while (<$fh>) { $before_last = $last; $last = $_; } #3 use File::ReadBackwards; my $bw = File::ReadBackwards->new($file) or die $! $bw->readline(); my $before_last = $bw->readline(); Paul Lalli -- To unsubscribe,

Re: STDIO does not hold execution

2007-11-05 Thread Paul Lalli
> ./script.pl line 70." > > # The script just continues??? > > } How are you running the script? By any chance are you piping some other command to it, or providing input redirection on the shell? What is the actual command you type at the command line to execute this prog

Re: Filehandle and redirection of STDOUT

2007-11-02 Thread Paul Lalli
processes inherit their parent's STDIN, STDOUT, and STDERR. Try it and see for yourself, rather than telling the OP that his program is wrong. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Filehandle and redirection of STDOUT

2007-11-02 Thread Paul Lalli
here's a couple ways to handle this. One is to localize your change to *STDOUT so that it goes back to what it was when the block ends: { local *STDOUT; open (STDOUT,">reverse.txt"); system("whatever"); } print "Back to the screen."; The more obvious

Re: Help with passing arrays to a Perl subroutine

2007-11-01 Thread Paul Lalli
On Nov 1, 6:35 pm, [EMAIL PROTECTED] (Dr.Ruud) wrote: > Paul Lalli schreef: > > You need @{$xValues} and @{$yValues}. > > Thanks for the correction of my stupid typoes. In the line that came > after what you quote, and in the code that followed it, it is OK. > BTW, the {} ar

Re: Help with passing arrays to a Perl subroutine

2007-11-01 Thread Paul Lalli
> > A graph subroutine is not likely to change the input data, so there is > no reason to copy the input data. > >my ($xValues, $yValues) = @_; > > and then use @xValues and @yValues where you need the arrays, No. @xValues and $xValues have nothing to do with

Re: XMLout and suppressempty

2007-11-01 Thread Paul Lalli
On Nov 1, 10:09 am, [EMAIL PROTECTED] (Ernond Paul) wrote: > I would like to suppress empty element when I output mu hash with > XMLout > but the option "suppressempty" only seeme to work with XMLin : > "suppressempty => 1 | '' | undef (in) : This option controls what > XMLin() should do [...]" Yo

Re: XMLout and suppressempty

2007-11-01 Thread Paul Lalli
quot;element"}[0]{"sub"}[0] = undef; None of those remove the element in question. perldoc -f delete perldoc -f undef You want splice() instead, since you're dealing with arrays on the final level. perldoc -f splice Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Help with passing arrays to a Perl subroutine

2007-11-01 Thread Paul Lalli
my ($x_ref, $y_ref) = @_; my @x = @{$x_ref}; my @y = @{$y_ref}; # . . . } # take_two([EMAIL PROTECTED], [EMAIL PROTECTED]); Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: FileHandle

2007-11-01 Thread Paul Lalli
; on the if clause. > > while () { > print "$_\n" if ( /MARK/ ); > } > > Hope I'm not too far off. Please don't guess. If you don't know the answer, either research and find the right answer, or just let other people answer. Giving wrong

Re: Getting error in Net::SFTP with get function

2007-11-01 Thread Paul Lalli
onfused about the context. You are still confused about context. It makes no sense to return ANYTHING in void context. Void context very specifically means that the return value is not used, looked at, or stored in any way. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

Re: interface Perl script with an external website (Pass Values to a web)

2007-11-01 Thread Paul Lalli
ch as a search box), click the submit button (via code, obviously, not the mouse) and retrieve the results. http://search.cpan.org/~petdance/WWW-Mechanize-1.32/lib/WWW/Mechanize.pm Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Getting error in Net::SFTP with get function

2007-10-31 Thread Paul Lalli
code should be correct. But maybe > I'm missing something. It's correct unless the file the OP is retrieving happens to be empty (or contains nothing but '0'). Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Pragmas use strict and use warnings

2007-10-31 Thread Paul Lalli
On Oct 30, 5:24 pm, [EMAIL PROTECTED] (Jenda Krynicky) wrote: > On 30 Oct 2007 at 10:22, Paul Lalli wrote: > > > > > > > On Oct 30, 11:15 am, [EMAIL PROTECTED] (Chas. Owens) wrote: > > > On 10/30/07, Kaushal Shriyan <[EMAIL PROTECTED]> wrote: > >

Re: Pragmas use strict and use warnings

2007-10-31 Thread Paul Lalli
On Oct 30, 2:23 pm, [EMAIL PROTECTED] (Kevin Viel) wrote: > > -Original Message- > > From: Paul Lalli [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, October 30, 2007 12:23 PM > > To: [EMAIL PROTECTED] > > Subject: Re: Pragmas use strict and use warnings &g

Re: Include variables from external perl script

2007-10-30 Thread Paul Lalli
On Oct 30, 1:51 pm, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: > On Oct 30, 2:50 pm, [EMAIL PROTECTED] (Paul Lalli) wrote: > > > If there is no strict, 'our' is a no-op. > > Not entirely true. The scope of a variable declared with our is > different from one t

Re: Split function

2007-10-30 Thread Paul Lalli
On Oct 30, 1:30 pm, [EMAIL PROTECTED] (Rob Dixon) wrote: > Paul Lalli wrote: > > Annoyingly, split / /, $foo; and split ' ', $foo; are not the same > > thing. split ' ', $foo is a special case that means to split on all > > sequences of whitespa

Re: Include variables from external perl script

2007-10-30 Thread Paul Lalli
On Oct 30, 1:51 pm, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: > On Oct 30, 2:50 pm, [EMAIL PROTECTED] (Paul Lalli) wrote: > > > If there is no strict, 'our' is a no-op. > > Not entirely true. The scope of a variable declared with our is > different from one t

Re: Pragmas use strict and use warnings

2007-10-30 Thread Paul Lalli
ND__ With strict enabled, the only way to use a short-name of a variable is to declare a lexical of that name (the right choice) using 'my', or to disable strict 'vars' on a variable-by-variable case using 'our' (the wrong choice). This is what leads people to assert

Re: Perl 5.8.6 bug in open()?

2007-10-30 Thread Paul Lalli
On Oct 30, 11:09 am, [EMAIL PROTECTED] (Paul Johnson) wrote: > On Tue, Oct 30, 2007 at 07:42:02AM -0700, Paul Lalli wrote: > > It's known, but I don't know that it qualifies as a bug. When you > > use the two argument form of open, Perl is looking for both the > >

Re: Include variables from external perl script

2007-10-30 Thread Paul Lalli
uot;abc"; > In addition to changing 'my' to our' in Config.pl, you'll also need to > add the 'our $value;' to Script.pl Blatantly untrue. The OP was not using strict. 'our' is only required to be able to refer to global variables without qualifying

Re: Perl 5.8.6 bug in open()?

2007-10-30 Thread Paul Lalli
ent form to open a file with arbitrary weird characters in it, open(FOO, '<', $file); otherwise it's necessary to protect any leading and trailing whitespace: $file =~ s#^(\s)#./$1#; open(FOO, "< $file\0"); Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Perl 5.8.6 bug in open()?

2007-10-30 Thread Paul Lalli
ibly with spaces separating them. Since your file ends in a space, you can't use this shortcut. In reality, you should NEVER use this short cut. Use the three-argument form of open, and you'll be fine: open my $FH, '<', $fname or die "Cannot open '$fname': $!"; perldoc -f open for more information Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: printf problem

2007-10-30 Thread Paul Lalli
if successful. sprintf() returns the string You are printing to the screen and storing the result (the 1) in $bcol, and then printing $bcol. Make up your mind. Either change the printf() to sprintf() or eliminate $bcol entirely. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Split function

2007-10-30 Thread Paul Lalli
lit /\s+/, $foo; In your statement, you're only splitting on a single whitespace character. There are two spaces in your string, so you're getting a null string as the second element of the returned list, since there is a "nothing" in between the two space characters. Paul La

Re: Quotes and apostrophes assistance

2007-10-29 Thread Paul Lalli
ecute. irrelevant advice, nothing to do with the problem at hand. There is no reason to alter the OP's method of using selectrow_array. my ($val) = $dbh->selectrow_array("SELECT foo FROM bar WHERE id = ?", undef, q{stuff'with'quotes'}); http://search.cpan.org/~tim

Re: Newbie question on substitution with Subroutines

2007-10-25 Thread Paul Lalli
; } > if ($var =~ s/dell/laptop/g) { > $count3++ > }} Same comments here. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: problem runing code | strange Error

2007-10-23 Thread Paul Lalli
o > <[EMAIL PROTECTED]>', > 'Subject' => 'PiX Detected Attack ' > ); Mail::Mailer::open takes a hash reference. You have passed it a list of key/value pairs. Stick a { before 'From' and a } after 'Attack' to create your hash reference. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Absolute noobie question regarding opening files on Windows platform

2007-10-23 Thread Paul Lalli
. You should ALWAYS use front slashes, regardless of Windows vs Unix. The only thing in Windows that requires backslashes is the cmd.exe or command.com shells. You are not using these shells when you write a Perl program. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For addi

Re: Absolute noobie question regarding opening files on Windows platform

2007-10-23 Thread Paul Lalli
last operating system error. It will tell you why the file could not be opened. Change your die() to: die "Cannot open the given file: $!"; Not relevant to the problem at hand, but you should also be using lexical filehandles instead of global barewords, and get into the habbit of using

Re: Absolute noobie question regarding opening files on Windows platform

2007-10-23 Thread Paul Lalli
rop the './' entirely. To the OP, please ignore this post completely. It is very wrong, and will lead you to more complicated errors. Yitzle, I'm sure you mean well, but taking random guesses at what might be wrong, and worse, at what a solution might be, are far worse than giving no

Re: Password generator (limit my dictionary to...)

2007-10-22 Thread Paul Lalli
On Oct 22, 2:18 pm, [EMAIL PROTECTED] (Jay Savage) wrote: > On 10/22/07, Paul Lalli <[EMAIL PROTECTED]> wrote: > > > On Oct 22, 2:45 am, [EMAIL PROTECTED] (Michael Alipio) wrote: > > > > The output should be a dictionary file that is minimum > > > 6 chara

Re: Password generator (limit my dictionary to...)

2007-10-22 Thread Paul Lalli
abandon the illogical desire to contrain yourself to one giant regexp expression. There is no need for such a requirement. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Password generator (limit my dictionary to...)

2007-10-22 Thread Paul Lalli
/perl > use warnings; > use strict; > > my $wordlist = shift @ARGV; > #my $newwordlist = shift @ARGV; > > open INPUTFILE, "$wordlist" or die $!; > #open OUTPUTFILE, ">$output" or die $!; > > while (){ next unless /^[a-z0-9]{6,15}$/; next unless tr

Re: Read in XML File for input

2007-10-19 Thread Paul Lalli
On Oct 19, 2:04 pm, [EMAIL PROTECTED] (Joseph L. Casale) wrote: > My whole project got too messy so I decided to use an existing XML file to > load in all the needed input I would require. > > I have the following code but fail to access to data in $workspace. > > my $workspace = XMLin($ARGV[0], f

Re: Assemble file and directory name for copy

2007-10-19 Thread Paul Lalli
) or die "Could not copy: $!": If for some reason you insist on using backslashes, you have to quote them first, as they're just characters, but you also have to escape them, which means putting a second backslash in front of them: copy ($FromDir . '\\' . $File, $ToDir . &#

Re: Filtering output of readdir

2007-10-18 Thread Paul Lalli
rstand why you'd give it. Especially since you seem to give the impression that open $dh, 'dir/'; @files = readdir $dh; and @files = ; give the same result. They don't. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: printing elements of an arrays of references

2007-10-18 Thread Paul Lalli
x], "\n"; > > > > } > } To dereference a reference, you enclose the reference in { } and prepend the appropriate sigil ($ for scalar, @ for array, % for hash) for my $heading (@{$AoA[0]}) { print "$heading\t"; } print "\n"; or more simply print join(&qu

Re: Sleep apnea

2007-10-16 Thread Paul Lalli
arnings; > print 8*8, "\n"; > sleep 3; > print 7*7, "\n"; Rather than changing the output by adding newlines, you can simply turn output buffering off: $|++; Read about the $| variable in `perldoc perlvar` Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: why "cant execute " error ?

2007-10-15 Thread Paul Lalli
only takes the bind parameters. If there are no bind parameters, it takes no arguments at all. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: why "cant execute " error ?

2007-10-15 Thread Paul Lalli
only takes the bind parameters. If there are no bind parameters, it takes no arguments at all. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: why "cant execute " error ?

2007-10-14 Thread Paul Lalli
epare($sql) or die "cant prepare"; > $sth->execute($sql) or die "cant execute"; > > and i get a "cant execute" error from cgi script thats running the > query. > > how do i sort out what the problem is ? By asking Perl/DBI what you did wrong. $sth-&

Re: WWW::Mechanize

2007-10-12 Thread Paul Lalli
On Oct 11, 3:31 pm, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: > On 11 Oct, 16:20, [EMAIL PROTECTED] (Paul Lalli) wrote: > Paul, sorry the issue is that it doesn't work :) That's a phenomenally bad error description. Only *you* know what you want your script to do. None of us

  1   2   3   4   >