c has asked for the wisdom of the Perl Monks concerning the following question:

I am using the following code:

#!/usr/bin/perl -wT use strict; my $file = "pancho-ng"; open(FH, $file); while(<FH>) { tr/\\\@/@/d; print if /USE/.../USE/ and !/USE/; } close(FH);

to print a portion of a file. the following text is contained within the portion being printed:

options [ --upload | --download | --commit ] [ --filename <filename> ] [ --list <list> ] [ --host <hostname> ] [ --server <ip/fqdn/hostname> ] [ --string <snmp community> ] [ --path <path within tftproot> ] [ --regex <regular expression> ] [ --version ] [ --verbose-help ] [ --help ]

the script works and print out the portion of the script i want it to, however it does not print out the < > characters or any text contained between them.
can someone explain why this is?

humbly -c

Replies are listed 'Best First'.
(Ovid) Re: printing the current script will not show
by Ovid (Cardinal) on Sep 11, 2001 at 01:38 UTC

    This works fine for me, also. Is there any chance that you have reduced this to a minimal test case and are actually viewing the results in a browser? If so, any data in the form /<[^>]*>/ (more or less) will be interpreted as a tag by the browser and will be ignored if it doesn't understand it.

    Cheers,
    Ovid

    Vote for paco!

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: printing the current script will not show
by blakem (Monsignor) on Sep 11, 2001 at 01:25 UTC
    hmmm... it seems to work just fine for me... Does this self contained script exhibit the errors when run in your environment?
    #!/usr/bin/perl -wT use strict; while(<DATA>) { tr/\\\@/@/d; print if /USE/.../USE/ and !/USE/; } __DATA__ I like jellybeans me too begin USE information options [ --upload | --download | --commit ] [ --filename <filename> ] [ --list <list> ] [ --host <hostname> ] [ --server <ip/fqdn/hostname> ] [ --string <snmp community> ] [ --path <path within tftproot> ] [ --regex <regular expression> ] [ --version ] [ --verbose-help ] [ --help ] end USE information Still like jellybeans me too =output options [ --upload | --download | --commit ] [ --filename <filename> ] [ --list <list> ] [ --host <hostname> ] [ --server <ip/fqdn/hostname> ] [ --string <snmp community> ] [ --path <path within tftproot> ] [ --regex <regular expression> ] [ --version ] [ --verbose-help ] [ --help ]

    -Blake