- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- yet another quick perl question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 01:34 AM
тАО03-07-2005 01:34 AM
my $refer = "\"certified.shmtl\"";
print "Before: ",$refer,"\n";
# $refer =~ tr ?/??d;
print "After : ",$refer,"\n";
The first print statement prints
"certified.shtml"
I need to strip the trailing and leading double quotes out of the string. Can't seem to make line 3 (commented) do that for me.
Thanks to A. Clay Stephenson forthe base code.
Background: while moving a html document from one location to another, I'm pulling alont the VIRTUAL include document embedded in the document as well.
The line starts out looking like:
I used awk to cook it down to "certified.shtml"
Good Solution: 1 line of perl that strips out the trailing and leading double quotes.
Pefect solution: Perl code that goes straight through the html docu and gives me certified.shtml
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 01:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 01:44 AM
тАО03-07-2005 01:44 AM
Re: yet another quick perl question
print "Before: $refer\n"; # Wy list, just interpolate!
$refer =~ tr/"//d; # or $refer =~ s/"//g;
print "After: $refer\n";
Safe and generic:
$refer =~ s/^\s*"?(.*)"?\s*$//;
And your one-liner:
# perl -nle'm{include\s+virtual="([^"]+)"} and print $1' blah.html
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 01:44 AM
тАО03-07-2005 01:44 AM
Re: yet another quick perl question
I'll leave the thread open a few hours in case someone wants to do the Perfect solution.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 01:44 AM
тАО03-07-2005 01:44 AM
Re: yet another quick perl question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 01:52 AM
тАО03-07-2005 01:52 AM
Re: yet another quick perl question
The perl script was already running, so a one liner was not actually needed.
What was asked in the perfect answer was a few lines of code to search the a different file say named column.shtml for that
and get the filename certified.shtml into a variable.
Thread still open, a chance for Merijn to double his pointage.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 01:58 AM
тАО03-07-2005 01:58 AM
Re: yet another quick perl question
or inside the script
:
:
m{include\s+virtual="([^"]+)"}i and print $file = $1;
:
:
$file now contains "certified.shtml"
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 02:27 AM
тАО03-07-2005 02:27 AM
Re: yet another quick perl question
Some variation of:
perl -ne 'if (/INCLUDE VIRT/) { $file=(split(/"/))[1]; print "file=$file\n "}' input-data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 07:58 AM
тАО03-07-2005 07:58 AM
Re: yet another quick perl question
#!/opt/perl/bin/perl
# $refer =~ s/\"//g;
$refer = "stevefile";
m{include\s+virtual="([^"]+)"}i and print $file = $refer;
print "After : ",$file,"\n";
Does not produce output.
/opt/perl/bin/perl -nle'm{include\s+virtual="([^"]+)"}i and print $1' stevefile
Output:
hpuxws.shtml
searches the file and produces appropriate output.
Kind of wonderinig what I'm doing wrong. I like Merijn's approach and would like to finish the job. I have tried submiting the file stevefile on the command line but that produces nothing new and does not accomplish objective.
The file name inbedded in the file stevefile is the output I want, double quotes stripped.
SEP
~
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2005 08:31 AM
тАО03-09-2005 08:31 AM
Re: yet another quick perl question
--8<---
#!/opt/perl/bin/perl
# $refer =~ s/\"//g;
$refer = "stevefile";
m{include\s+virtual="([^"]+)"}i and print $file = $refer;
print "After : ",$file,"\n";
-->8---
I do not see a loop that puts every line of the file being parsed in $_, something that the -n option in
--8<---
/opt/perl/bin/perl -nle'm{include\s+virtual="([^"]+)"}i and print $1' stevefile
-->8---
does. In your script, you match against $_, which is empty. So if you want the *script* to do the same as the oneliner, change it to something like
--8<---
#!/opt/perl/bin/perl
my $file = "?";
@ARGV = ("stevefile");
while (<>) {
m{include\s+virtual="([^"]+)"}i and $file = $1;
}
print "After : ",$file,"\n";
-->8---
and see if that fits your needs
Enjoy, Have FUN! H.Merijn