Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. Geekatron

    subroutine call

    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...
  2. Geekatron

    Adding newlines Textarea data

    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/)...
  3. Geekatron

    Removing the leading white space in a string

    Try this: push @values, $1 while($ad=~/(\d+)/g); @values now contains all the values in the string. --G
  4. Geekatron

    internal server error

    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
  5. Geekatron

    delete perticular characters

    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...
  6. Geekatron

    internal server error

    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...
  7. Geekatron

    parse a simple string

    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
  8. Geekatron

    parse a simple string

    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
  9. Geekatron

    parse a simple string

    Several ways to do that, but the easiest is a regular expression: $_ =~ s/Hello //; --G
  10. Geekatron

    From upper case to lower case

    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
  11. Geekatron

    From upper case to lower case

    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 $_) . " "; }...
  12. Geekatron

    addslashes

    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...
  13. Geekatron

    How to tell the size of an anonymous array of hash?

    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
  14. Geekatron

    How to tell the size of an anonymous array of hash?

    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} =...
  15. Geekatron

    How to tell the size of an anonymous array of hash?

    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
  16. Geekatron

    How to tell the size of an anonymous array of hash?

    What about this: $foo = [ [ { name => 'Dan', id => '0001', }, { name => 'Bob', id => '0002', }, ], [ { name => 'Tom', id => '0003', }, ], ]...
  17. Geekatron

    Simple Perl Search script not working for my site

    You'll want to tweak this to add your own HTML layout, etc. I took a guess at your web root. I used fgrep here instead of grep because its less memory/cpu intensive for doing simple keyword matching. If you don't have fgrep you can use grep with the same syntax. #!/usr/local/bin/perl use CGI...
  18. Geekatron

    Simple Perl Search script not working for my site

    There are still errors in how you are trying to use File::find. Builder.com has an introduction to the use of File::Find that may be helpful: http://builder.com.com/5100-6371-1044617.html#Listing%20A However, there may be a much easier way to do this. Are you on a UNIX-based server, and if so...
  19. Geekatron

    Simple Perl Search script not working for my site

    You seem to have some typos in your code. For example, the line print "<li><a href=\"$File::Find::name\">$page_title</a></li>\n; is missing a trailing quote, and the two lines after that don't make sense - is that all supposed to be one line? Have you tried running this through the Perl...
  20. Geekatron

    Newbie Perl question

    You can also use metacharacters in strings to accomplish the same thing: $mystring = "fee \Ufi fo fum"; print $mystring'; output: fee FI FO FUM or $mystring = "\ufee fi fo fum"; print $mystring'; output: Fee fi fo fum \U - converts everything after it in a string to uppercase \L -...

Part and Inventory Search

Back
Top