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

    Accessing Unix folder in Perl on windbows based

    I suggest you use strict; # and use warnintgs;
  2. knights199

    Help with error handling...

    If you want Perl to raise an error/warning, why not use the 'warn' and 'die' functions?
  3. knights199

    Output on screen for every line of copy

    It might just me, but doesn't this code simply copy C:\First.txt to C:\Second.txt for every line in LIST? Or is that what you want to do? Because, I can't see the use in copying the same file multiple times.
  4. knights199

    Modules on A Hosted Server

    The '.' in the @INC array represents the current directory (e.g. the directory of your script). I assume you can easily place modules in there. (e.g. /path/script.pl and /path/IO/Socket.pm etc). If this is not what you want, 'use lib' like everyone else suggested :p
  5. knights199

    Modules on A Hosted Server

    I suggest checking the @INC array on the server to see in what directories will be looked for modules.
  6. knights199

    open(INFO, $file) - open MORE THAN 1 File ?

    Kevin is right, 'perldoc -f do' for more help. Also, the <> operator can be used to read data (on default: a line) from an open filehandle. STDIN is a "fileglob" (I think, might aswell forget about that) and is always open by default. Any reads from it will read input from the terminal (by...
  7. knights199

    open(INFO, $file) - open MORE THAN 1 File ?

    my $file_to_open; $file_to_open = $ARGV[0] or do { print "Enter filename: "; chomp( $file_to_open = <STDIN> ); }; print "$file_to_open\n";
  8. knights199

    Removing lines starting with # from a file

    open (DEFAULT, "<$default_template") or die; $config = join( "", grep { not /^#/ } <DEFAULT> ); close DEFAULT; No lines starting with a comment.
  9. knights199

    open(INFO, $file) - open MORE THAN 1 File ?

    It's because the open operator doesn't accept any wildcards in the filename. It will try to open the file with constant name 'test*.file' . Something like the following might be what you're looking for (untested): use strict; use warnings; my( @handles, $fh ); my $err = 0; foreach (...
  10. knights199

    convert variable to regex

    I suggest you try to find out :-) However, I would suggest: name => "(?i:".$Pattern->Text.")", as the argument for 'name' should (probably) be a string and not a slash-delimited regex :-)
  11. knights199

    convert variable to regex

    *Grabs Friedl of the shelf* my $foo = "Hello World"; my $obj1 = qr/world/; my $obj2 = qr/(?i:world)/; $foo =~ /$obj1/ and print "test 1 ok\n"; # Won't work $foo =~ /$obj2/ and print "test 2 ok\n"; # Might just work because of (?i:) in regex"Some flavors also support (?i:...) and (?-i:...)...
  12. knights199

    regular expression for directory structure

    [/]? will succeed either way. It will accept a '/', but it will be satisfied with nothing. try:^/forms/guide(/[^/]*)?$ Untested though :-)
  13. knights199

    if (! $small_string=~ /\s*/){ - NOT WORKING

    if (! $small_string=~ /^\s*$/){ print "$small_string\n"; }The reason this doesn't work is because the '!' operator has too high a precedence. Replace it with 'not' (which has a very low precende) or enclose the entire expression '$small_string =~ /blah/' in...
  14. knights199

    my $small_string = substr ($_, 168, 6); SUBSTR

    Using previous solutions; this will only do the counting. my $count = grep { substr($_, 168, 6) !~ /^\s*$/ } <INFO>; print "Number of small_strings with a value: $count\n";
  15. knights199

    Capture Text

    #!/usr/bin/perl /^User\s?name=(.+)/ and $uname = $1 while <DATA>; print "\$uname eq $uname\n"; __DATA__ foo bar User name=jriggs baz TIMTOWTDI :-)
  16. knights199

    Simple regex

    my @combin = ("anything_D", "something_H");
  17. knights199

    getting the return value from a socket connection

    Either send something that your script will recognize to manually break out of the loop, or close the connection on the remote machine. while (<$sock>) { # will return eof if connection on $sock dies chomp; print "$_++++++\n"; /^exit/ and last; # break out if 'exit' received }
  18. knights199

    getting the return value from a socket connection

    Are you sure you're printing <$sock> and not $sock? If your code still hangs, you can try and edit the $/ variable. <$sock> will return when a string ending with a newline (the value of $/) can be read, change this value to something else to define your "end-of-message". Also see perldoc perlvar .
  19. knights199

    Split an array of comma separated elements

    Thanks :)
  20. knights199

    getting the return value from a socket connection

    print while <$sock>; Read it like any other filehandle.

Part and Inventory Search

Back
Top