All four syntaxes listed by Mike are valid with or without strict enabled.
What is NOT allowed with strict enabled is calling a sub with NEITHER & nor ():
use strict;
go;
exit;
sub go {
print "wibble!\n";
}
In this example Perl will complain bitterly:
Bareword "go" not allowed while...
The textarea field actually returns not individual linefeeds, but carriage return/linefeed pairs:
San Francisco\r\n
San Diego\r\n
Denver\r\n
You were close - but you need either a loop or better yet a regex to fix EACH line within the city param. Try this instead:
elsif($field =~ /city/)...
Ah. Yes, that would do it. DBI is not very nice about telling you when something is wrong on the database end - it tends to just quit, kill your script, and leave you to sort it out yourself. Rather unfriendly.
Glad you solved it!
--G
Like this?
Usage: <scriptname> <char to delete> <filename>
#!<your perl binary location>
$char=$ARGV[0]; # get char to delete from command line
$file=$ARGV[1]; # get file to modify from command line
undef $/;
# get file contents
open(IN,"<$file");
$file=<IN>;
close IN;
# delete char...
Hmm. Have you tried checking it from the command-line?
perl -c <scriptname>
That might give some hints what's wrong if there is a syntax error in the code.
You might also get that error if you attempt to print something back to the browser before printing the "Content-type" string. You seem...
Ah. Helps if you post the actual problem first. :-)
You can just extend my first regex to do what you want:
$_ =~ s/^.+? .+? //; # removes first 2 words from $_
--G
It occurs to me you probably would like a more general expression to remove the first word from any string:
$_ =~ s/^.+? //; # removes first word and space from $_
--G
Oh nice, Tom. I KNEW there had to be a way to do it in one line, but I just couldn't quite get ther. Might of known a regex would solve it. Cheers. :-)
--G
Try this. I stuck it in a sub for ease of use.
$clean_str = cap_str('RIGHT HERE FOR YOU');
print "Capitalized string: $clean_str\n";
exit;
# convert any string to Capitalized Words
sub cap_str {
my ($str) = @_;
my $new;
foreach (split(" ",$str)) {
$new .= (ucfirst lc $_) . " ";
}...
If addslashes does what I think it does (not a PHP guru), yes: q and qq.
For example, if I want to assign this line of HTML to a var in Perl:
<form name="myform" method="GET" action="/wibble/foo.cgi">
I would obviously not want to say
$formline = "<form name....>";
because I would then...
Oh good! Glad that helped.
Incidentally, if you want to actually know what the first level dimension is, this will get it:
$first_dim = $#{$foo};
After that you could use a similar syntax to find out the second dimension of each first dimension:
$second_dim_0 = $#{$foo->[0]};
Cheers!
--G
OH. I see. No, i misspoke slightly - the output I get is exactly the same as yours, except mine doesn't generate the last line you are not wanting. Here is what I get, on Solaris 8, with Perl 5.8, using the code as I posted it:
$i = 0, $j = 0, $foo->[0][0]->{name} = Dan, $foo->[0][0]->{id} =...
I intended to output the same, only without having to know ahead of time what the array dimensions were.
Perhaps I misunderstood your goal. (I'm a little tired today, sorry.) I thought the problem was how to do this without hard-coding the array boundaries. Could you restate the question?
--G
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.